Polkadot同步节点安装部署

参考文档https://wiki.polkadot.network/docs/zh-CN/maintain-sync

 1、下载安装脚本

curl https://sh.rustup.rs -sSf | sh

2、更新rustup

rustup update

3、安装相应的依赖包

# Ubunut系统
apt install build-essential git clang libclang-dev pkg-config libssl-dev
# Centos系统
yum install build-essential git clang libclang-dev pkg-config libssl-dev

4、下载编译polkadot包

git clone https://github.com/paritytech/polkadot kusama
cd kusama
./scripts/init.sh
cargo build --release

或也可以直接下载polkadot启动程序

# wget https://github.com/paritytech/polkadot/releases/download/v0.8.27/polkadot
--2021-01-27 06:00:22--  https://github.com/paritytech/polkadot/releases/download/v0.8.27/polkadot
Resolving github.com (github.com)... 52.74.223.119
Connecting to github.com (github.com)|52.74.223.119|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/144140342/36271500-5406-11eb-846c-38e25a002241?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210127%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210127T060027Z&X-Amz-Expires=300&X-Amz-Signature=38fd9f5c7a3a53a0bfc49b7e5e760c35bfa1f8e502df1d696490d80aaa00ed5c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=144140342&response-content-disposition=attachment%3B%20filename%3Dpolkadot&response-content-type=application%2Foctet-stream [following]
--2021-01-27 06:00:27--  https://github-production-release-asset-2e65be.s3.amazonaws.com/144140342/36271500-5406-11eb-846c-38e25a002241?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210127%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210127T060027Z&X-Amz-Expires=300&X-Amz-Signature=38fd9f5c7a3a53a0bfc49b7e5e760c35bfa1f8e502df1d696490d80aaa00ed5c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=144140342&response-content-disposition=attachment%3B%20filename%3Dpolkadot&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.228.112
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.228.112|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104462008 (100M) [application/octet-stream]
Saving to: ‘polkadot’

polkadot                                                            100%[=================================================================================================================================================================>]  99.62M  6.28MB/s    in 18s     

2021-01-27 06:00:46 (5.67 MB/s) - ‘polkadot’ saved [104462008/104462008]

5、拷贝运行程序

mkdir /data/DOT
cp -rf target/release/polkadot/ /data/DOT/

6、启动程序

cd /data/DOT
./polkadot --name "Bitbull-polkadot" -database=/data/DOT/dotdata/ &
# 对外网开放rpc端口
./polkadot --name Bitbull-polkadot -d=/data/coins/DOT/dotdata/ --rpc-port 9932 --rpc-cors all --rpc-external  > /data/coins/DOT/debug.log 2>&1 &

7、查看接口

root@coin:/data/coins/DOT# curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' http://localhost:9933
{"jsonrpc":"2.0","result":"0x938a0a1de043fe36cbb9a6781a4d24a5496555997d48f59e5de27148dcfd76fb2262d0a291cbaedd9e53c57f95741da62ec969f49fa2ed323581bd2ea63bd1602c3e97e8e00fd10fbefcf2655e63c969b3982f672cf20ed2d76ac721ec188d14148dae1428e5c32b5cebad7a5be99659fd46f7660dbdb1bd519a56825ac6fc70daaf16bcb6c6868cf9ea8e2ab8bf649c182f449a81af0c591b622f26305c7041","id":1}

获取最新区块高度

root@coin:/data/coins/DOT# curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getHeader", "params":[]}' http://localhost:9933
{"jsonrpc":"2.0","result":{"digest":{"logs":["0x0642414245b5010300000000f8d7cd0f00000000965d164ace5a9f321c2ab9b55f246340f33263e926f6d910f73262aee37a0d18664a69e171cf9d56d36df9758f6986df7483c4d143b1e10e7b551192f326570c42921e788b2db48a9ddaab67cbd00f6ac432c34b2065ca015b5eeca14c585303","0x05424142450101c6307d3addfb0fbfefcf9336e44dd24451bafa1fb0c76c9e7e9c9cf93fb61b1942adcf9011c09e1f52dc581331f641693bfc5e0baabb6acf64e2ff3e73a79686"]},"extrinsicsRoot":"0x749b2464ec2d5ca5aac650aa7739aac6903ff1bb44d53c1d2e260d14563b4f95","number":"0xf95c","parentHash":"0x6744e2d86a815994ad790cb66928eff742d80609537de7f9b79d9eceacb44960","stateRoot":"0x037aef36131072a8567ce2f5d7a613a568e64f0597c572568d2fa4ea99d439ff"},"id":1}

转换成十进制查询最新高度

echo $((`curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getHeader", "params":[]}' http://localhost:9933 |awk -F '"' '{print $22}'`))

查看区块高度 

root@coin:/data/coins/DOT# curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock", "params":[]}' http://localhost:9933
{"jsonrpc":"2.0","result":{"block":{"extrinsics":["0x280403000ba04ca2667201","0x1c040a009e950300","0x1004140000"],"header":{"digest":{"logs":["0x0642414245b501030400000006c4cd0f0000000088f6b58b505f01c8c7911a48b40f2cc991557424187852e28d66c26a41c7a15d3541b609afbd96aafe94aec8aa51febc625028963756098cf4932a311901a50f5946c119006a90a86abcef36491183b6e81af1f0bb45055bac1a041208954a01","0x0542414245010150239c85981daa8144a99bd282c9c380541f89c8ad999bb31f11c4190c0cf65123553d5c5f953d418ee802ab366e942919fab6bd6389368eac56f91d56b90588"]},"extrinsicsRoot":"0x14c48c657972257ca625078998f00eb9a36df08f5a1ac0fb657da8d49d860105","number":"0xe56a","parentHash":"0xcfc0e06c184b5e01c151ee74d5da7cd61cafaf63bd3e743d451a78ce3ba58606","stateRoot":"0xbb25583075e34534027ecd23ec5293724e31c06c2ee8d4ad9e58f7699084492c"}},"justification":null},"id":1}

8、最终的启动方式

./polkadot --name Bitbull-polkadot -d=/data/coins/DOT/dotdata/ --rpc-port 9933 --rpc-cors all --rpc-external --pruning archive > /data/coins/DOT/debug.log 2>&1 &
./polkadot --name Bitbull-polkadot -d=/data/coins/DOT/dotdata/ --rpc-port 9933 --rpc-cors all --rpc-external --pruning archive --ws-port=9944 --ws-external

猜你喜欢

转载自blog.csdn.net/baidu_38432732/article/details/112891185