Ubuntu 搭建BSC全量节点
Aug 3, 2022
Ubuntu 搭建BSC全量节点
当前配置:
- 128核心CPU
- 内存2T
- SSD,25T
- 带宽,国内联通
- 长沙
安装GO
下载最近linux版本,将解压后的目录放到 /usr/local
中
在 ~/.bashrc 中配置环境
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
输入 go version 查看安装。
国内的话,记得要配置 go mod 代理:
$ go env -w GOPROXY=https://goproxy.io,direct
$ go env | grep GOPROXY
查看是否为 goproxy.io
节点安装
$ git clone https://github.com/binance-chain/bsc
$ cd bsc/
$ make geth
配置到环境变量,将以下代码加入到 ~/.bashrc
export PATH=$PATH:/youpath/bsc/build/bin
使用geth version
确认安装正确
配置创世区块
$ wget https://github.com/binance-chain/bsc/releases/download/v1.1.7/mainnet.zip
$ unzip mainnet.zip
$ geth --datadir node init genesis.json
第一行命令,去 github 上查看最新版本。
启动BSC全节点
$ screen -S bsc
$ geth --config ./config.toml --datadir ./node --diffsync --cache 56000 --rpc.allow-unprotected-txs --gcmode=archive --syncmode=full --txlookuplimit 0
–config:指定BSC节点配置文件
–datadir:指定BSC节点数据库和密钥存储库的数据目录(默认即可)
–cache:设置最大分配给内部缓存的内存,默认:1024(设置越大,每次同步的数据越多,消耗的内存也越大)
–rpc.allow-unprotected-txs:允许通过RPC提交不受保护的(非 EIP155 签名)交易
–txlookuplimit 0 : 禁用删除事务索引
–diffsync:启用差异同步协议来帮助节点更快地同步
查看同步进度
$ cd youpath/node
$ geth attach geth.ipc
$ eth.syncing
可以看到 syncing 对象中有currentBlock,这为当前同步到的区块号。
总结
- 同步区块时,默认会将机器CPU压榨干净,此时最好不好取做其他依赖性能的事情。
- 从0同步到最新区块,需要挺长时间,其中定时来查看同步速度和磁盘空间是否富余。
- CPU、内存、SSD,会决定同步时长。