知乎專欄 | 多維度架構 | | | 微信號 netkiller-ebook | | | QQ群:128659835 請註明“讀者” |
本文所用軟件版本
geth v.1.8.13
truffle v4.0.6
web3.js v1.0.0
Solidity Version: 0.4.24
安裝環境
Ubuntu 17.10
sudo apt upgrade -y sudo apt install software-properties-common sudo add-apt-repository -y ppa:ethereum/ethereum sudo apt update sudo apt install ethereum
neo@netkiller ~ % geth version Geth Version: 1.8.10-stable Git Commit: 4bb3c89d44e372e6a9ab85a8be0c9345265c763a Architecture: amd64 Protocol Versions: [63 62] Network Id: 1 Go Version: go1.9.5 Operating System: linux GOPATH= GOROOT=/usr/lib/go-1.9
sudo apt install solc -y
neo@netkiller ~ % solc --version solc, the solidity compiler commandline interface Version: 0.4.19+commit.c4cbbb05.Linux.g++
yum update -y yum install git wget bzip2 -y yum install golang -y cd /usr/local/src git clone https://github.com/ethereum/go-ethereum.git cd go-ethereum/ gmake all mv build /srv/go-ethereum echo "export PATH=$PATH:$PWD/build/bin" >> /etc/profile source /etc/profile
上面安裝版本是 unstable 版本,如果是生產環境請使用 Release 版本 https://github.com/ethereum/go-ethereum/tags
wget https://github.com/ethereum/go-ethereum/archive/v1.8.10.tar.gz tar zxvf v1.8.10.tar.gz cd go-ethereum-1.8.10/ gmake all mv build /srv/go-ethereum-1.8.10
brew update brew upgrade brew tap ethereum/ethereum brew install ethereum brew install solidity
brew install node brew install npm npm config set registry https://registry.npm.taobao.org
下載安裝以太坊錢包(大陸網絡可能下載有問題,需要翻牆)
https://github.com/ethereum/mist/releases/download/v0.9.3/Ethereum-Wallet-macosx-0-9-3.dmggit clone https://github.com/ethereum/go-ethereum sudo apt-get install -y build-essential golang cd go-ethereum make geth
Netkiller OSCM 是由 Netkiller 製作的一套自動化安裝腳本。
適用於 CentOS 7
curl -s https://raw.githubusercontent.com/oscm/shell/master/blockchain/ethereum/centos/go-ethereum-1.8.10.sh | bash
安裝完成後使用下面命令進入控制台
[root@localhost ~]# su - ethereum Last login: Sat Feb 3 00:23:52 EST 2018 on pts/0 [ethereum@localhost ~]$ geth attach Welcome to the Geth JavaScript console! instance: Geth/v1.8.10-stable/linux-amd64/go1.8.10 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0 >
curl -s https://raw.githubusercontent.com/oscm/shell/master/blockchain/ethereum/centos/go-ethereum-1.8.1.sh | bash
curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/gcc/gcc.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/golang/golang-1.10.2.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/blockchain/ethereum/centos/go-ethereum-1.8.10.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/blockchain/ethereum/systemd/private.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/node.js/binrary/node-v10.1.0.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/node.js/binrary/profile.d.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/blockchain/ethereum/truffle/truffle.sh | bash
在同步主網的過程中,我們發現經常出現geth崩潰退出,為了防止異常退出,我們寫了這個腳本。
[ethereum@netkiller ~]$ cat run.sh #!/bin/bash for (( ; ; )) do #geth --syncmode light --cache 2048 --maxpeers 200 # geth --syncmode light --cache 2048 --maxpeers 200 --rpc --rpcaddr 0.0.0.0 --rpcport 7545 --rpcapi web3,admin,eth,personal --port 30303 2> /tmp/geth.log geth --datadir private --networkid 44444 --port 30302 --mine --rpc #geth --testnet --syncmode light --cache 2048 --maxpeers 200 --rpc 2> /tmp/geth.log sleep 10 done &