准备工作

1
sudo apt-get install aria2

下载最近的历史快照

1
2
3
screen -S download

aria2c -o geth.tar.lz4 -x 16 -s 20 "https://tf-dex-prod-public-snapshot-site1.s3-accelerate.amazonaws.com/geth-20220503.tar.lz4?AWSAccessKeyId=AKIAYINE6SBQPUZDDRRO&Signature=%2B83JSYmxAiGVnr4qAQGvpFOvDgI%3D&Expires=1654256806"

解压文件

1
2
3
4
5
6
7
8
9
10
11
12
screen -S jieya

lz4 -d geth.tar.lz4 | tar -xv

crtl + a + d

# 检查目前所有的screen作业,并删除已经无法使用的screen作业
screen -wipe

# 恢复离线的screen作业

screen -r job

下载geth_linux可执行文件

1
2
wget   $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep geth_linux |cut -d\" -f4)
mv geth_linux /usr/local/bin/geth

下载mainnet.zip配置文件

1
2
wget   $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep mainnet |cut -d\" -f4)
unzip mainnet.zip
  • 解压之后会有config.tomlgenesis.json文件
  • 修改config.toml文件,允许访问
1
2
HTTPHost = "0.0.0.0"
HTTPVirtualHosts = ["*"]

启动

  • 使用supervisor守护进程启动
1
2
3
4
5
6
7
8
[program:geth_job]
command=geth --config /bsc/config.toml --datadir /bsc/node --diffsync --rpcapi eth,web3,admin,personal,net --cache 18000 --rpc.allow-unprotected-txs --txlookuplimit 0
user=root
autostart=true
autorestart=true
numprocs=1
redirect_stderr=true
stdout_logfile=/bsc/job/geth.log

测试rpc服务

1
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://127.0.0.1:8080

以太坊JSON RPC手册

掉块处理

1
2
3
4
StaticNodes = [
"enode://9f90d69c5fef1ca0b1417a1423038aa493a7f12d8e3d27e10a5a8fd3da216e485cf6c15f48ee310a14729bc3a4b05038479476c0aa82eed3c5d9d2e64ba3a2b3@52.69.42.169:30311",
"enode://78ef719ebb2f4fc222aa988a356274dcd3624fb808936ca2ea77388ca229773d4351f795abf505e86db1a30ed1523ded9f9674d916b295bfb98516b78d2844be@13.231.200.147:30311"
]
  • 重启服务