知乎专栏 | 多维度架构 |
本文所用软件版本
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 &