CITA 服务部署系列【八. 分布部署 CITA 服务】

分布部署 CITA 服务

什么是分布部署?

待定…

分布式运行共识节点

本章节采用2台物理主机,每台主机运行2个共识节点,从而模拟4个分布式共识节点的运行;

同步节点配置文件

打包节点配置文件(10.0.7.5)

tar zcvf CITA-FANS-CHAIN.tar.gz CITA-FANS-CHAIN

复制压缩包文件到其他主机(10.0.7.5)

scp CITA-FANS-CHAIN.tar.gz yace@10.0.7.6:/tmp

文件解压缩(10.0.7.6)

cd /data/cita_secp256k1_sha3/
mv /tmp/CITA-FANS-CHAIN.tar.gz .
tar zxvf CITA-FANS-CHAIN.tar.gz
rm -rf CITA-FANS-CHAIN.tar.gz

初始化节点配置文件

主机(10.0.7.5)

./env.sh ./bin/cita setup CITA-FANS-CHAIN/0
./env.sh ./bin/cita setup CITA-FANS-CHAIN/1

主机(10.0.7.6)

./env.sh ./bin/cita setup CITA-FANS-CHAIN/2
./env.sh ./bin/cita setup CITA-FANS-CHAIN/3

启动节点

主机(10.0.7.5)

./daemon.sh ./bin/cita start CITA-FANS-CHAIN/0
./daemon.sh ./bin/cita start CITA-FANS-CHAIN/1

主机(10.0.7.6)

./daemon.sh ./bin/cita start CITA-FANS-CHAIN/2
./daemon.sh ./bin/cita start CITA-FANS-CHAIN/3

节点服务进程检查

主机(10.0.7.5)

netstat -nutlp | grep 'cita-network' | grep 900
netstat -nutlp | grep 'cita-jsonrpc' | grep 33

主机(10.0.7.6)

netstat -nutlp | grep 'cita-network' | grep 900
netstat -nutlp | grep 'cita-jsonrpc' | grep 33

CITA 服务运行检验

基础信息检验

切换指定节点(cita-cli交互界面)

cita>switch --url http://10.0.7.5:3337

查看 CITA 服务的详细信息

cita>rpc getMetaData
{
 "id": 1,
 "jsonrpc": "2.0",
 "result": {
 "blockInterval": 10000,
 "chainId": 0,
 "chainIdV1": "1",
 "chainName": "CITA-FANS-CHAIN",
 "economicalModel": 1,
 "genesisTimestamp": 1544772132700,
 "operator": "CITA-FANS",
 "tokenAvatar": "https://avatars1.githubusercontent.com/u/35361817",
 "tokenName": "CFANS",
 "tokenSymbol": "NATT",
 "validators": [
 "0x0981a91732bf47a823354694715eca3eba73219a",
 "0x401a11bdbc9765c73a4ccdbb4c047db99a19e61d",
 "0x819eb5a703b8e2e6e7c2f43d62010cbf222d3559",
 "0x9c56e0d717a2948df861dfb978ac5be32a15c689"
 ],
 "version": 1,
 "website": "CITAFANS.COM"
 }
}

区块产出时间检验

tail -f CITA-FANS-CHAIN/0/logs/cita-chain.log
2018-12-14T17:13:08.341631606+08:00 - INFO - Session initialized
2018-12-14T17:13:08.817518895+08:00 - INFO - Session initialized
2018-12-14T17:13:09.128324700+08:00 - INFO - chain config: Config { prooftype: 2, cache_size: Some(1048576) }
2018-12-14T17:13:09.128379399+08:00 - WARN - not expected get_chain_current_head hash.
2018-12-14T17:13:09.128396199+08:00 - INFO - get chain max_store_height : 0 current_height: 0
2018-12-14T17:13:27.337163429+08:00 - INFO - Chain enters the timeout retransmission phase
2018-12-14T17:13:28.080191750+08:00 - INFO - new chain status height 1, hash 7154f0306c69454e95a9558376884a8f3623839e777efdb34c0541ef219ab3e9
2018-12-14T17:13:39.879780443+08:00 - INFO - new chain status height 2, hash 22cff584f34c3820ab7872f326e7b4f092c1362d435563bfcdbe473a2158a53c
2018-12-14T17:13:42.345942349+08:00 - INFO - new chain status height 3, hash 767492e95b23d8118453cdc903b95e355d8df7a4f91983f2c56c742028a4fdec
2018-12-14T17:13:52.635264717+08:00 - INFO - new chain status height 4, hash 71d785638ac655ea3bd1f6134067b54098dc4bc34d2aff2daac6348bb5b23a10
2018-12-14T17:14:02.661068660+08:00 - INFO - new chain status height 5, hash 1303f39ea50c2998b25814039e965447950a2387bfeef48e1c53c9afcee1625f
2018-12-14T17:14:12.823931519+08:00 - INFO - new chain status height 6, hash 9642552b0d5dfe1ee19bce26d83bd3579f07e85ca650287538096dc9e28bf965
* * *

:grinning: 很感谢您能够看到这里,如果文中的内容有描述不当,请您在本章节下方指出,我会尽快修改;

1赞