Fisco Bcos3.0物理机框架搭建区块链网络

Fisco Bcos3.0物理机框架搭建区块链网络

兰涛 lands

在进行下述操作之前请先完成第一章的 centos 环境安装

1.下载区块链构建工具 BcosBuilder 及相关资源

部署工具 BcosBuilder 目标是让用户最快的部署和使用 FISCO BCOS Pro/max 版本区块链,其功能包括:部署/启动/关闭/更新/扩容 RPC 服务、Gateway 服务以及区块链节点服务。

1.1.下载 BcosBuilder

1
2
3
4
5
6
7
8
9
 # 创建操作目录
mkdir -p ~/fisco && cd ~/fisco
Note : 若网速太慢,可尝试如下命令下载部署脚本 :
curl -#LO https://osp-1257653870.cos.ap-guangzhou.myqcloud.com/FISCO-BCOS/FISCO-BCOS/releases/v3.5.0/BcosBuilder.tgz
# 解压
tar -xvf BcosBuilder.tgz

# 安装构建工具依赖包
cd BcosBuilder && pip3 install -r requirements.txt

1.3.下载二进制文件

1
2
3
4
 # 进入操作目录
cd ~/fisco/BcosBuilder/pro
运行build_chain.py脚本下载二进制,二进制包默认下载到binary目录
python3 build_chain.py download_binary -t cdn

2.启动 tars-node

1
cd /root/fisco/BcosBuilder/docker/host/linux/node

打开配置文件 docker-compose.yml,修改 配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
version: "3"
services:
tars-node:
image: tarscloud/tars-node:latest
network_mode: "host"
environment:
# 指定为自己的网卡
INET: enp2s0
WEB_HOST: "10.10.141.57:3000"
restart: always
volumes:
- ~/app/tars:/data/tars
- /etc/localtime:/etc/localtime

注意:WEB_HOST 需要改成 10.10.141.57(tars 主服务 Ip) INET 需要改成网卡名称 tars 主服务网卡名)

在 tars 启动完成后,进入运维->节点 检查检查节点联通性

1
2
cd docker/host/linux/node
docker-compose up -d

3.扩展 node 节点

3.1.修改配置文件 config.toml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
[tars]
tars_url = "http://10.10.141.57:3000/"
tars_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJhZG1pbiIsImlhdCI6MTcwMDYzNDc4MiwiZXhwIjoxNzAwODA3NTgyfQ.1_S1j_-ajTDSS8F43N4dMqdo1SQ7HHsq463ApJBZEnk"
tars_pkg_dir = "binary/"

[chain]
# 扩容的区块链节点所属的链ID。
chain_id="chain0"
rpc_ca_cert_path="generated/rpc/chain0/ca"
gateway_ca_cert_path="generated/gateway/chain0/ca"
rpc_sm_ssl=true
gateway_sm_ssl=true
[[group]]
group_id="group0"
genesis_config_path = "generated/chain0/group0/config.genesis"
auth_check=true
init_auth_address="0x76b72d379b8f640d061e152784026923e266bcb4"

# 扩容节点是否为国密节点,默认为false。
sm_crypto=true
[[agency]]
name = "companyA"
[[agency.group]]
group_id = "group0"
[[agency.group.node]]
node_name = "node2"
deploy_ip = "10.10.145.76"
enable_storage_security = false
monitor_listen_port = "3901"
monitor_log_path = ""
[[agency]]
name = "companyB"
[agency.rpc]
deploy_ip=["10.10.145.76"]
listen_ip="0.0.0.0"
listen_port=20200
thread_count=4
[agency.gateway]
deploy_ip=["10.10.145.76"]
listen_ip="0.0.0.0"
listen_port=30300
peers=["10.10.141.57:30300","10.10.145.76:30300","10.10.145.76:30301"]
[[agency.group]]
group_id = "group0"
[[agency.group.node]]
node_name = "node1"
deploy_ip = "10.10.145.76"
# 扩容节点是否开启落盘加密
enable_storage_security = false
# 监控服务的监听端口,默认为3902
monitor_listen_port = "3902"
# 需要监控的区块链节点日志所在路径 example:"/home/fisco/tars/framework/app_log/"
monitor_log_path = ""

[[agency]]
name = "companyC"
[agency.rpc]
deploy_ip=["10.10.145.76"]
listen_ip="0.0.0.0"
listen_port=20201
thread_count=4
[agency.gateway]
deploy_ip=["10.10.145.76"]
listen_ip="0.0.0.0"
listen_port=30301
peers=["10.10.141.57:30300","10.10.145.76:30300","10.10.145.76:30301"]
[[agency.group]]
# 扩容节点所在群组ID。
group_id = "group0"

[[agency.group.node]]
# 扩容的区块链节点服务名,不能和已有的区块链节点服务名冲突。
node_name = "node1"
# 扩容的区块链节点服务部署IP。
deploy_ip = "10.10.145.76"
# 扩容节点是否开启落盘加密
enable_storage_security = false
# url of the key center, in format of ip:port, please refer to https://github.com/FISCO-BCOS/key-manager for details
# key_center_url =
# 监控服务的监听端口,默认为3902
monitor_listen_port = "3903"
# 需要监控的区块链节点日志所在路径 example:"/home/fisco/tars/framework/app_log/"
monitor_log_path = ""
[[agency]]
name = "companyD"
[agency.rpc]
deploy_ip=["10.10.145.76"]
listen_ip="0.0.0.0"
listen_port=20202
thread_count=4
[agency.gateway]
deploy_ip=["10.10.145.76"]
listen_ip="0.0.0.0"
listen_port=30302
peers=["10.10.141.57:30300","10.10.145.76:30300","10.10.145.76:30301","10.10.145.76:30302"]
[[agency.group]]
# 扩容节点所在群组ID。
group_id = "group0"

[[agency.group.node]]
# 扩容的区块链节点服务名,不能和已有的区块链节点服务名冲突。
node_name = "node1"
# 扩容的区块链节点服务部署IP。
deploy_ip = "10.10.145.76"
# 扩容节点是否开启落盘加密
enable_storage_security = false
# url of the key center, in format of ip:port, please refer to https://github.com/FISCO-BCOS/key-manager for details
# key_center_url =
# 监控服务的监听端口,默认为3902
monitor_listen_port = "3904"
# 需要监控的区块链节点日志所在路径 example:"/home/fisco/tars/framework/app_log/"
monitor_log_path = ""

3.2.部署节点

1
2
3
4
5
#进入操作目录cd ~/fisco/BcosBuilder/pro
#扩容并部署RPC服务
python3 build_chain.py chain -o expand -t rpc
python3 build_chain.py chain -o expand -t gateway
python3 build_chain.py chain -o expand -t node

服务部署信息
image.png
区块链控制台打印的节点信息

image.png

4.将新扩容节点加入到 群组

扩容新节点时,不建议直接将节点加为共识节点,当扩容节点的块高与链上已有节点最高块高一致时候,才可将其加入为共识节点。所以需要先设置为观察节点,在设置为共识节点

在第一次搭建区块链的时候,我们在 10.10.141.57 上搭建了控制台,我们进入之前的 57 控制台

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# 查询当前组的节点列表
[group0]: /apps> getGroupPeers
peer0: 15275f326eb2948be01d686f165523b6a5099762ae66ec7cf46c746ebe70dbb54df3e745087e5cd1fd0b428044cd80d412a2695ece938aa5acd557cd9157f995
peer1: 384e6817c9a3f2cbfadf88608105ca172bf4d6c11690c04f82d18e2d33068feb2f9bb131083c3d41d3c74fa8b79e88dd27737e32fb9a6cc14b8f036b05f6f9f8
peer2: 68737b2c46602bbe8a6a175f3479b3e0842dec720b606600eee74dcb788ab318a5ebb16b250d032b048ac8685999bb88581dac12d2fcf7af844931db916951e7
peer3: aebdce6d9578022dbc4036ae9a7c8ba04ca54a4ffe5ef921ad6cc2be52565bdca8acb32889b8ef11b1de109e721a263f69fc1f503597f7021b9e28ce0d6e0f1d
peer4: db4681719aa4a7ff93ab44f6dc9e97e18e202f4002896b765076c849b286999fc59e2ac5fbb5f5c8884dd06ad8760a3d23d0bef0f363c3a3987ca114af8903ca

# 观察节点信息
[group0]: /apps> getObserverList
[]

# 共识节点信息
[group0]: /apps> getSealerList
[
Sealer{
nodeID='aebdce6d9578022dbc4036ae9a7c8ba04ca54a4ffe5ef921ad6cc2be52565bdca8acb32889b8ef11b1de109e721a263f69fc1f503597f7021b9e28ce0d6e0f1d',
weight=1
},
Sealer{
nodeID='15275f326eb2948be01d686f165523b6a5099762ae66ec7cf46c746ebe70dbb54df3e745087e5cd1fd0b428044cd80d412a2695ece938aa5acd557cd9157f995',
weight=1
},
Sealer{
nodeID='db4681719aa4a7ff93ab44f6dc9e97e18e202f4002896b765076c849b286999fc59e2ac5fbb5f5c8884dd06ad8760a3d23d0bef0f363c3a3987ca114af8903ca',
weight=1
},
Sealer{
nodeID='384e6817c9a3f2cbfadf88608105ca172bf4d6c11690c04f82d18e2d33068feb2f9bb131083c3d41d3c74fa8b79e88dd27737e32fb9a6cc14b8f036b05f6f9f8',
weight=1
},
Sealer{
nodeID='68737b2c46602bbe8a6a175f3479b3e0842dec720b606600eee74dcb788ab318a5ebb16b250d032b048ac8685999bb88581dac12d2fcf7af844931db916951e7',
weight=1
}
]
# 区块链p2p网络信息
[group0]: /apps> getPeers
PeersInfo{
p2pNodeID='048a8cba0cbadb4586e871a9fc74373dddc2260d0a22ab908e7682c22648a5c69f582251188f9a71d6db1493702927d4b1ee17d196b122488e916ae3f8d1f9b17d',
endPoint='0.0.0.0:30301',
groupNodeIDInfo=[
NodeIDInfo{
group='group0',
nodeIDList=[
384e6817c9a3f2cbfadf88608105ca172bf4d6c11690c04f82d18e2d33068feb2f9bb131083c3d41d3c74fa8b79e88dd27737e32fb9a6cc14b8f036b05f6f9f8
]
}
],
peers=[
PeerInfo{
p2pNodeID='040654ac107bd633bc5d6dde61e56ea8a0740b9614f2c2ecd6d7bfb04f89d1f3e8d2a3e0ab1fb481a33f236f274dde09a706a72f4bd37d1550f73ee9df56379701',
endPoint='10.10.145.76:43310',
groupNodeIDInfo=[
NodeIDInfo{
group='group0',
nodeIDList=[
68737b2c46602bbe8a6a175f3479b3e0842dec720b606600eee74dcb788ab318a5ebb16b250d032b048ac8685999bb88581dac12d2fcf7af844931db916951e7
]
}
]
},
PeerInfo{
p2pNodeID='04ef0a664a5ac4eb44a40989f604a3b600c85f8b0bf48994791454fc1d7d13daabe710ff9ed4ad36c31d88b1154a09f3cb74b4680240e34a623609852af0fde9c9',
endPoint='10.10.141.57:30300',
groupNodeIDInfo=[
NodeIDInfo{
group='group0',
nodeIDList=[
aebdce6d9578022dbc4036ae9a7c8ba04ca54a4ffe5ef921ad6cc2be52565bdca8acb32889b8ef11b1de109e721a263f69fc1f503597f7021b9e28ce0d6e0f1d,
db4681719aa4a7ff93ab44f6dc9e97e18e202f4002896b765076c849b286999fc59e2ac5fbb5f5c8884dd06ad8760a3d23d0bef0f363c3a3987ca114af8903ca
]
}
]
},
PeerInfo{
p2pNodeID='041ed0a0a54d403f374dd6369976acec46545a2c0ee21d00539dd89d4c6d3ae205b065fc3322145742b198fb7c8c50d0c453848921a86a647745d7205541176e68',
endPoint='10.10.145.76:30300',
groupNodeIDInfo=[
NodeIDInfo{
group='group0',
nodeIDList=[
15275f326eb2948be01d686f165523b6a5099762ae66ec7cf46c746ebe70dbb54df3e745087e5cd1fd0b428044cd80d412a2695ece938aa5acd557cd9157f995
]
}
]
}
]
}
  • 标题: Fisco Bcos3.0物理机框架搭建区块链网络
  • 作者: 兰涛
  • 创建于 : 2023-11-24 16:36:16
  • 更新于 : 2024-01-26 09:52:58
  • 链接: https://lands.work/3e5f4391/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论