# 拉取镜像
[root@ecs-5731 ~]# docker pull ethereum/client-go:v1.9.23 [root@ecs-5731 ~]# docker run -dit --name geth -p 30303:30303 -p 8545:8545 -p 30303:30303/udp -v /etc/localtime:/etc/localtime -v /home/geth:/root/.ethereum ethereum/client-go:v1.9.23 --rpc --rpcaddr "0.0.0.0"
进入容器并进入geth控制台
/ # geth attach /root/.ethereum/geth.ipc > eth.syncing # 同步状态 false 当返回false时,则同步完成。 > eth.blockNumber # 同步过程中通过 eth.blockNumber 查看当前区块号的话会显示为0 11188232 > net.peerCount # 连接了多少个节点进行同步 14
在同步过程中,查看同步状态,currentBlock和highestBlock 差100多个区块,这段时间停留了很久,大约2天才能完全同步完。
同步完成后,eth.syncing会返回false,查看容器日志会打印Imported new chain segment字符信息。
[root@ecs-5731 ~]# docker logs -f geth INFO [11-04|11:26:48.079] Imported new chain segment blocks=1 txs=142 mgas=12.446 elapsed=101.256ms mgasps=122.916 number=11188241 hash="88c31d…4cb3c7" dirty=648.96MiB
当前块和高度块差100多资料:https://www.jianshu.com/p/c172b807514f
注意:8545端口不要对外网开放或限制访问来源。
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/4892.html