go-ethereum 需要go版本不低于 1.7, 文章最后介绍了如何卸载低版本的go
sudo add-apt-repository -y ppa:gophers/archive
sudo apt-get update
sudo apt-get install -y golang-1.10-go
sudo ln -s /usr/lib/go-1.10/bin/go /usr/bin/go
通过软链的方式把go 放到全局环境变量中
查看go版本 go version
git clone https://github.com/ethereum/go-ethereum
cd go-ethereum
git checkout v1.8.0
make geth #编译
生成 执行文件 ./build/bin/geth
./build/bin/geth
INFO [03-12|21:50:36] Maximum peer count ETH=25 LES=0 total=25
INFO [03-12|21:50:36] Starting peer-to-peer node instance=Geth/v1.8.0-stable/linux-amd64/go1.10
INFO [03-12|21:50:36] Allocated cache and file handles database=~/.ethereum/geth/chaindata cache=768 handles=512
INFO [03-12|21:50:36] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Engine: ethash}"
INFO [03-12|21:50:36] Disk storage enabled for ethash caches dir=~/.ethereum/geth/ethash count=3
INFO [03-12|21:50:36] Disk storage enabled for ethash DAGs dir=~/.ethash count=2
INFO [03-12|21:50:36] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [03-12|21:50:36] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [03-12|21:50:36] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [03-12|21:50:36] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [03-12|21:50:36] Loaded local transaction journal transactions=0 dropped=0
INFO [03-12|21:50:36] Regenerated local transaction journal transactions=0 accounts=0
INFO [03-12|21:50:36] Starting P2P networking
INFO [03-12|21:50:36] Mapped network port proto=udp extport=30303 intport=30303 interface=NAT-PMP(192.168.1.1)
INFO [03-12|21:50:36] UDP listener up self=enode://67d9b38f8a2f9874ef60d53a52492efecaaad5f662d08ef@192.168.1.1:30303
INFO [03-12|21:50:36] RLPx listener up self=enode://67d9b38f8a2f9874ef60d53a52492efecaaad5f662d08ef@192.168.1.1:30303
INFO [03-12|21:50:36] IPC endpoint opened url=~/.ethereum/geth.ipc
INFO [03-12|21:50:36] Mapped network port proto=tcp extport=30303 intport=30303 interface=NAT-PMP(192.168.1.1)
nohup ./build/bin/geth --datadir /mnt/eth &
##移动 gethsudo mv ./build/bin/geth /usr/local/bin/
eth有三种同步方式:
--syncmode 'fast' Blockchain sync mode ('fast' 'full or 'light')
默认是 fast
, 如果同步全部数据 geth --syncmode full
##守护进程
geth Ethereum node to run automatically on Ubuntu
#/etc/supervisor/conf.d/gethd.conf
[program:gethd]
command=/usr/local/bin/geth --datadir /mnt/eth/data --syncmode full --rpc
user=deployer # deployer用户启动任务
autostart=true
autorestart=true
stderr_logfile=/mnt/eth/data/geth_err.log
stdout_logfile=/mnt/eth/data/geth.log
sudo supervisorctl reload
sudo apt-get remove golang-go
sudo apt-get remove --auto-remove golang-go
参考:
https://github.com/golang/go/wiki/Ubuntu
https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu