赞
踩
one_click_generator.sh
脚本为根据用户填写的节点配置,一键部署联盟链的脚本。脚本会根据用户指定文件夹下配置的node_deployment.ini
,在文件夹下生成相应的节点。
!!!一键部署脚本使用时需要确保当前meta文件夹下不含节点证书信息,请清空meta文件夹。
1.1、下载(第一条如果失败,就使用第二条)
第一条:
- cd ~
- git clone https://github.com/FISCO-BCOS/generator.git
第二条:
- cd ~
- git clone https://gitee.com/FISCO-BCOS/generator.git
1.2、安装
cd ~/generator && bash ./scripts/install.sh
1.3、检查
检查是否安装成功,若成功,输出 usage: generator xxx
cd ~/generator && ./generator -h
1.4、获取节点二进制
拉取最新fisco-bcos二进制文件到meta中,如果网络较差,可以尝试通过其他方式下载fisco-bcos
,或使用--cdn
选项,并将下载好的二进制放置于meta
文件夹下
cd ~/generator && ./generator --download_fisco ./meta
1.5、检查二进制版本
若成功,输出 FISCO-BCOS Version : x.x.x-x
cd ~/generator && ./meta/fisco-bcos -v
cd ~/generator && bash ./one_click_generator.sh -b ./tmp_one_click
执行完毕后,./tmp_one_click文件夹结构如下:
查看执行后的一键部署模板文件夹:
├── agencyA # A机构文件夹 │ ├── agency_cert # A机构证书及私钥 │ ├── generator-agency # 自动代替A机构进行操作的generator文件夹 │ ├── node # A机构生成的节点,多机部署时推送至对应服务器即可 │ ├── node_deployment.ini # A机构的节点配置信息 │ └── sdk # A机构的sdk或控制台配置文件 ├── agencyB | ├── agency_cert | ├── generator-agency | ├── node | ├── node_deployment.ini | └── sdk |── ca.crt # 链证书 |── ca.key # 链私钥 |── group.1.genesis # 群组1创世区块 |── peers.txt # 节点的peers.txt信息
- cd ~/generator && bash ./tmp_one_click/agencyA/node/start_all.sh && \
- cd ~/generator && bash ./tmp_one_click/agencyB/node/start_all.sh
3.1、查看节点进程
ps -ef | grep fisco
3.2、查看节点运行状态
tail -f ~/generator/tmp_one_click/agency*/node/node*/log/log* | grep +++
为机构A和机构C增加新节点
4.1、初始化扩容配置
创建扩容文件夹,示例中tmp_one_click_expand可以为任意名称,请每次扩容使用新的文件夹
mkdir ~/generator/tmp_one_click_expand/
4.2、拷贝链证书及私钥至扩容文件夹
cp ~/generator/tmp_one_click/ca.* ~/generator/tmp_one_click_expand/
4.3、拷贝群组1创世区块group.1.genesis
至扩容文件夹
cp ~/generator/tmp_one_click/group.1.genesis ~/generator/tmp_one_click_expand/
4.4、拷贝群组1节点P2P连接文件peers.txt
至扩容文件夹
cp ~/generator/tmp_one_click/peers.txt ~/generator/tmp_one_click_expand/
5.1、创建机构A扩容节点所在目录
mkdir ~/generator/tmp_one_click_expand/agencyA
5.2、拷贝机构A证书、私钥至对应文件夹
cp -r ~/generator/tmp_one_click/agencyA/agency_cert ~/generator/tmp_one_click_expand/agencyA
5.3、机构A填写节点配置信息
- cat > ~/generator/tmp_one_click_expand/agencyA/node_deployment.ini << EOF
- [group]
- group_id=1
-
- [node0]
- ; Host IP for the communication among peers.
- ; Please use your ssh login IP.
- p2p_ip=127.0.0.1
- ; listening IP for the communication between SDK clients.
- ; This IP is the same as p2p_ip for the physical host.
- ; But for virtual host e.g., VPS servers, it is usually different from p2p_ip.
- ; You can check accessible addresses of your network card.
- ; Please see https://tecadmin.net/check-ip-address-ubuntu-18-04-desktop/
- ; for more instructions.
- rpc_ip=127.0.0.1
- channel_ip=0.0.0.0
- p2p_listen_port=30304
- channel_listen_port=20204
- jsonrpc_listen_port=8549
- EOF
6.1、创建机构C扩容节点所在目录
mkdir ~/generator/tmp_one_click_expand/agencyC
6.2、机构C填写节点配置信息
- cat > ~/generator/tmp_one_click_expand/agencyC/node_deployment.ini << EOF
- [group]
- group_id=1
-
- [node0]
- ; Host IP for the communication among peers.
- ; Please use your ssh login IP.
- p2p_ip=127.0.0.1
- ; listening IP for the communication between SDK clients.
- ; This IP is the same as p2p_ip for the physical host.
- ; But for virtual host e.g., VPS servers, it is usually different from p2p_ip.
- ; You can check accessible addresses of your network card.
- ; Please see https://tecadmin.net/check-ip-address-ubuntu-18-04-desktop/
- ; for more instructions.
- rpc_ip=127.0.0.1
- channel_ip=0.0.0.0
- p2p_listen_port=30305
- channel_listen_port=20205
- jsonrpc_listen_port=8550
- EOF
cd ~/generator && bash ./one_click_generator.sh -e ./tmp_one_click_expand
- cd ~/generator && bash ./tmp_one_click_expand/agencyA/node/start_all.sh && \
- bash ./tmp_one_click_expand/agencyC/node/start_all.sh
8.1、查看节点进程
ps -ef | grep fisco
9.1、下载控制台
获取控制台,可能需要较长时间,国内用户可以使用--cdn
命令:
以机构A使用控制台为例,此步需要切换到机构A对应的generator-agency
文件夹
- cd ~/generator/tmp_one_click/agencyA/generator-agency
- ./generator --download_console ./ --cdn
9.2、查看节点nodeid
cat ~/generator/tmp_one_click_expand/agencyA/node/node_127.0.0.1_30304/conf/node.nodeid
9.3、启动控制台
cd ~/generator/tmp_one_click/agencyA/generator-agency/console && bash ./start.sh 1
9.4、注册共识节点
使用控制台addSealer
命令将节点注册为共识节点,此步需要用到cat
命令查看得到机构A节点的node.nodeid
:
查看A nodeid
cat ~/generator/tmp_one_click_expand/agencyA/node/node_127.0.0.1_30304/conf/node.nodeid
注册节点A
addSealer 1790aa786e048e2cbb90e02e799f652bc41d9da70aa3fc3f8b6f8b02b350989f44b7bd6fb43aa66c5bc237be5888440e8dfbbc1e1c8ff0caa04411e10acdbe70
查看C nodeid
cat ~/generator/tmp_one_click_expand/agencyC/node/node_127.0.0.1_30305/conf/node.nodeid
注册节点C
addSealer 129196749f01cafd947b3da224e72a97c3a8812271f6c3c5e054437620313b9979a84e1c357e3916427344bc03e4deffabcbcd9057430efd90313a85c34d8050
10.1、查看机构C nodeid
cat ~/generator/tmp_one_click_expand/agencyC/node/node_127.0.0.1_30305/conf/node.nodeid
10.2、注册观察节点
addObserver 129196749f01cafd947b3da224e72a97c3a8812271f6c3c5e054437620313b9979a84e1c357e3916427344bc03e4deffabcbcd9057430efd90313a85c34d8050
到此完成,新增节点到现有群组的操作。
十一、
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。