Go-Ethereum: 編譯運(yùn)行

安裝Golang

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 通過(guò)軟鏈的方式把go 放到全局環(huán)境變量中

查看go版本 go version

編譯Ethereum

git clone https://github.com/ethereum/go-ethereum
cd go-ethereum
git checkout v1.8.0
make geth #編譯

生成 執(zhí)行文件 ./build/bin/geth

運(yùn)行

./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)

設(shè)定datadir 并后臺(tái)運(yùn)行

nohup ./build/bin/geth --datadir /mnt/eth &

移動(dòng) geth

sudo mv ./build/bin/geth /usr/local/bin/

同步方式

eth有三種同步方式:

--syncmode 'fast'   Blockchain sync mode ('fast' 'full or 'light')

默認(rèn)是 fast, 如果同步全部數(shù)據(jù) geth --syncmode full

守護(hù)進(jìn)程

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用戶啟動(dòng)任務(wù)
autostart=true
autorestart=true
stderr_logfile=/mnt/eth/data/geth_err.log
stdout_logfile=/mnt/eth/data/geth.log

sudo supervisorctl reload

卸載低版本Golang

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容