节点接入安顺官方网络
全节点接入区块链网络需要自行维护一个节点。
全节点可以以共识节点或同步节点两种方式接入,接入正式环境前请联系官方工作人员开放节点接入白名单。
安装环境
Ubuntu 16或18
CentOS 7
部署方式和配置设置
编译节点可执行文件geth,并将编译好的geth文件copy到节点目录,示例中节点目录为
/data/install
cp geth /data/install
2. 新建node文件夹,配置genesis.json, static-nodes.json 和nodekey文件
注意将nodekey中的keystore替换为当前要配置的节点keystore
$ cd /data/install
$ mkdir node && cd node
$ vi genesis.json
{
"config": {
"chainId": 1088,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"hotstuff": {
"protocol": "basic"
}
},
"alloc": {
"0x258af48e28e4a6846e931ddff8e1cdf8579821e5": {"publicKey": "0x02c07fb7d48eac559a2483e249d27841c18c7ce5dbbbf2796a6963cc9cef27cabd", "balance": "100000000000000000000000000000"},
"0x6a708455c8777630aac9d1e7702d13f7a865b27c": {"publicKey": "0x02f5135ae0853af71f017a8ecb68e720b729ab92c7123c686e75b7487d4a57ae07", "balance": "100000000000000000000000000000"},
"0x8c09d936a1b408d6e0afaa537ba4e06c4504a0ae": {"publicKey": "0x03ecac0ebe7224cfd04056c940605a4a9d4cb0367cf5819bf7e5502bf44f68bdd4", "balance": "100000000000000000000000000000"},
"0xad3bf5ed640cc72f37bd21d64a65c3c756e9c88c": {"publicKey": "0x03d0ecfd09db6b1e4f59da7ebde8f6c3ea3ed09f06f5190477ae4ee528ec692fa8", "balance": "100000000000000000000000000000"},
"0xc095448424a5ecd5ca7ccdadfaad127a9d7e88ec": {"publicKey": "0x0244e509103445d5e8fd290608308d16d08c739655d6994254e413bc1a06783856", "balance": "100000000000000000000000000000"},
"0xd47a4e56e9262543db39d9203cf1a2e53735f834": {"publicKey": "0x023884de29148505a8d862992e5721767d4b47ff52ffab4c2d2527182d812a6d95", "balance": "100000000000000000000000000000"},
"0xbfb558f0dceb07fbb09e1c283048b551a4310921": {"publicKey": "0x03b838fa2387beb3a56aed86e447309f8844cb208387c63af64ad740729b5c0a27", "balance": "100000000000000000000000000000"}
},
"coinbase": "0x0000000000000000000000000000000000000000",
"difficulty": "0x1",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f8daf89394258af48e28e4a6846e931ddff8e1cdf8579821e5946a708455c8777630aac9d1e7702d13f7a865b27c948c09d936a1b408d6e0afaa537ba4e06c4504a0ae94ad3bf5ed640cc72f37bd21d64a65c3c756e9c88c94c095448424a5ecd5ca7ccdadfaad127a9d7e88ec94d47a4e56e9262543db39d9203cf1a2e53735f83494bfb558f0dceb07fbb09e1c283048b551a4310921b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c080",
"gasLimit": "0xffffffff",
"nonce": "0x4510809143055965",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00"
}
$ vi static-nodes.json
[
"enode://c07fb7d48eac559a2483e249d27841c18c7ce5dbbbf2796a6963cc9cef27cabd2e1bc9c456a83f0777a98dfd6e7baf272739b9e5f8febf0077dc09509c2dfa48@124.220.23.204:30300?discport=0"
]
$ mkdir geth && cd geth
$ vi nodekey
# 这里在nodekey中配置keystore,例如
{
"address": "1d3a781db87d57a2091f968734186c8c72353116",
"crypto": {
"cipher": "aes-128-ctr",
"ciphertext": "2d5c5cc5ff6c7e2f2e49cb53859df5457fbada13b179f41e160bb6d80897d87f",
"cipherparams": {
"iv": "978375653c56f3255763bd509336782b"
},
"kdf": "scrypt",
"kdfparams": {
"dklen": 32,
"n": 262144,
"p": 1,
"r": 8,
"salt": "de8296b9cdb58b1f220841c1c84bbc2452a87fbce2d4d7c9cfbaf16e5501dee2"
},
"mac": "40cecc8a51db200f9afde4b85d7715951be0295723d148dfaa46ca7da20b0643"
},
"id": "93415801-0d57-4d62-8329-f82ebae37939",
"version": 3
}
$ cd .. && ls
genesis.json geth static-nodes.json
3. 初始化节点
$ cd /data/install
# $pass 为keystore钱包文件的密码
$ export NODE_PASS=$pass
$ ./geth init node/genesis.json --datadir node
INFO [05-18|00:13:45.204] Maximum peer count ETH=50 LES=0 total=50
INFO [05-18|00:13:45.204] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
WARN [05-18|00:13:45.205] Found deprecated node list file /data/install/node/static-nodes.json, please use the TOML config file instead.
INFO [05-18|00:13:45.205] Set global gas cap cap=25,000,000
INFO [05-18|00:13:45.205] Allocated cache and file handles database=/data/install/node/geth/chaindata cache=16.00MiB handles=16
INFO [05-18|00:13:45.226] Writing custom genesis block
INFO [05-18|00:13:45.228] Persisted trie from memory database node(header root)=0x6089d09f30249b1f11359fa6ba0e674569df8c8622c3040ab70a5dd27c09f375 nodes=81 size=10.62KiB time="240.642µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-82.00B
INFO [05-18|00:13:45.229] Successfully wrote genesis state database=chaindata hash=5c3928..dc5818
INFO [05-18|00:13:45.229] Allocated cache and file handles database=/data/install/node/geth/lightchaindata cache=16.00MiB handles=16
INFO [05-18|00:13:45.247] Writing custom genesis block
INFO [05-18|00:13:45.249] Persisted trie from memory database node(header root)=0x6089d09f30249b1f11359fa6ba0e674569df8c8622c3040ab70a5dd27c09f375 nodes=81 size=10.62KiB time="227.687µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-82.00B
INFO [05-18|00:13:45.249] Successfully wrote genesis state database=lightchaindata hash=5c3928..dc5818
4. 配置启动脚本start.sh文件
作为共识节点参与网络所需启动脚本如下:
$ cd /data/install
$ vi start.sh
#!/bin/bash
echo "input node pass"
read -s pass
export NODE_PASS=$pass
port=30300
rpcport=8545
node="node"
miner=0x2D3913c12ACa0E4A2278f829Fb78A682123c0125
echo "$node and miner is $miner, rpc port $rpcport, p2p port $port"
nohup ./geth --mine --miner.threads 1 \
--miner.etherbase=$miner \
--identity=$node \
--maxpeers=100 \
--syncmode full \
--allow-insecure-unlock \
--datadir $node \
--networkid 2088 \
--txlookuplimit 0 \
--txpool.pricelimit 1000000000 \
--http.corsdomain "*" \
--http.api admin,eth,debug,miner,net,txpool,personal,web3 \
--http --http.addr 0.0.0.0 --http.port $rpcport --http.vhosts "*" \
--port $port \
--verbosity 5 \
--nodiscover >> $node/node.log 2>&1 &
sleep 3s;
ps -ef|grep geth|grep mine|grep -v grep;
同步节点参与网络所需配置如下:
$ cd /data/install
$ vi start.sh
#!/bin/bash
echo "input node pass"
read -s pass
export NODE_PASS=$pass
port=30300
rpcport=8545
node="node"
echo " rpc port $rpcport, p2p port $port"
nohup ./geth --identity=$node \
--maxpeers=100 \
--syncmode full \
--allow-insecure-unlock \
--datadir $node \
--networkid 2088 \
--txlookuplimit 0 \
--txpool.pricelimit 1000000000 \
--http.corsdomain "*" \
--http.api admin,eth,debug,net,txpool,personal,web3 \
--http --http.addr 0.0.0.0 --http.port $rpcport --http.vhosts "*" \
--port $port \
--verbosity 5 \
--nodiscover >> $node/node.log 2>&1 &
sleep 3s;
ps -ef|grep geth|grep -v grep;
5. 执行start.sh脚本,输入钱包文件密码,启动节点
$ chmod +x start.sh
$ ./start.sh
input node pass
node and miner is 0x2D3913c12ACa0E4A2278f829Fb78A682123c0125, rpc port 8545, p2p port 30300
Last updated