赞
踩
为保证区块链安全性,FISCO BCOS引入了游离节点、观察者节点和共识节点,这三种节点类型可通过控制台相互转换。
将指定节点分别转换成共识节点、观察者节点、游离节点,相关操作命令如下:
节点准入操作前,请确保:
- 操作节点Node ID存在,节点Node ID可在节点目录下执行 cat conf/node.nodeid获取
- 节点加入的区块链所有节点共识正常:正常共识的节点会输出+++日志
# 设节点位于~/fisco/nodes/127.0.0.1/node0目录下
cd ~/fisco
# 获取节点Node ID(设节点目录为~/nodes/127.0.0.1/node0/)
cat ~/fisco/nodes/127.0.0.1/node0/conf/node.nodeid
bf4ff9364d481f658931a2d68a939e1f82c071491fb187801ab10b72b1ceea1ac79e260eaf6fba6fe26ce12b5dfa98d8febc7f3f37f69e74efa55465fa670117
# 连接控制台(设控制台位于~/fisco/console目录)
cd ~/fisco/console
bash start.sh
# 将指定节点转换为共识节点
[group:1]> addSealer bf4ff9364d481f658931a2d68a939e1f82c071491fb187801ab10b72b1ceea1ac79e260eaf6fba6fe26ce12b5dfa98d8febc7f3f37f69e74efa55465fa670117
# 查询共识节点列表
[group:1]> getSealerList
[
bf4ff9364d481f658931a2d68a939e1f82c071491fb187801ab10b72b1ceea1ac79e260eaf6fba6fe26ce12b5dfa98d8febc7f3f37f69e74efa55465fa670117
]
# 将指定节点转换为观察者节点
[group:1]> addObserver bf4ff9364d481f658931a2d68a939e1f82c071491fb187801ab10b72b1ceea1ac79e260eaf6fba6fe26ce12b5dfa98d8febc7f3f37f69e74efa55465fa670117
# 查询观察者节点列表
[group:1]> getObserverList
[
bf4ff9364d481f658931a2d68a939e1f82c071491fb187801ab10b72b1ceea1ac79e260eaf6fba6fe26ce12b5dfa98d8febc7f3f37f69e74efa55465fa6701170
]
# 将指定节点转换为游离节点
[group:1]> removeNode bf4ff9364d481f658931a2d68a939e1f82c071491fb187801ab10b72b1ceea1ac79e260eaf6fba6fe26ce12b5dfa98d8febc7f3f37f69e74efa55465fa670117
# 查询节点列表
[group:1]> getNodeIDList
[
bf4ff9364d481f658931a2d68a939e1f82c071491fb187801ab10b72b1ceea1ac79e260eaf6fba6fe26ce12b5dfa98d8febc7f3f37f69e74efa55465fa670117
]
# 查询共识节点列表
[group:1]> getSealerList
[]
# 查询观察者节点列表
[group:1]> getObserverList
[]
cd ~/fisco/ && curl -#LO https://raw.githubusercontent.com/FISCO-BCOS/FISCO-BCOS/master-2.0/tools/gen_node_cert.sh && chmod u+x gen_node_cert.sh
如果因为网络问题导致长时间无法下载,请尝试
cd ~/fisco/ && curl -#LO https://gitee.com/FISCO-BCOS/FISCO-BCOS/raw/master-2.0/tools/gen_node_cert.sh && chmod u+x gen_node_cert.sh
# -c指定机构证书及私钥所在路径
# -o输出到指定文件夹,其中node4/conf中会存在机构agency新签发的证书和私钥
# 成功会输出 All completed 提示
bash gen_node_cert.sh -c nodes/cert/agency/ -o nodes/127.0.0.1/node4
nodes/127.0.0.1/
,拷贝node0/config.ini
、node0/start.sh
和node0/stop.sh
到node4目录;cd nodes/127.0.0.1/
cp node0/config.ini node0/start.sh node0/stop.sh node4/
node4/config.ini
。对于[rpc]
模块,修改listen_ip
、channel_listen_port
和jsonrpc_listen_port
;对于[p2p]
模块,修改listen_port
并在node.
中增加自身节点信息;vim node4/config.ini
[rpc]
channel_listen_ip=0.0.0.0
channel_listen_port=20204
jsonrpc_listen_ip=127.0.0.1
jsonrpc_listen_port=8549
disable_dynamic_group=false
[p2p]
listen_ip=0.0.0.0
listen_port=30304
; nodes to connect
node.0=127.0.0.1:30300
node.1=127.0.0.1:30301
node.2=127.0.0.1:30302
node.3=127.0.0.1:30303
node.4=127.0.0.1:30304
node0/conf/group.1.genesis
(内含群组节点初始化列表)和node0/conf/group.1.ini
到node4/conf
目录下,不需改动;cd ~/fisco/nodes/127.0.0.1/
cp node0/conf/group.1.genesis node4/conf/
cp node0/conf/group.1.ini node4/conf/
node4/start.sh
启动节点;bash node4/start.sh
node4
与其他节点连接已经建立,加入网络操作完成tail -f node4/log/log* | grep connected
# 以下日志表明节点node4与其他4个节点建立了连接
info|2023-04-25 15:42:16.391604|[P2P][Service] heartBeat,connected count=4
info|2023-04-25 15:42:26.400361|[P2P][Service] heartBeat,connected count=4
info|2023-04-25 15:42:36.400797|[P2P][Service] heartBeat,connected count=4
info|2023-04-25 15:42:46.401075|[P2P][Service] heartBeat,connected count=4
cat node4/conf/node.nodeid
得到类似下面的字符串就是nodeid,nodeid是节点公钥的16进制表示
9a288280fac1f32e0db65ed9028aa418f74389d3f7a334a229d1f80c2171acc608ef02c98bd0f4f2ef1d9824dc7054a4df49c7e9b47e9f05ba5ac4a923d0ee1d
回到cd ~/fisco/console
路径,bash start.sh
进入控制台
# 查询观察者节点列表
[group:1]> getObserverList
[]
# 将指定节点转换为观察者节点
[group:1]> addObserver 9a288280fac1f32e0db65ed9028aa418f74389d3f7a334a229d1f80c2171acc608ef02c98bd0f4f2ef1d9824dc7054a4df49c7e9b47e9f05ba5ac4a923d0ee1d
{
"code":1,
"msg":"Success"
}
# 查询观察者节点列表
[group:1]> getObserverList
[
9a288280fac1f32e0db65ed9028aa418f74389d3f7a334a229d1f80c2171acc608ef02c98bd0f4f2ef1d9824dc7054a4df49c7e9b47e9f05ba5ac4a923d0ee1d
]
# 查询共识节点列表
[group:1]> getSealerList
[
0dee66b823f6f3a533bbc62d799ec53a2e5a5ce366a59888fdf89afe00e32ad4d9baf8c7f18f6d76511510a3de7c92f5e59cf06a89540b6b668bcb13b87cc760,
48a25b2f208e91ac91aa497156ee74d5a8eaa662f24df32562ba942e65ca9ef3134bd39c06d0551845bffc22fbbebb4aae03d35ff92b54b4d53d02e20af35d24,
8fbf1678634d1c7fcb6e50dfa6d23c99fe3ed3fbd9594cde97b25c9fc93b0630c48bed8cd7e8d170859c22021514107f6ded2267c2a5cb0483d382309185ac1e,
bf4ff9364d481f658931a2d68a939e1f82c071491fb187801ab10b72b1ceea1ac79e260eaf6fba6fe26ce12b5dfa98d8febc7f3f37f69e74efa55465fa670117
]
# 将指定节点转换为共识节点
[group:1]> addSealer 9a288280fac1f32e0db65ed9028aa418f74389d3f7a334a229d1f80c2171acc608ef02c98bd0f4f2ef1d9824dc7054a4df49c7e9b47e9f05ba5ac4a923d0ee1d
{
"code":1,
"msg":"Success"
}
# 查询共识节点列表
[group:1]> getSealerList
[
0dee66b823f6f3a533bbc62d799ec53a2e5a5ce366a59888fdf89afe00e32ad4d9baf8c7f18f6d76511510a3de7c92f5e59cf06a89540b6b668bcb13b87cc760,
48a25b2f208e91ac91aa497156ee74d5a8eaa662f24df32562ba942e65ca9ef3134bd39c06d0551845bffc22fbbebb4aae03d35ff92b54b4d53d02e20af35d24,
8fbf1678634d1c7fcb6e50dfa6d23c99fe3ed3fbd9594cde97b25c9fc93b0630c48bed8cd7e8d170859c22021514107f6ded2267c2a5cb0483d382309185ac1e,
bf4ff9364d481f658931a2d68a939e1f82c071491fb187801ab10b72b1ceea1ac79e260eaf6fba6fe26ce12b5dfa98d8febc7f3f37f69e74efa55465fa670117,
9a288280fac1f32e0db65ed9028aa418f74389d3f7a334a229d1f80c2171acc608ef02c98bd0f4f2ef1d9824dc7054a4df49c7e9b47e9f05ba5ac4a923d0ee1d
]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。