Expand the Max version of the blockchain node(No tars console)¶
1. Script function introduction¶
The ‘build _ chain.sh’ script is used to quickly generate a configuration file for a node in a chain. The following describes the functions of the pro / max script options for scaling out the pro / max script without tars:
‘C ‘Options [Optional]
Script command, which supports’ deploy ‘. The default value is’ deploy’:
deploy: for deploying pro chains。
expand_node: Used to expand the node
expand_group: Used to expand the group
expand_service: For scaling RPC / Gateway services
‘V ‘Options [Optional]
Specifies the chain version (air, pro, max). The default value is air。
‘c ‘option [Optional]
Specifies the path of the service configuration file. This path must include config.toml. The default value is. / BcosBuilder / max / config.toml。
‘o ‘option [Optional]
Specifies the directory where the generated node artifacts are located. The default directory is’. / expand’。
2. Expand RPC / Gateway service¶
2.1 Setting RPC / Gateway Service Expansion Configuration¶
Use the build _ chain script to deploy a max service. Now you need to scale up the rpc / gateway
Its main modifications are as follows:
1. Specify the ca path in [chain] rpc _ ca _ cert _ path and gateway _ ca _ cert _ path;
2. tars _ pkg _ dir in [tars] specifies the binary location of the service;
3. Set the institution name in [[agency]]
4. Set the deploy _ ip, listen _ port, tars _ listen _ port service ip and corresponding port of [agency.rpc];
5. Set the deploy _ ip, listen _ port, tars _ listen _ port service ip and corresponding port of [agency.gateway], and modify the peers (you need to write the IP: port of the deployed gateway, and other deployed gateways do not need to modify the corresponding nodes.json;
Note that the difference between tars _ listen _ port and the last deployed port must be greater than 6. For example, if the tars _ listen _ port of the last deployed node is 40402, the minimum value of tars _ listen _ port in this instance is 40408, and the minimum value of tars _ listen _ port in gateway is 40409
The configuration of the new RPC / Gateway service ‘config.toml’ is as follows:
[tars]
tars_pkg_dir = "/data/task/BcosBuilder/max/binary"
[chain]
chain_id="chain0"
# the rpc-service enable sm-ssl or not, default disable sm-ssl
rpc_sm_ssl=false
# the gateway-service enable sm-ssl or not, default disable sm-ssm
gateway_sm_ssl=false
# the existed rpc service ca path, will generate new ca if not configured
rpc_ca_cert_path="/data/task/generate/rpc/chain0/ca"
# the existed gateway service ca path, will generate new ca if not configured
gateway_ca_cert_path="/data/task/generate/gateway/chain0/ca"
[[group]]
group_id="group0"
# the genesis configuration path of the group, will generate new genesis configuration if not configured
#genesis_config_path = ""
# VM type, now only support evm/wasm
vm_type="evm"
# use sm-crypto or not
sm_crypto=false
# enable auth-check or not
auth_check=false
init_auth_address="0x182ee9ac08a729b098e5b8e45b6b328c16a4f0a7"
# the genesis config
# the number of blocks generated by each leader
leader_period = 1
# the max number of transactions of a block
block_tx_count_limit = 1000
# consensus algorithm now support PBFT(consensus_type=pbft)
consensus_type = "pbft"
# transaction gas limit
gas_limit = "3000000000"
# compatible version, can be dynamically upgraded through setSystemConfig
compatibility_version="3.4.0"
[[agency]]
name = "agencyB"
failover_cluster_url = "172.30.93.111:2379"
# enable data disk encryption for rpc/gateway or not, default is false
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 =
# cipher_data_key =
[agency.rpc]
deploy_ip=["172.30.93.111"]
# rpc listen ip
listen_ip="0.0.0.0"
# rpc listen port
listen_port=20210
thread_count=4
# rpc tars server listen ip
tars_listen_ip="0.0.0.0"
# rpc tars server listen port
tars_listen_port=43408
[agency.gateway]
deploy_ip=["172.30.93.111"]
# gateway listen ip
listen_ip="0.0.0.0"
# gateway listen port
listen_port=30310
# gateway connected peers, should be all of the gateway peers info
peers=["172.31.184.227:33300","172.30.93.111:30310"]
tars_listen_port=43409
2.2 Generate RPC / Gateway¶
# Scale out and deploy RPC services
bash build_chain.sh -C expand_service -V max -o expand_service -c ./config.toml
The RPC / Gateway service-related configuration generated during the expansion process is located at expand _ service / ${deploy_ip}’Directory, as follows:
$ tree expand_service/172.30.93.111
expand_service/172.30.93.111
├── gateway_30310
│ ├── BcosGatewayService
│ ├── conf
│ │ ├── ca.crt
│ │ ├── cert.cnf
│ │ ├── config.ini
│ │ ├── nodes.json
│ │ ├── ssl.crt
│ │ ├── ssl.key
│ │ ├── ssl.nodeid
│ │ ├── tars.conf
│ │ └── tars_proxy.ini
│ ├── start.sh
│ └── stop.sh
├── rpc_20210
│ ├── BcosRpcService
│ ├── conf
│ │ ├── ca.crt
│ │ ├── cert.cnf
│ │ ├── config.ini
│ │ ├── sdk
│ │ │ ├── ca.crt
│ │ │ ├── cert.cnf
│ │ │ ├── sdk.crt
│ │ │ ├── sdk.key
│ │ │ └── sdk.nodeid
│ │ ├── ssl.crt
│ │ ├── ssl.key
│ │ ├── ssl.nodeid
│ │ ├── tars.conf
│ │ └── tars_proxy.ini
│ ├── start.sh
│ └── stop.sh
├── start_all.sh
└── stop_all.sh
2.3 Deploy TiKV¶
Deploy tikv on the machine in the expansion service. For convenience of demonstration, use TiUP playground to start the TiKV node. The playground is only used for the test environment. For the production environment, please refer to the official TiKV document to deploy the cluster;
Download and install tiup
$ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
Start tikv v6.5.0
# Deploy and start tikv(Here, the physical ip of the machine is 172.30.93.111)
$ nohup tiup playground v6.5.0 --mode tikv-slim --host=172.30.93.111 -T tikv_demo --without-monitor > ~/tikv.log 2>&1 &
# Obtain the tikv listening port(The default listening port of tikv is 2379)
$ cat ~/tikv.log
tiup is checking updates for component playground ...timeout!
Starting component `playground`: /home/fisco/.tiup/components/playground/v1.9.4/tiup-playground v6.5.0 --mode tikv-slim --host=172.30.93.111 -T tikv_demo --without-monitor
Playground Bootstrapping...
Start pd instance:v6.5.0
Start tikv instance:v6.5.0
PD client endpoints: [172.30.93.111:2379]
2.4 Obtain the newly expanded service information through the console¶
Place the generated product on the corresponding ip machine and start the service, start the console, and enter the ‘getPeers’ command. The number of Gateway service nodes displayed on the console is increased from 1 to 2。
[group0]: /apps> getPeers
PeersInfo{
p2pNodeID='3082010a0282010100bb4983a6136c0b1823a00a93d401899ed736c2e149ebd456052d3a2d256eae26b5bd5af6764e045f9066590f333e0f970d32de2a1f4ec134eb2429eec8f37e55584c8f69fafc3b1dc6c53576afe3575dba0cce3426fd359cbf2cae41ca127e1af607b361bf338323f2c25ec21216f7ac01e4e200ea9628905a76ce72abf0dfcdc44fb8a53710d8990823dbd88e587b2422df5be10778f5f8af88d3f824e50410767e40c4cf17f64c25fe7ef300472e305f8fd7464553739044f57350cd4eda608b8f815025c2d502ab48fd3e0f68b4ae7240ef20a14edc3e4267584c910abb7925168994818a0f1e56b7bff152180c039f45af00945b555c15facb4f8986c9870203010001',
endPoint='0.0.0.0:33300',
groupNodeIDInfo=[
NodeIDInfo{
group='group0',
nodeIDList=[
57b1eceaf9129b062f4845c159eff7440b01cc40c3787019bebc30d66e47aa22e73ea31028e23d325ed559258ab10021cd0b586b5e757d99f76914b2680a9d79
]
}
],
peers=[
PeerInfo{
p2pNodeID='3082010a0282010100cadd66bad17ea1764a9a08dca2659d375cd36fbc5f577d3ad1817169fa3460188713c28e8b556d25adcdc20a98f36e484e5215146b295777c65798230aced92df76609665461ab7f2b7174a757dae76e1080aa742f4395ddc45a7b3642977f6794965433bb9d04d870eca8d3f47e11f5c605a8bcfef0ac3ac864c54945e415232a147850a3ed3a240450248fcfe4ea9d0f38908039b974d53c8e40c57ccd1bb5e5f09af0c5d51cba6370c37bb8954c61a3e35eda92759553db8589cf39dd7ddff6a605b5b61034dc21cae771685c0b12cbb908f56fcba0a917a07ec5df410643d27721ac2dbe84c44e67b97fc57bc69db9778ab2f6bc9596a1e3cccdbf30a9990203010001',
endPoint='172.30.93.111:49646',
groupNodeIDInfo=[
]
}
]
}
3. Expand node service¶
3.1 Setting Block Chain Node Expansion Configuration¶
Specific steps are as follows:
1. Copy the config.toml during deployment, keep only the agency configuration of the node you want to expand, and delete the configuration files of other agencies;
2. tars _ pkg _ dir in [tars] specifies the binary location of the service;
3. [group] genesis _ config _ path, which specifies the path of the genesis block configuration file of the existing node;
4. [agency.group] option in [[agency]], modify node _ name, tars _ listen _ port;
Note that the tars _ listen _ port in [[agency.group.node]] requires 6 ports. Therefore, the difference between the tars _ listen _ port port and the last deployed port must be greater than 6. For example, if the tars _ listen _ port of the last deployed node is 40402, the minimum value of the tars _ listen _ port is 40408。
Configure ‘config.toml’ for scaling (for example, for scaling nodes of the rpc / gateway service that has been scaled out) as follows:
[tars]
tars_pkg_dir = "/data/task/BcosBuilder/max/binary"
[chain]
chain_id="chain0"
# the rpc-service enable sm-ssl or not, default disable sm-ssl
rpc_sm_ssl=false
# the gateway-service enable sm-ssl or not, default disable sm-ssm
gateway_sm_ssl=false
# the existed rpc service ca path, will generate new ca if not configured
rpc_ca_cert_path="/data/task/generate/rpc/chain0/ca"
# the existed gateway service ca path, will generate new ca if not configured
gateway_ca_cert_path="/data/task/generate/gateway/chain0/ca"
[[group]]
group_id="group0"
# the genesis configuration path of the group, will generate new genesis configuration if not configured
genesis_config_path = "/data/task/generate/172.31.184.227/group0_max_node_40402/conf/config.genesis"
# VM type, now only support evm/wasm
vm_type="evm"
# use sm-crypto or not
sm_crypto=false
# enable auth-check or not
auth_check=false
init_auth_address="0x182ee9ac08a729b098e5b8e45b6b328c16a4f0a7"
# the genesis config
# the number of blocks generated by each leader
leader_period = 1
# the max number of transactions of a block
block_tx_count_limit = 1000
# consensus algorithm now support PBFT(consensus_type=pbft)
consensus_type = "pbft"
# transaction gas limit
gas_limit = "3000000000"
# compatible version, can be dynamically upgraded through setSystemConfig
compatibility_version="3.4.0"
[[agency]]
name = "agencyB"
failover_cluster_url = "172.30.93.111:2379"
# enable data disk encryption for rpc/gateway or not, default is false
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 =
# cipher_data_key =
[agency.rpc]
deploy_ip=["172.30.93.111"]
# rpc listen ip
listen_ip="0.0.0.0"
# rpc listen port
listen_port=20210
thread_count=4
# rpc tars server listen ip
tars_listen_ip="0.0.0.0"
# rpc tars server listen port
tars_listen_port=40408
[agency.gateway]
deploy_ip=["172.30.93.111"]
# gateway listen ip
listen_ip="0.0.0.0"
# gateway listen port
listen_port=30310
# gateway connected peers, should be all of the gateway peers info
peers=["172.31.184.227:33300","172.30.93.111:30310"]
tars_listen_port=40409
[[agency.group]]
group_id = "group0"
[[agency.group.node]]
node_name = "node0"
# the tikv storage pd-addresses
pd_addrs = "172.30.93.111:2379"
key_page_size=10240
deploy_ip = ["172.30.93.111"]
executor_deploy_ip=["172.30.93.111"]
monitor_listen_port = "3901"
# the tikv storage pd-addresses
# monitor log path example:"/home/fisco/tars/framework/app_log/"
monitor_log_path = ""
# node tars server listen ip
tars_listen_ip="0.0.0.0"
# node tars server listen port
tars_listen_port=40410
3.2 Deploy build nodes¶
# Expand node service
bash build_chain.sh -C expand_node -V max -o expand_node -c ./config.toml
After executing the above command, the products generated during the expansion process are as follows
$ tree expand_node/172.30.93.111/
expand_node/172.30.93.111/
├── group0_executor_43410
│ ├── BcosExecutorService
│ ├── conf
│ │ ├── config.genesis
│ │ ├── config.ini
│ │ ├── tars.conf
│ │ └── tars_proxy.ini
│ ├── start.sh
│ └── stop.sh
├── group0_max_node_43410
│ ├── BcosMaxNodeService
│ ├── conf
│ │ ├── config.genesis
│ │ ├── config.ini
│ │ ├── node.nodeid
│ │ ├── node.pem
│ │ ├── tars.conf
│ │ └── tars_proxy.ini
│ ├── start.sh
│ └── stop.sh
├── start_all.sh
└── stop_all.sh
3.3 Add the new expansion node to the group¶
Place the generated product on the corresponding ip machine. Before starting the node, you need to turn on tikv as in 2.3;
Note
When you scale out a new node, first add the node as an observation node, and only when the block height of the scale-out node is the same as the highest block height of the existing node on the chain, can it be added as a consensus node。
Step 1: Obtain the NodeID of the scaling node
After the new node is successfully scaled out, you can view the list of new nodes through the ‘getGroupPeers’ command in the console:
[group0]: /apps> getGroupPeers
peer0: 2300e14703675333d947154d8f01bb9d9f814c23a89980872404f368b301d45be2d3acebe306fa6d5a2859fd67f6ba2515eba0b263c940a5f67977ca440f806d
f760b1ef241faa35f2cc68cdb370bfc6b27f9b94b4c79a3d24d4fee41021d87d858a486b611c8ec8213c666faf9e6eec41115cb289bb0249d233e8866f22a94a
[group0]: /apps> getSealerList
[
Sealer{
nodeID='57b1eceaf9129b062f4845c159eff7440b01cc40c3787019bebc30d66e47aa22e73ea31028e23d325ed559258ab10021cd0b586b5e757d99f76914b2680a9d79',
weight=1
}
]
As can be seen from the console output, the addID is 16357cee953a4838d74f3d401c7bf9b5db0120fd8f45e1748ca63d4f420b3d168f66c7a118dcfd16b3ab438c7ca7d4218828709c9c99fe7f867d09c
Step 2: Add an expansion node as an observation node
[group0]: /apps> addObserver 16357cee953a4838d74f3d401c7bf9b5db0120fd8f45e1748ca63d4f420b3d168f66c7a118dcfd16b3ab438c7ca7d4218828709c9c99fe7f867d09c30663c8f8
{
"code":0,
"msg":"Success"
}
Step 3: After the scaling node is synchronized to the highest block, add the scaling node as a consensus node
[group0]: /apps> addSealer 16357cee953a4838d74f3d401c7bf9b5db0120fd8f45e1748ca63d4f420b3d168f66c7a118dcfd16b3ab438c7ca7d4218828709c9c99fe7f867d09c30663c8f8 1
{
"code":0,
"msg":"Success"
}
[group0]: /apps> getSealerList
[
Sealer{
nodeID='57b1eceaf9129b062f4845c159eff7440b01cc40c3787019bebc30d66e47aa22e73ea31028e23d325ed559258ab10021cd0b586b5e757d99f76914b2680a9d79',
weight=1
},
Sealer{
nodeID='16357cee953a4838d74f3d401c7bf9b5db0120fd8f45e1748ca63d4f420b3d168f66c7a118dcfd16b3ab438c7ca7d4218828709c9c99fe7f867d09c30663c8f8',
weight=1
}
]