以太坊公链Geth同步

一、安装所需基础工具html

yum update -y && yum install git wget bzip2 vim gcc-c++ ntp epel-release nodejs cmake -y

二、安装Gonode

wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.10.linux-amd64.tar.gz
echo 'export GOROOT=/usr/local/go' >> /etc/profile 
echo 'export PATH=$PATH:$GOROOT/bin' >> /etc/profile 
echo 'export GOPATH=/root/go' >> /etc/profile
echo 'export PATH=$PATH:$GOPATH/bin' >> /etc/profile
source /etc/profile

验证linux

$ go version
go version go1.10 linux/amd64

三、克隆编译项目go-ethereumc++

git clone https://github.com/ethereum/go-ethereum.git 
cd go-ethereum 
make all

在path中加入geth路径git

echo 'export PATH=$PATH:/opt/go-ethereum/build/bin' >> /etc/profile
source /etc/profile

验证github

[root@iZrj9hk3x36fkle13532jaZ ~]# geth version
INFO [08-16|10:12:12.117] Bumping default cache on mainnet         provided=1024 updated=4096
Geth
Version: 1.9.2-unstable
Git Commit: c9cdf144d55f6bbd75314e812eeefc18d7e8c40e
Git Commit Date: 20190808
Architecture: amd64
Protocol Versions: [63]
Network Id: 1
Go Version: go1.10
Operating System: linux
GOPATH=/root/go
GOROOT=/usr/local/go

四、同步以太坊区块web

nohup geth --syncmode "fast" --port "30303" --cache=4096 --datadir /data/geth --rpc --rpcapi db,eth,net,web3,personal,admin,miner --rpcport 8545 --rpcaddr 0.0.0.0 --rpccorsdomain "*"  --maxpeers 999  --maxpendpeers 999 > output.log 2>&1 &

五、进入geth控制台vim

geth attach ipc:/data/geth/geth.ipc