BHD钱包部署【生态池/合作池】
前序
BHD网址:https://btchd.org/#wallet

注:我这里是centos7, 所以我选linuxPC
部署
解压与配置
tar -zxf bhd-v1.3.4.0-d909c0e-x86_64-linux-gnu.tar.gz

注: 大概就长这个样子, 生态池和合作池是一样的, 端口不同而已。
启动之前记得把data目录替换(如果有原数据的话), 添加配置文件btchd.conf
启动
/opt/bhd-wallet/bin/btchdd -datadir=/opt/bhd-wallet/data/
直接nohup也行, supervisord也行, 下面扔个supervisord维护的配置过来
[program:btchdd_co] user=root directory=/opt/bhd-wallet/ environment=LD_LIBRARY_PATH="/opt/bhd-wallet/lib" command=/opt/bhd-wallet/bin/btchdd -datadir=/opt/bhd-wallet/data/ numprocs=1 startsecs=3 startretries=3 autostart=true autorestart=true process_name=%(program_name)s
就这样的启动成功了
验证
1.查看区块
https://btchd.org/explorer/block
对比与自己钱包的块值
/opt/bhd-wallet/btchd-cli.sh getMiningInfo

对比线上最新的+1

下面还有两条出数据代表正常
/opt/bhd-wallet/btchd-cli.sh getblockchaininfo /opt/bhd-wallet/btchd-cli.sh listsignaddresses
告警shell
注:发现钱包掉线马上告警, 主要使用的是getMininfo去获取每个字段中的值, 然后判断非空, 如果有空, 证明钱包挂了, 这是异常情况, 告警。当告警完之后, 获取到数据代表正常,
这个时候再发一条恢复告警提示管理员或者开发人员, 当无挂掉得时候正常显示, 可以使用nohup指定重定向日志。
#*************************************************************************
# > File Name: btchddProcess.sh
# > Author: chenglee
# > Main : chengkenlee@sina.com
# > Blog : http://www.cnblogs.com/chenglee/
# > Created Time : 2019年08月22日 星期一 14时28分49秒
#*************************************************************************
#!/bin/bash
hostname=`hostname`
NetWorkIP=`ip addr |grep inet |grep -v inet6 |grep eth0|awk '{print $2}' |awk -F "/" '{print $1}'`
BtchddProcess="btchdd_co"
count=0
#online
webhook="这里填写你的钉钉机器人告警url"
#test
function BTCHDDERROR(){
currTime1=`echo $(date +"%Y-%m-%d.%T")`
currchengtime=`echo $(date +"%Y-%m-%d %T")`
SsPid="$$"
curl ''$webhook'' \
-H 'Content-Type: application/json' \
-d '{"msgtype": "text",
"text": {
"content": "
服务器:'$hostname' 发生: '$BtchddProcess'活性故障!
[
告警主机:'$hostname'
告警地址:'$NetWorkIP'
监控项目:'$BtchddProcess'
告警等级:高
当前状态:中断
告警信息:'$BtchddProcess' is down
告警时间:'$currTime1'
事件ID:'$SsPid'
]
"
}
}'
}
function BTCHDDRESTART(){
currTime2=`echo $(date +"%Y-%m-%d.%T")`
currchengtime2=`echo $(date +"%Y-%m-%d %T")`
SsPid="$$"
continueTime=$(($(date +%s -d "$currchengtime2") - $(date +%s -d "$currchengtime")));
curl ''$webhook'' \
-H 'Content-Type: application/json' \
-d '{"msgtype": "text",
"text": {
"content": "
服务器:'$hostname' 发生: 进程'$BtchddProcess'活性恢复!
[
告警主机:'$hostname'
告警地址:'$NetWorkIP'
监控项目:'$BtchddProcess'
告警等级:中
当前状态:运行
告警信息:'$processname' restart success
告警时间:'$currTime1'
恢复时间:'$currTime2'
持续时间:'$continueTime' s
事件ID:'$SsPid'
]
"
}
}'
}
:<<cheng
function BTCHDDRESTARTOFF(){
curl ''$webhook'' \
-H 'Content-Type: application/json' \
-d '{"msgtype": "text",
"text": {
"content": "高级告警:[主机:'$hostname' - 进程:'$BtchddProcess' - 操作:活性检测异常 - 状态:重启失败]"
}
}'
}
cheng
function BTCHDDSUCC(){
curl ''$webhook'' \
-H 'Content-Type: application/json' \
-d '{"msgtype": "text",
"text": {
"content": "高级告警:[主机:'$hostname' - 进程:'$BtchddProcess' - 操作:活性检测异常 - 状态:恢复]"
}
}'
}
function btstatus(){
#curl -v -X POST 'http://127.0.0.1:8732/burst?requestType=getMiningInfo' > status
curl -X POST 'http://localhost:8911/burst?requestType=getMiningInfo' > status
sleep 2;
Height=`cat status | awk -F ',' '{print$1}' | awk -F ':' '{print$2}'`
GenerationSignature=`cat status | awk -F ',' '{print$2}' | awk -F ':' '{print$2}' | awk -F '"' '{print$2}'`
BaseTarget=`cat status | awk -F ',' '{print$3}' | awk -F ':' '{print$2}' | awk -F '"' '{print$2}'`
TargetDeadline=`cat status | awk -F ',' '{print$4}' | awk -F ':' '{print$2}'`
RequestProcessingTime=`cat status | awk -F ',' '{print$5}' | sed 's/}//' | awk -F ':' '{print$2}'`
}
function SKill(){
Pid=`ps aux | grep "btchdd" | grep -v grep | wc -l`
if [ $Pid > 0 ];then
ps aux | grep "btchdd" | grep -v grep | awk -F ' ' '{print$2}' | xargs kill -9
BTCHDDRESTART
if [ -z "$Height" -o -z "$GenerationSignature" -o -z "$BaseTarget" -o -z "$TargetDeadline" -o -z "$RequestProcessingTime" ];then
echo;
else
BTCHDDSUCC
fi
fi
}
function check(){
btstatus
if [ -z "$Height" -o -z "$GenerationSignature" -o -z "$BaseTarget" -o -z "$TargetDeadline" -o -z "$RequestProcessingTime" ];then
BTCHDDERROR
sleep 5;
count=$[count+1]
echo "[suspend:$count]"
echo "#####1:[$Height],2:[$GenerationSignature],3:[$BaseTarget],4:[$TargetDeadline],5:[$RequestProcessingTime]####"
else
echo "Success"
echo "#####1:[$Height],2:[$GenerationSignature],3:[$BaseTarget],4:[$TargetDeadline],5:[$RequestProcessingTime]####"
sleep 1;
if [ $count -gt 0 ];then
BTCHDDRESTART
count=0
echo "[suspend:$count]"
fi
fi
}
function main(){
while :
do
currTime=$(date +"%Y-%m-%d %T")
echo $currTime
check
echo;
sleep 60;
done
}
main


因为配置了supervisord自动拉起, 所以每次中断的时候就会自动重启。

浙公网安备 33010602011771号