本文作者:陈进坚
博客地址:https://jian1098.github.io
CSDN博客:https://blog.csdn.net/c_jian
简书:https://www.jianshu.com/u/8ba9ac5706b6
联系方式:jian1098@qq.com
安装Geth
1 | root@dserv834-mtl8:~# apt-get install software-properties-common |
安装后查询到geth版本即为安装成功
1 | root@dserv834-mtl8:~# which geth ###查看geth路径 |
创建Geth启动/停止脚本
查看本地IP地址,得到内网地址为173.209.49.10
1 | root@dserv834-mtl8:~# ifconfig -a |
创建geth启动脚本starteth.sh,将第二行开始的脚本复制保存,需要修改rpcaddr的ip,datadir可以省略,一般将datadir改为大容量的数据盘目录
1 | root@dserv834-mtl8:~# vi starteth.sh |
创建geth停止脚本stopeth.sh,将第二行开始的脚本复制保存
1 | root@dserv834-mtl8:~# vi stopeth.sh |
配置脚本执行权限
1 | root@dserv834-mtl8:~# chmod u+x st*.sh |
启动geth程序同步区块数据
启动Geth开始同步数据,通过查看geth.log来监控Geth的同步情况
1 | root@dserv834-mtl8:~# ./starteth.sh |
一般情况下geth从0开始同步需要3天左右的时间,由服务器的带宽和性能决定,可以购买境外的服务器,如香港的阿里云。
判断同步完成
geth在同步的时候,通过geth console查看eth.blockNumber命令查询区块高度,如果得到的结果是0,说明没有同步完成,如果得到最新的区块,说明已经同步到最新区块了。