迁移Evmos验证人节点

in hive-180932 •  2 years ago 

前几天,Evmos节点升级,其中一个主要的更新是缩短出块的速度。从之前的大概6秒每块,缩短到大概2秒每块

由于大幅缩短了出块速度,之前跑Evmos验证人的服务器显然跟不上出块的速度,频繁的丢块。一丢块,就跟不上同步速度,导致连续的丢块

尝试调整不同的节点设置,都不能解决连续丢块的问题,所以决定更换服务器,换一个NVMe SSD的服务器,因为之前的服务器丢块很大原因是硬盘读写速度跟不上同步速度。

迁移过程还算顺利。迁移Evmos验证人节点后,丢块的次数大大降低了。

image.png

这里写一下迁移Evmos验证人节点的过程:

安装GO 1.17

sudo rm -rf /usr/local/go;
curl https://dl.google.com/go/go1.17.linux-amd64.tar.gz | sudo tar -C/usr/local -zxvf - ;
cat <<'EOF' >>$HOME/.profile
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
EOF
source $HOME/.profile

#安装完成后运行以下命令查看版本

go version

安装其他必要的环境

sudo apt-get update -y && sudo apt-get upgrade -y;
sudo apt-get install build-essential -y;

下载源代码并编译

git clone https://github.com/tharsis/evmos
cd evmos && git checkout tags/v6.0.1 
make install

安装完成后可以运行 evmosd version --long 检查是否安装成功

evmosd version --long

name: evmos
server_name: evmosd
version: 6.0.1

初始节点

evmosd init <moniker> --chain-id=evmos_9001-2



*<moniker>改成你要设置的名字

导入钱包

evmosd keys add <your key name> --recover 



*<yourKeyName>改成你要设置的钱包名

下载genesis.json

curl https://archive.evmos.org/mainnet/genesis.json> ~/.evmosd/config/genesis.json

检查Genesis文件是否正确

cd ~/.evmosd/config
echo "4aa13da5eb4b9705ae8a7c3e09d1c36b92d08247dad2a6ed1844d031fcfe296c genesis.json" | sha256sum -c

修改app.toml

nano ~/.evmosd/config/app.toml

修改以下设置:

minimum-gas-prices = "25000000000aevmos"
pruning = "custom"
pruning-keep-recent = "100"
pruning-keep-every = "0"
pruning-interval = "10"
snapshot-interval = 0

修改config.toml

nano ~/.evmosd/config/config.toml

修改以下设置:

indexer = "null"

安装lz4

sudo apt update
sudo apt install snapd -y
sudo snap install lz4

下载节点备份

https://polkachu.com/tendermint_snapshots/evmos 上下载备份

下载+解压文件命令:

curl -o - -L https://snapshots1.polkachu.com/snapshots/evmos/evmos_1141681.tar.lz4 | lz4 -c -d - | tar -x -C $HOME/.evmosd

运行节点(使用Cosmovisor)

下载并设置Cosmovisor

git clone https://github.com/cosmos/cosmos-sdk
cd cosmos-sdk
git checkout v0.44.6
make cosmovisor
cp cosmovisor/cosmovisor $GOPATH/bin/cosmovisor
cd $HOME
mkdir -p ~/.evmosd
mkdir -p ~/.evmosd/cosmovisor
mkdir -p ~/.evmosd/cosmovisor/genesis
mkdir -p ~/.evmosd/cosmovisor/genesis/bin
mkdir -p ~/.evmosd/cosmovisor/upgrades
echo "# Setup Cosmovisor" >> ~/.profile
echo "export DAEMON_NAME=evmosd" >> ~/.profile
echo "export DAEMON_HOME=$HOME/.evmosd" >> ~/.profile
echo 'export PATH="$DAEMON_HOME/cosmovisor/current/bin:$PATH"' >> ~/.profile
source ~/.profile
cp $GOPATH/bin/evmosd ~/.evmosd/cosmovisor/genesis/bin

创建背后运行服务

sudo tee /etc/systemd/system/evmosd.service > /dev/null <<EOF  
[Unit]
Description=Evmos Daemon
After=network-online.target

[Service]
User=$USER
ExecStart=$(which cosmovisor) start
Restart=always
RestartSec=3
LimitNOFILE=infinity

Environment="DAEMON_HOME=$HOME/.evmosd"
Environment="DAEMON_NAME=evmosd"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"

[Install]
WantedBy=multi-user.target
EOF

创建好后,更新,开启节点服务

sudo -S systemctl daemon-reload
sudo -S systemctl enable evmosd
sudo -S systemctl start evmosd

上面的命令运行好后,你的节点就开启了

用下面命令查看服务:

查看服务状态

systemctl status evmosd

查看服务日志

journalctl -u evmosd -f

等节点同步成功后,把旧节点停止,然后迁移验证人文件到新的服务器

迁移验证人文件

迁移验证人节点需要的文件是:

  • ~/.evmosd/config/priv_validator_key.json
  • ~/.evmosd/config/node_key.json
    把上面2个文件搬到新的服务器

重启Evmos节点

systemctl restart evmosd

重启前请确定旧的节点已经停止,不然同时2个节点一起跑会导致双签

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!