Environment
fisco 2.8.0
ubuntu 20
Preface
This experiment will use the build_chain.sh
script to build a blockchain network with six nodes, one organization, and two groups.
Operate based on fisco official documentsBuild a multi-machine blockchain network
Please prepare two Ubuntu machines in advance
In my environment, the IP addresses of the two machines are [make sure the machines can be connected before, useping
Command to test connection】
192.168.19.133
192.168.19.137
Then the node ports of each machine are as follows [Because it is built with multiple machines, the ports belong to their respective machines]
Node name | Node address | p2p_port | channel_port | jsonrpc_port |
---|---|---|---|---|
node0 | 192.168.19.133 | 30300 | 20200 | 8545 |
node1 | 192.168.19.133 | 30301 | 20201 | 8546 |
node2 | 192.168.19.133 | 30302 | 20202 | 8547 |
node3 | 192.168.19.137 | 30300 | 20200 | 8545 |
node4 | 192.168.19.137 | 30301 | 20201 | 8546 |
node5 | 192.168.19.137 | 30302 | 20202 | 8547 |
Configure the node and generate
Compile documents in192.168.19.137
, based on the table aboveipconf
root@192-168-19-137:/yijiu# cat ipconf
192.168.19.133:3 agencyOne 1 30300,20200,8545 #请根据自己的实际机子ip地址进行过填写
192.168.19.137:3 agencyOne 1 30300,20200,8545 # 使用机构1 ,并且都属于群组1
Then use-f
parameters to generate node-related configuration files
bash build_chain.sh -f ipconf -e ./fisco-bcos
root@192-168-19-137:/yijiu# bash build_chain.sh -f ipconf -e ./fisco-bcos
Checking fisco-bcos binary...
Binary check passed.
==============================================================
Generating CA key...
==============================================================
Generating keys and certificates ...
Processing IP=192.168.19.133 Total=3 Agency=agencyOne Groups=1
Processing IP=192.168.19.137 Total=3 Agency=agencyOne Groups=1
==============================================================
Generating configuration files ...
Processing IP=192.168.19.133 Total=3 Agency=agencyOne Groups=1
Processing IP=192.168.19.137 Total=3 Agency=agencyOne Groups=1
==============================================================
Group:1 has 6 nodes
==============================================================
[INFO] FISCO-BCOS Path : ./fisco-bcos
[INFO] IP List File : ipconf
[INFO] Start Port : 30300 20200 8545
[INFO] Server IP : 192.168.19.133:3 192.168.19.137:3
[INFO] Output Dir : /yijiu/nodes
[INFO] CA Path : /yijiu/nodes/cert/
==============================================================
[INFO] Execute the download_console.sh script in directory named by IP to get FISCO-BCOS console.
e.g. bash /yijiu/nodes/192.168.19.133/download_console.sh -f
==============================================================
[INFO] All completed. Files in /yijiu/nodes
At this time, it cannot be started directly because the node files all exist in the machine of 192.168.19.137
, and then the node files of 192.168.19.133
need to be copied to 192.168.19.133
In the machine
root@192-168-19-137:/yijiu# ll nodes/
总用量 20
drwxr-xr-x 5 root root 4096 12月 7 12:54 ./
drwxr-xr-x 3 root root 4096 12月 7 12:54 ../
drwxr-xr-x 6 root root 4096 12月 7 12:54 192.168.19.133/ # 这个
drwxr-xr-x 6 root root 4096 12月 7 12:54 192.168.19.137/
drwxr-xr-x 3 root root 4096 12月 7 12:54 cert/
Copy node configuration
First of all192.168.19.133
create a nodes folder in the machine [you may be asked to enter the password of the 192.168.19.133 ordinary account. You can also perform password-free operations on these two machines. configuration]
# 根据自己的实际情况填写普通账户和ip地址
root@192-168-19-137:/yijiu# ssh [email protected] "mkdir -p /yijiu/nodes"
The authenticity of host '192.168.19.133 (192.168.19.133)' can't be established.
ECDSA key fingerprint is SHA256:8JZFwBijayGtqRHhBxJ6Z257Lbl3+I4kQ28UJTJ12gI.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.19.133' (ECDSA) to the list of known hosts.
[email protected]'s password:
Copy the relevant files to 192.168.19.133
machine
# scp -r 需要拷贝的文件路径 普通账户@目标的ip地址:路径
root@192-168-19-137:/yijiu# scp -r nodes/192.168.19.133 [email protected]:/yijiu/nodes
[email protected]'s password:
fisco-bcos 100% 28MB 152.0MB/s 00:00
download_bin.sh 100% 5476 4.5MB/s 00:00
download_console.sh 100% 2932 5.0MB/s 00:00
reload_whitelist.sh 100% 1745 2.1MB/s 00:00
load_new_groups.sh 100% 1006 391.9KB/s 00:00
monitor.sh 100% 4635 5.3MB/s 00:00
reload_sdk_allowlist.sh 100% 647 154.9KB/s 00:00
config.ini 100% 1762 2.2MB/s 00:00
stop.sh 100% 830 235.0KB/s 00:00
start.sh 100% 1005 264.1KB/s 00:00
node.key 100% 237 367.8KB/s 00:00
node.nodeid 100% 129 259.2KB/s 00:00
group.1.genesis 100% 1537 3.2MB/s 00:00
node.crt 100% 1838 4.4MB/s 00:00
group.1.ini 100% 2745 5.5MB/s 00:00
ca.crt 100% 664 1.3MB/s 00:00
stop_all.sh 100% 506 1.2MB/s 00:00
.transTest.sh 100% 2627 2.4MB/s 00:00
reload_whitelist.sh 100% 1745 4.1MB/s 00:00
load_new_groups.sh 100% 1006 2.8MB/s 00:00
monitor.sh 100% 4635 9.8MB/s 00:00
reload_sdk_allowlist.sh 100% 647 1.8MB/s 00:00
config.ini 100% 1762 4.4MB/s 00:00
stop.sh 100% 830 2.2MB/s 00:00
start.sh 100% 1005 3.0MB/s 00:00
node.key 100% 237 684.6KB/s 00:00
node.nodeid 100% 129 381.9KB/s 00:00
group.1.genesis 100% 1537 3.6MB/s 00:00
node.crt 100% 1838 4.3MB/s 00:00
group.1.ini 100% 2745 7.1MB/s 00:00
ca.crt 100% 664 1.6MB/s 00:00
sdk.key 100% 237 288.1KB/s 00:00
sdk.publickey 100% 129 231.9KB/s 00:00
ca.crt 100% 664 1.6MB/s 00:00
sdk.crt 100% 1830 2.6MB/s 00:00
reload_whitelist.sh 100% 1745 3.3MB/s 00:00
load_new_groups.sh 100% 1006 1.7MB/s 00:00
monitor.sh 100% 4635 5.2MB/s 00:00
reload_sdk_allowlist.sh 100% 647 1.3MB/s 00:00
config.ini 100% 1762 3.5MB/s 00:00
stop.sh 100% 830 2.2MB/s 00:00
start.sh 100% 1005 2.6MB/s 00:00
node.key 100% 237 437.6KB/s 00:00
node.nodeid 100% 129 169.6KB/s 00:00
group.1.genesis 100% 1537 2.8MB/s 00:00
node.crt 100% 1838 4.4MB/s 00:00
group.1.ini 100% 2745 5.9MB/s 00:00
ca.crt 100% 664 1.2MB/s 00:00
start_all.sh
Then check 133
whether the folder of the machine has been copied successfully
root@192-168-19-133:/# ll yijiu/nodes/192.168.19.133/
总用量 28584
drwxr-xr-x 6 yijiu yijiu 4096 12月 7 13:13 ./
drwxrwxr-x 3 yijiu yijiu 4096 12月 7 13:13 ../
-rwxr-xr-x 1 yijiu yijiu 5476 12月 7 13:13 download_bin.sh*
-rwxr-xr-x 1 yijiu yijiu 2932 12月 7 13:13 download_console.sh*
-rwxr-xr-x 1 yijiu yijiu 29213128 12月 7 13:13 fisco-bcos*
drwxr-xr-x 4 yijiu yijiu 4096 12月 7 13:13 node0/
drwxr-xr-x 4 yijiu yijiu 4096 12月 7 13:13 node1/
drwxr-xr-x 4 yijiu yijiu 4096 12月 7 13:13 node2/
drwxr-xr-x 2 yijiu yijiu 4096 12月 7 13:13 sdk/
-rwxr-xr-x 1 yijiu yijiu 520 12月 7 13:13 start_all.sh*
-rwxr-xr-x 1 yijiu yijiu 506 12月 7 13:13 stop_all.sh*
-rwxr-xr-x 1 yijiu yijiu 2627 12月 7 13:13 .transTest.sh*
root@192-168-19-133:/#
Start the dual-machine node
There are two ways to start, one is remote start, and the other is to go to the target machine to start.
- Start
137
Machine child node
root@192-168-19-137:/yijiu# bash nodes/192.168.19.137/start_all.sh
try to start node0
try to start node1
try to start node2
node0 start successfully
node1 start successfully
node2 start successfully
- Start
133
Machine node | I choose to start remotely like the official one
root@192-168-19-137:/yijiu# ssh [email protected] "bash /yijiu/nodes/192.168.19.133/start_all.sh"
[email protected]'s password:
try to start node0
try to start node1
try to start node2
node2 start successfully
node0 start successfully
node1 start successfully
You can check the startup status of the two machines
root@192-168-19-137:/yijiu# ps -ef | grep -v grep | grep fisco
root 6731 1 1 13:17 pts/0 00:00:04 /yijiu/nodes/192.168.19.137/node0/../fisco-bcos -c config.ini
root 6733 1 1 13:17 pts/0 00:00:04 /yijiu/nodes/192.168.19.137/node1/../fisco-bcos -c config.ini
root 6735 1 1 13:17 pts/0 00:00:04 /yijiu/nodes/192.168.19.137/node2/../fisco-bcos -c config.ini
root@192-168-19-133:/# ps -ef | grep -v grep | grep fisco
yijiu 9457 1 1 13:20 ? 00:00:02 /yijiu/nodes/192.168.19.133/node1/../fisco-bcos -c config.ini
yijiu 9459 1 1 13:20 ? 00:00:02 /yijiu/nodes/192.168.19.133/node0/../fisco-bcos -c config.ini
yijiu 9461 1 1 13:20 ? 00:00:02 /yijiu/nodes/192.168.19.133/node2/../fisco-bcos -c config.ini
Check whether the number of connections of a node is in progress
root@192-168-19-133:/# tail -f yijiu/nodes/192.168.19.133/node1/log/log* | grep connected
info|2023-12-9 13:24:18.561051|[P2P][Service] heartBeat,connected count=5
info|2023-12-9 13:24:28.561754|[P2P][Service] heartBeat,connected count=5
Check the consensus status of a node
root@192-168-19-137:/yijiu# tail -f nodes/192.168.19.137/node2/log/log* | grep +++
info|2023-12-09 13:25:16.156900|[g:1][CONSENSUS][SEALER]++++++++++++++++ Generating seal on,blkNum=1,tx=0,nodeIdx=1,hash=b5eafd2c...
info|2023-12-09 13:25:22.190674|[g:1][CONSENSUS][SEALER]++++++++++++++++ Generating seal on,blkNum=1,tx=0,nodeIdx=1,hash=ce20bd30...
Configure a simple console
Prepare an initialized console file
This is the same as a normal stand-alone setup. Copy the certificate of the sdk
folder into the consoleconf
Directory
root@192-168-19-137:/yijiu/console# cp -r ../nodes/192.168.19.137/sdk/* conf/
Copy a config, toml file
root@192-168-19-137:/yijiu/console# cp -r conf/config-example.toml conf/config.toml
Modify the config.toml file
[network]
peers=["192.168.19.137:20200"] # 需要注意这个参数,需要按照实际情况填写,console控制台是基于此参数选择以什么节点进行区块链网络操作
Start the console
root@192-168-19-137:/yijiu/console# bash start.sh
=============================================================================================
Welcome to FISCO BCOS console(2.8.0)!
Type 'help' or 'h' for help. Type 'quit' or 'q' to quit console.
________ ______ ______ ______ ______ _______ ______ ______ ______
| | \/ \ / \ / \ | \ / \ / \ / \
| $$$$$$$$\$$$$$| $$$$$$| $$$$$$| $$$$$$\ | $$$$$$$| $$$$$$| $$$$$$| $$$$$$\
| $$__ | $$ | $$___\$| $$ \$| $$ | $$ | $$__/ $| $$ \$| $$ | $| $$___\$$
| $$ \ | $$ \$$ \| $$ | $$ | $$ | $$ $| $$ | $$ | $$\$$ \
| $$$$$ | $$ _\$$$$$$| $$ __| $$ | $$ | $$$$$$$| $$ __| $$ | $$_\$$$$$$\
| $$ _| $$_| \__| $| $$__/ | $$__/ $$ | $$__/ $| $$__/ | $$__/ $| \__| $$
| $$ | $$ \\$$ $$\$$ $$\$$ $$ | $$ $$\$$ $$\$$ $$\$$ $$
\$$ \$$$$$$ \$$$$$$ \$$$$$$ \$$$$$$ \$$$$$$$ \$$$$$$ \$$$$$$ \$$$$$$
=============================================================================================
[group:1]>
View peers
[group:1]> getPeers
[
PeerInfo{
nodeID='9bb06a10288a809d20b5f52cb19754b330f8b8626e9346ec7bca2595469eb604debf536f5d25963b603f596a9581ba8cb513f431d685f1cd3e0deab7b7c59fa6',
iPAndPort='192.168.19.133:37122',
node='node0',
agency='agencyOne',
topic='[
]'
},
PeerInfo{
nodeID='581a96ff7f6c04957d19b0b4ba14e9fe019ca3bcadb9fdc7f7768fe4831b655345d80c115f5375a033994776a85f379ec73360f221123a9c0c3a43afcb5c680a',
iPAndPort='192.168.19.133:37138',
node='node2',
agency='agencyOne',
topic='[
]'
},
PeerInfo{
nodeID='08c694ec0f8fdce1323a61adf93f6c22670a5994a651e61018c1b4dcf46de09cdeb261f944e90b7a58c01f8dae850b81a0be619298c2ee2d8f4f94b5b3e39b17',
iPAndPort='192.168.19.133:37150',
node='node1',
agency='agencyOne',
topic='[
]'
},
PeerInfo{
nodeID='f61bc799ffa0c8ead5a976fc8d67706079d361d85720b77e6875f9ee5fb97f7e78e2484671e364712a87ec713b9695185533135546941198d5bdbbd3befa3fd6',
iPAndPort='192.168.19.137:30301',
node='node1',
agency='agencyOne',
topic='[
]'
},
PeerInfo{
nodeID='4513c784506e318e93af312f2042cd519ecc523a65cbce2f0274034712eecb16182da3cd38cc226874396ebb8bc7481aa9e3bce2749c4f9f050708c9328416a5',
iPAndPort='192.168.19.137:30302',
node='node2',
agency='agencyOne',
topic='[
]'
}
]
Conclusion
This construction method will be more cumbersome, because if there are more machines and more nodes, repeated copying and login operations will be required. It is recommended to use the official oneEnterprise-level operation and maintenance deployment tool