Centos下安装Geth

518 阅读1分钟

Go Ethereum下载安装

下载地址:geth.ethereum.org/downloads/,选择需要下载的客户端:geth-[linux]-amd64-1.***.tar.gz

  • #执行下载命令
wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.11.6-ea9e62ca.tar.gz
  • 解压
[root@localhost opt]# tar zxvf geth-linux-amd64-1.11.6-ea9e62ca.tar.gz 
[root@localhost opt]# cd geth-linux-amd64-1.11.6-ea9e62ca
[root@localhost opt]# cp geth /usr/bin/geth
  • 同步网络时间(时间错误导致无法同步节点)
ntpdate cn.pool.ntp.org
  • 定时同步网络时间
[root@localhost opt]# echo '0 0 * * * root ntpdate cn.pool.ntp.org prefer' >> /etc/crontab  
[root@localhost opt]# service crond restart

-创建目录 [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