前期准备工具
- 操纵系统:Ubuntu 20.04.2 LTS/CentOS 8 x64
- 远程连接工具:FinalShell
Linux环境部署
Ubuntu更新系统命令
apt-get update
apt-get upgrade
CentOS更新系统命令
yum update
yum upgrade
创建并进入bee文件夹
依次输入命令:
mkdir bees
cd bees
下载安装clef
Ubuntu下载安装bee clef命令
wget https://github.com/ethersphere/bee-clef/releases/download/v0.4.12/bee-clef_0.4.12_amd64.deb
sudo dpkg -i bee-clef_0.4.12_amd64.deb
CentOS下载安装bee clef命令
wget https://github.com/ethersphere/bee-clef/releases/download/v0.4.12/bee-clef_0.4.12_amd64.rpm
sudo rpm -i bee-clef_0.4.12_amd64.rpm
下载安装bee
Ubuntu下载安装bee命令
wget https://github.com/ethersphere/bee/releases/download/v0.6.2/bee_0.6.2_amd64.deb
sudo dpkg -i bee_0.6.2_amd64.deb
CentOS下载安装bee命令
wget https://github.com/ethersphere/bee/releases/download/v0.6.2/bee_0.6.2_amd64.rpm
sudo rpm -i bee_0.6.2_amd64.rpm
安装screen
Ubuntu安装命令
apt-get install -y screen
CentOS安装命令
yum install -y screen
安装并在后台运行clef-service
screen -S clef
(确保路径是在/bees下)
新建clef-service文件
vim clef-service
按”i”键将如下代码全部复制粘贴到新建的文件
#!/usr/bin/env bash
start() {
KEYSTORE=/var/lib/bee-clef/keystore
CONFIGDIR=/var/lib/bee-clef
CHAINID=5
SECRET=$(cat /var/lib/bee-clef/password)
# clef with every start sets permissions back to 600
(while [ ! -f /var/lib/bee-clef/clef.ipc ]; do sleep 1; done && chmod 660 /var/lib/bee-clef/clef.ipc) &
rm /var/lib/bee-clef/stdin /var/lib/bee-clef/stdout || true
mkfifo /var/lib/bee-clef/stdin /var/lib/bee-clef/stdout
(
exec 3>/var/lib/bee-clef/stdin
while read < /var/lib/bee-clef/stdout
do
if [[ "$REPLY" =~ "enter the password" ]]; then
echo '{ "jsonrpc": "2.0", "id":1, "result": { "text":"'"$SECRET"'" } }' > /var/lib/bee-clef/stdin
break
fi
done
) &
clef --stdio-ui --keystore $KEYSTORE --configdir $CONFIGDIR --chainid $CHAINID --rules /etc/bee-clef/rules.js --nousb --4bytedb-custom /etc/bee-clef/4byte.json --pcscdpath "" --auditlog "" --loglevel 3 --ipcpath /var/lib/bee-clef < /var/lib/bee-clef/stdin | tee /var/lib/bee-clef/stdout
}
stop() {
echo "STOP! Systemd will stop the service!"
}
case $1 in
start|stop) "$1"
esac
按”:wq”保存退出编辑!
赋予clef-service文件可执行权限
chmod a+x clef-service
启动clef
./clef-service start
界面无报错即标代表启动完成
关掉当前窗口
按住ctrl不松,分别按a、d,关掉当前子窗口(注意是快速同时按一次就可以)
后台运行bee
screen -S bee
启动bee
bee start \
--verbosity 5 \
--swap-endpoint https://goerli.infura.io/v3/14a4d92bf5884b79b8d9d066eff829d2 \
--debug-api-addr :1635 \
--debug-api-enable \
--clef-signer-enable \
--clef-signer-endpoint /var/lib/bee-clef/clef.ipc
第一次输入需要输入2遍密码
后台运行bee
程序正常运行后,快速同时按下ctrl+a、d,跳出新页面即表示后台运行成功。
关闭窗口
关闭窗口即为退出当前服务器。(成功后台运行clef和bee后退出服务器程序也在跑,放心退出)
重新连入云服务器
双击节点,屏幕显示“连接成功”即表示成功连入。
查询状态
Ubuntu安装jq
apt-get install jq
CentOS安装jq
yum install jq
安装curl,可以用如下命令安装
sudo apt install curl
查看有无支票
curl localhost:1635/chequebook/cheque | jq
查看当前连接到多少个节点
curl -s http://localhost:1635/peers | jq '.peers | length'
测试连通
curl http://localhost:1633
检查网络拓扑
curl -X GET http://localhost:1635/topology | jq
查询当前节点余额
curl localhost:1635/chequebook/balance | jq
检查对等余额
curl localhost:1635/balances | jq
查看节点地址
curl http://localhost:1635/addresses
查看账本合约地址
curl http://localhost:1635/chequebook/address
兑换支票
下载兑现支票脚本
wget -O cashout.sh https://gist.githubusercontent.com/ralph-pichler/3b5ccd7a5c5cd0500e6428752b37e975/raw/b40510f1172b96c21d6d20558ca1e70d26d625c4/cashout.sh
赋予脚本可执行的权限
chmod a+x cashout.sh
查询兑换支票(有返回就代表有可兑换支票)
./cashout.sh
兑换支票
./cashout.sh cashout-all 5
记得定期兑换支票!
从bee-clef 的节点导出私钥
bee-clef-keys
会将 .JSON 文件和密码.txt文件存储到主文件夹中,将钱包导入到MetaMask时需要用到这两个文件!
原创文章,作者:朋远方,如若转载,请注明出处:https://bitchina.info/linuxxiadeswarmceshijiedianbushujiaocheng/.html