Centos下安装Geth

一般要求服务器:4核-8G-500G

[root@localhost opt]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

Go Ethereum下载安装

下载地址:https://geth.ethereum.org/downloads/

选择需要下载的客户端:geth-linux-amd64-1.8.27-4bcc0a37.tar.gz

#下载
[root@localhost opt]# wget geth-linux-amd64-1.8.27-4bcc0a37.tar.gz


# 解压安装 将geth放入usr/local/bin目录下【可省略环境变量配置】
[root@localhost opt]# tar zxvf geth-linux-amd64-1.8.27-4bcc0a37.tar.gz
[root@localhost opt]# cd geth-linux-amd64-1.8.27-4bcc0a37
[root@localhost opt]# cp geth /usr/bin/geth

同步网络时间(时间错误导致无法同步节点)

[root@localhost opt]# ntpdate cn.pool.ntp.org
16 Jul 09:59:56 ntpdate[28004]: step time server 119.28.183.184 offset 0.975532 sec

定时同步网络时间

[root@localhost opt]# echo '0 0 * * * root ntpdate cn.pool.ntp.org prefer' >> /etc/crontab
[root@localhost opt]# service crond restart
Redirecting to /bin/systemctl restart crond.service

# 创建目录 [root@localhost ~]# mkdir geth

# 生成配置文件
[root@localhost ~]# geth --syncmode 'fast' --datadir /home/geth/chaindata --http --http.addr=0.0.0.0 --http.port 9545 --http.api "eth,web3,txpool,net,personal"  --ws --ws.port 9546 --ws.addr "0.0.0.0" --ws.origins "*"  --maxpeers 500  --cache 2048 dumpconfig > /root/geth/config.toml 

后台启动geth开始后台同步区块
[root@localhost ~]#  nohup geth --config /home/geth/config.toml >> /home/geth/geth-sync.log 2>&1 &

查看同步日志【注意路径】

[root@localhost geth]# tail -f  geth-sync.log

参数参见

https://www.cnblogs.com/tinyxiong/p/7918706.html

https://blog.csdn.net/zhangnero/article/details/96133289

进入控制台

[root@localhost ~]# geth attach rpc:http://127.0.0.1:9545

查看区块同步情况

> eth.syncing 

> eth.blockNumber

附:https://cn.etherscan.com/

原文地址:https://www.cnblogs.com/ddzzhh/p/15677713.html