指导文档
1、获取最新BSC镜像
镜像地址
2、下载BSC节点配置
通过以下方式下载genesis.json和config.toml
主网:
wget $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep mainnet |cut -d\" -f4)
unzip mainnet.zip
测试网
wget $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep mainnet |cut -d\" -f4)
unzip testnet.zip
3、编写docker-compose yaml文件
version: '3'services:bsc:image: ghcr.io/bnb-chain/bsc:1.2.8container_name: bsc#command: --http.addr 0.0.0.0 --http.port 8545 --http.vhosts '*' --verbosity 5ports:- 8000:8545volumes:- ./config:/bsc/config- ./data/:/bsc/noderestart: alwayscommand: ["--config", "/bsc/config/config.toml", "--datadir", "/bsc/node"]
注:
Docker 变量和配置文件位置
需要注意的重要环境变量:
$BSC_HOME = /bsc
$DATA_DIR = /data
文件位置:
BSC_CONFIG=${BSC_HOME}/config/config.toml
BSC_GENESIS=${BSC_HOME}/config/genesis.json
4、启动节点
root@iZj6c9oahptfht9r6j85e3Z:/data/docker-compose/bsc# docker-compose up -d
Pulling bsc (ghcr.io/bnb-chain/bsc:1.2.8)...
1.2.8: Pulling from bnb-chain/bsc
4db1b89c0bd1: Pull complete
a34266e32dee: Pull complete
4999da8f4ad8: Pull complete
f26222169b59: Pull complete
e43db73d308e: Pull complete
0b2cfd4e54fd: Pull complete
66a3300a431a: Pull complete
Digest: sha256:3ce9d32c405ec630a46455f56fd31dcb36d191827aecc145303935918bc4bd5d
5、节点验证
24cc269e9118:~$ geth attach http://localhost:8545
Welcome to the Geth JavaScript console!modules: eth:1.0 net:1.0 parlia:1.0 rpc:1.0 txpool:1.0 web3:1.0To exit, press ctrl-d or type exit
> eth.blockNumber
2308452
> eth.syncing
{currentBlock: 2301620,healedBytecodeBytes: 0,healedBytecodes: 0,healedTrienodeBytes: 0,healedTrienodes: 0,healingBytecode: 0,healingTrienodes: 0,highestBlock: 27367683,startingBlock: 2256913,syncedAccountBytes: 374663576,syncedAccounts: 1933270,syncedBytecodeBytes: 187067435,syncedBytecodes: 24643,syncedStorage: 11251871,syncedStorageBytes: 2452084725
}
curl验证区块高度
# curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H 'Content-Type: application/json' http://localhost:8000
{"jsonrpc":"2.0","id":1,"result":"0x1c598e5"}