Swarm 基于docker一机多节点布署

更新系统及初始化环境

sudo apt update
sudo apt -y upgrade

sudo apt install docker docker-compose  -y

# time adjust
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# install ulimit
rhn=`cat /etc/security/limits.conf |grep "root hard nofile 1048576"|wc -l`

if [ $rhn -le 0 ]; then
  ulimit -n 1048576
  sed -i "/nofile/d" /etc/security/limits.conf
  echo "* hard nofile 1048576" >> /etc/security/limits.conf
  echo "* soft nofile 1048576" >> /etc/security/limits.conf
  echo "root hard nofile 1048576" >> /etc/security/limits.conf
  echo "root soft nofile 1048576" >> /etc/security/limits.conf
fi

localdatadir="/data/bee"

if [ ! -d ${localdatadir} ] ; then
  sudo mkdir -p ${localdatadir}
fi

cd localdatadir

wget -q https://raw.githubusercontent.com/ethersphere/bee/v0.6.2/packaging/docker/docker-compose.yml

wget -q https://raw.githubusercontent.com/ethersphere/bee/v0.6.2/packaging/docker/env -O .env

修改.env
BEE_FULL_NODE=true
BEE_PASSWORD=Fspoos.-om_s23s
BEE_SWAP_ENDPOINT=wss://goerli.infura.io/ws/v3/82b5e643d655*****

参考模板 env

修改docker-compose.yml
主要修改成两个节点的配制文件
把services里头的clef-1、bee-2、volumes、command、depends_on拷一份到"- clef-1"这一行的下面。
修改完大概变这样

version: "3"
services:
  clef-1:
    image: ethersphere/clef:0.4.12
    restart: unless-stopped
    environment:
      - CLEF_CHAINID
    volumes:
      - clef-1:/app/data/clef-1
    command: full

  bee-1:
    image: ethersphere/bee:beta
    restart: unless-stopped
    environment:
      - BEE_API_ADDR
      - BEE_BOOTNODE
      - BEE_BOOTNODE_MODE
      - BEE_CLEF_SIGNER_ENABLE
      - BEE_CLEF_SIGNER_ENDPOINT=http://clef-1:8550
      - *******

    ports:
      - "${API_ADDR:-63301}${BEE_API_ADDR:-:63301}"
      - "${P2P_ADDR:-63401}${BEE_P2P_ADDR:-:63401}"
      - "${DEBUG_API_ADDR:-127.0.0.1:63501}${BEE_DEBUG_API_ADDR:-:63501}"

    volumes:
      - bee-1:/home/bee2/.bee
    command: start
    depends_on:
      - clef-1

clef-2:
    image: ethersphere/clef:0.4.12
    restart: unless-stopped
    environment:
      - CLEF_CHAINID
    volumes:
      - clef-2:/app/data/clef-2
    command: full

  bee-2:
    image: ethersphere/bee:beta
    restart: unless-stopped
    environment:
      - BEE_API_ADDR
      - *BEE_BOOTNODE
      - BEE_BOOTNODE_MODE
      - BEE_CLEF_SIGNER_ENABLE
      - BEE_CLEF_SIGNER_ENDPOINT=http://clef-2:8550
      - *********

    ports:

      - "${API_ADDR:-63302}${BEE_API_ADDR:-:63302}"
      - "${P2P_ADDR:-63402}${BEE_P2P_ADDR:-:63402}"
      - "${DEBUG_API_ADDR:-127.0.0.1:63502}${BEE_DEBUG_API_ADDR:-:63502}"

    volumes:
      - bee-2:/home/bee2/.bee

    command: start
    depends_on:
     - clef-2

volumes:
  clef-1:
  bee-1:
  clef-2:
  bee-2:

参考模板docker-compose.yml

启动docker-compose

docker-compose up -d

完成后查看容器状态

docker ps -a

接水

docker-compose logs -f bee-1
docker-compose logs -f bee-2

得到节点的钱包地址,去官方频道接水。所用自己的钱包给节点地址打入1个gETH、1个gBZZ。
如果需要再多开些节点,道理是一样的只需要再加clef-3、bee-3就可以了。

需要写脚本监控各节点的状态,并汇总到监控主机上。


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容