polygon部署 0.2.x

一 环境要求

  • 内存:16-32 GB
  • CPU:4-8核CPU(t3 xLarge)
  • 存储:至少 650GB SSD(确保它是可扩展的)

二 安装环境依赖

https://docs.polygon.technology/docs/integrate/full-node-binaries

2.1 安装编译环境

~# sudo apt-get install build-essential -y

2.2 安装go

~# wget https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz
~# tar xf go1.17.5.linux-amd64.tar.gz -C /usr/local/
~# echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
~# . /etc/profile
~# go version
go version go1.17.5 linux/amd64

2.3 安装RabbitMQ

~# apt -y install rabbitmq-server
~# systemctl enable rabbitmq-server
Synchronizing state of rabbitmq-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable rabbitmq-server
~# systemctl start rabbitmq-server

三 安装Binaries

3.1 下载安装

~# git clone https://github.com/maticnetwork/heimdall
~# cd heimdall/
~/heimdall# git checkout v0.2.4
~/heimdall# make install network=mumbai  #测试网

3.2 查看二进制安装路径

~# ls -l go/bin/
total 130636
-rwxr-xr-x 1 root root 50752736 Dec 20 16:00 bridge
-rwxr-xr-x 1 root root 40397632 Dec 20 15:59 heimdallcli
-rwxr-xr-x 1 root root 42617112 Dec 20 15:59 heimdalld

3.3 复制可执行程序

~# cp /root/go/bin/heimdalld /usr/bin/
~# cp /root/go/bin/heimdallcli /usr/bin/
~# cp /root/go/bin/bridge /usr/bin/

四 安装Bor

~# git clone https://github.com/maticnetwork/bor
~# cd bor
~# git checkout v0.2.13-beta2
~# make bor-all
~# cp bor/build/bin/bor /usr/bin/
~# cp bor/build/bin/bootnode /usr/bin/

五 设置node

5.1 下载launch

~# git clone https://github.com/maticnetwork/launch

5.2 设置launch directory

~# mkdir node
~# cp -rfp launch/testnet-v4/sentry/sentry/* node

六 设置network directories

6.1 设置Heidmall数据

~# cd node/heimdall/
~/node/heimdall# bash setup.sh 
{
  "chain_id": "heimdall-ps1Fl2",
  "node_id": "e632f106c07eaee86d68059e8b62acc3ac6b1206"
}

6.2 设置bor数据

~# cd ~/node/bor
~/node/bor# bash setup.sh 
INFO [12-21|10:29:53.071] Maximum peer count                       ETH=50 LES=0 total=50
INFO [12-21|10:29:53.071] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [12-21|10:29:53.072] Set global gas cap                       cap=50,000,000
INFO [12-21|10:29:53.072] Allocated cache and file handles         database=/root/.bor/data/bor/chaindata cache=16.00MiB handles=16
INFO [12-21|10:29:53.077] Writing custom genesis block 
INFO [12-21|10:29:53.079] Persisted trie from memory database      nodes=11 size=1.60KiB time="136.267µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [12-21|10:29:53.079] Successfully wrote genesis state         database=chaindata                     hash=7b6650..2b1ca7
INFO [12-21|10:29:53.080] Allocated cache and file handles         database=/root/.bor/data/bor/lightchaindata cache=16.00MiB handles=16
INFO [12-21|10:29:53.084] Writing custom genesis block 
INFO [12-21|10:29:53.085] Persisted trie from memory database      nodes=11 size=1.60KiB time="125.427µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [12-21|10:29:53.086] Successfully wrote genesis state         database=lightchaindata                     hash=7b6650..2b1ca7
Setup done!

七 设置service files

7.1 下载service

~# cd ~/node
~/node# wget https://raw.githubusercontent.com/maticnetwork/launch/master/testnet-v4/service.sh

7.2 创建元数据文件

~# sudo mkdir -p /etc/matic
~# sudo chmod -R 777 /etc/matic/
~# touch /etc/matic/metadata

7.3 生成service file

~# cd ~/node
~/node# bash service.sh
~/node# sudo cp *.service /etc/systemd/system/

7.4 heimdalld-bridge.service

~/node# cat heimdalld-bridge.service 
[Unit]
  Description=heimdalld-bridge

[Service]
  WorkingDirectory=/root/node
  ExecStart=/root/go/bin/bridge start --all
  Type=simple
  User=root

[Install]
  WantedBy=multi-user.target

7.5  heimdalld-rest-server.service

~/node# cat heimdalld-rest-server.service 
[Unit]
  Description=heimdalld-rest-server

[Service]
  WorkingDirectory=/root/node
  ExecStart=/root/go/bin/heimdalld rest-server
  Type=simple
  User=root

[Install]
  WantedBy=multi-user.target

7.6 heimdalld.service

~/node# cat heimdalld.service 
[Unit]
  Description=heimdalld

[Service]
  WorkingDirectory=/root/node
  ExecStart=/root/go/bin/heimdalld start
  Type=simple
  User=root

[Install]
  WantedBy=multi-user.target

7.7 bor.service

~/node# cat bor.service 
[Unit]
  Description=bor
  StartLimitIntervalSec=500
  StartLimitBurst=5

[Service]
  Restart=on-failure
  RestartSec=5s
  WorkingDirectory=/root/node
  EnvironmentFile=/etc/matic/metadata
  ExecStartPre=/bin/chmod +x /root/node/bor/start.sh
  ExecStart=/bin/bash /root/node/bor/start.sh ${VALIDATOR_ADDRESS}
  Type=simple
  User=root
  KillSignal=SIGINT
  TimeoutStopSec=120

[Install]
  WantedBy=multi-user.target

八 设置配置文件

8.1 heimdalld配置

grep seeds .heimdalld/config/config.toml 
# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool
seeds="4cd60c1d76e44b05f7dfd8bab3f447b119e87042@54.147.31.250:26656,b18bbe1f3d8576f4b73d9b18976e71c65e839149@34.226.134.117:26656"

8.2 bor启动配置

grep bootnodes ~/node/bor/start.sh
--bootnodes "enode://320553cda00dfc003f499a3ce9598029f364fbb3ed1222fdc20a94d97dcc4d8ba0cd0bfa996579dcc6d17a534741fb0a5da303a90579431259150de66b597251@54.147.31.250:30303"

九 启动服务

9.1 启动heimdall

systemctl start heimdalld
systemctl start heimdalld-rest-server

9.2 启动bor

同步 Heimdall 后,启动 Bor

systemctl start bor

10 查看日志

10.1 Heimdall日志

journalctl -u heimdalld.service -f

10.2 Heimdall rest server日志

journalctl -u heimdalld-rest-server.service -f

10.3 bor日志

journalctl -u bor.service -f

11 Polygon Chains Snapshots

11.1 Chains Snapshots 下载

https://snapshots.matic.today/

11.2 Heimdall Snapshot

11.2.1 下载Heimdall Snapshot

wget -c <snapshot url>

11.2.2 解压Heimdall Snapshot

tar -xzvf <snapshot file> -C <HEIMDALL_DATA_DIRECTORY>
// For example, this will unpack the tar file in the Heimdall Data directory:
tar xf heimdall-snapshot-2022-06-10.tar.gz -C /data/polygon/.heimdalld/data

11.2.3 实例

wget -c https://matic-blockchain-snapshots.s3-accelerate.amazonaws.com/matic-mainnet/heimdall-snapshot-2022-11-30.tar.gz -O - | tar -xzf - -C ~/.heimdalld/data/

11.3 Bor Snapshot

11.3.1 下载Bor Snapshot

wget -c <snapshot url>

11.3.2 解压Bor Snapshot

tar -xzvf <snapshot file> -C <BOR_DATA_DIRECTORY>
// For example, this will unpack the tar file in the Bor data directory:
tar -xzvf bor-pruned-snapshot-2022-07-01.tar.gz -C /data/polygon/.bor/data/bor/chaindata

11.3.3 示例

wget -c     https://matic-blockchain-snapshots.s3-accelerate.amazonaws.com/matic-mainnet/bor-fullnode-snapshot-2022-11-21.tar.gz  -O - | tar -xzf - -C ~/.bor/data/bor/chaindata

 

posted @ 2021-12-21 13:05  小吉猫  阅读(1039)  评论(0编辑  收藏  举报