网络
网络 |
chainId |
主网 |
56 |
测试网 |
97 |
官方节点
Mainnet(https://bsc-dataseed.binance.org/),
Testnet(https://data-seed-prebsc-1-s1.binance.org:8545/)
配置
centos 7.6 、1.5T SSD、 8核 32G 、带宽10M
(注根据快照大小来配置SSD,至少是快照的2倍)
准备
安装screen
yum install screen -y
节点启动
预编译二进制文件下载
wget https://github.com/binance-chain/bsc/releases/download/v1.1.2/geth_linux
设置可执行权限及重命名为geth(操作习惯)
chomod +x geth_linux mv geth_linux geth
注:也可通过源码编译(需要 Go1.13+环境)
git clone https://github.com/binance-chain/bsc # Enter the folder bsc was cloned into cd bsc # Compile and install bsc make geth
配置文件下载
1. genesis.json
2. config.toml
wget https://github.com/binance-chain/bsc/releases/download/v1.1.2/mainnet.zip unzip mainnet.zip
genesis写入到本地状态
./geth --datadir node init genesis.json
下载快照
创建下载快照及解压快照会话
screen -S snapshots
打开地址
https://github.com/binance-chain/bsc-snapshots
找到最新快照下载,如当前最新为 geth-20211019.tar.gz。保证磁盘足够解压快照。
wget -O geth.tar.gz "<复制的快照地址>"
下载完成,解压快照
tar zxvf geth.tar.gz
数据库替换
将 node目录下的 chaindata 和triecache 文件替换
mv server/data-seed/geth/chaindata node/geth/chaindata;
mv server/data-seed/geth/triecache node/geth/triecache
配置文件修改
编辑 config.toml
HTTPHost: 值默认为 "localhost",仅允许本地访问,可设置为:"0.0.0.0"
HTTPVirtualHosts:设置为:HTTPVirtualHosts = ["*"]
HTTPPort = 8545 :HTTP端口
启动
创建节点启动会话
screen -S bsc
执行命令,运行节点
./geth --config ./config.toml --datadir ./node --cache 18000 --rpc.allow-unprotected-txs --txlookuplimit 0
节点状态监听
screen -S cli
./geth attach http://127.0.0.1:8545
查看同步情况
>eth.syncing
>eth.blockNumber
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://127.0.0.1:8545