一 環境要求
- 記憶體: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="[email protected]:26656,[email protected]: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.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