1、安装所需基础工具
yum update -y && yum install git wget bzip2 vim gcc-c++ ntp epel-release nodejs cmake -y
2、安装Go
- 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
验证
- $ go version
- go version go1.10 linux/amd64
3、克隆编译项目go-ethereum
- git clone https://github.com/ethereum/go-ethereum.git
- cd go-ethereum
- make all
在path中加入geth路径
- echo 'export PATH=$PATH:/opt/go-ethereum/build/bin' >> /etc/profile
- source /etc/profile
验证
- [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
4、同步以太坊区块
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 &
5、进入geth控制台
geth attach ipc:/data/geth/geth.ipc