zhanxin

Done is better than perfect.

0%

Bee 节点部署

bee swarm 已成功部署主网,本文介绍如何在主网启动 bee 节点。

环境准备

  1. ubuntu 20.02.
  2. 2 核 4 G 55G 系统盘

单机器单节点部署

目前 bee 1.0.0 启动 bee-clef (密钥管理工具) 会导致 bee 节点无法启动,所以目前只需要启动 bee,可以通过 exportSwarmKey 导出私钥

安装 bee

1
2
wget https://github.com/ethersphere/bee-clef/releases/download/v0.4.13/bee-clef_0.4.13_amd64.deb
sudo dpkg -i bee-clef_0.4.13_amd64.deb

修改配置文件

配置文件默认地址为 /etc/bee/bee.yml,修改以下字段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
## Bee configuration - https://gateway.ethswarm.org/bzz/docs.swarm.eth/docs/installation/configuration/
full-node: true
## 关闭 bee-clef
clef-signer-enable: false
## NAT 公网地址,建议配置,并且要开启端口访问
nat-addr: "{{服务器公网 ip}}:1634"
# xdai rpc 调用,可以使用官方建议的 getblock.io 注册,也可以自建节点
swap-endpoint: "https://rpc.xdaichain.com/"
## initial deposit if deploying a new chequebook (default 10000000000000000)
## 如果不质押 BZZ,将这字段改为 0
swap-initial-deposit: 0
## triggers connection to main network
bee-mainnet: true
## 连接主网
mainnet: true

修改完成后执行 systemctl restart bee

启动节点

  1. journalctl --lines=100 --follow --unit bee 获取节点 xDai chain 地址
  2. 充值 0.01 XDAI
  3. curl localhost:1635/health 查看节点是否启动成功

导出节点私钥

因为bee-1.0.0 没有部署 bee-clef, 所以如果需要导出私钥,可以使用官方建议的工具exportSwarmKey 导出私钥进行备份。

  1. 服务器环境需要安装 golang git
  2. git clone https://github.com/ethersphere/exportSwarmKey.git
  3. 开启国内 go package 代理,go env -w GOPROXY=https://goproxy.cn,direct
  4. 导出私钥,go run pkg/main.go /var/lib/bee/keys/ {bee 节点密码,默认地址为 /var/lib/bee/password}
  5. 找到对应节点启动地址私钥,通过 Metamask 等以太坊钱包导入

如何自建 xDai Chain 节点

考虑到节点的稳定性,自建 xDai Rpc 是最好的选择

  1. 安装依赖环境,apt-get install build-essential cmake libudev-dev
  2. 下载安装包 wget https://github.com/openethereum/openethereum/releases/download/v3.2.5/openethereum-linux-v3.2.5.zip
  3. 解压安装包 unzip openethereum-linux-v3.2.5.zip
  4. 添加执行权限,chmod u+x openethereum && mv openethereum /usr/bin
  5. 启动节点
    1
    nohup openethereum --chain=xdai  --base-path=/root/gethnode/xdai --db-path=/root/gethnode/xdai/db  --jsonrpc-hosts=all --jsonrpc-interface=all  --jsonrpc-threads=8> /root/log.log 2>&1 &
  6. 同步完成替换 /etc/bee/bee.yml swap-endpoint 字段为 http://localhost:8545

参考资料

  1. swarm
  2. xdai