Ethereum节点安装

基于Ubuntu安装

  • 安装依赖
apt-get install software-properties-common python-software-properties
  • 获取源
add-apt-repository -y ppa:ethereum/ethereum
  • 安装
apt-get update
apt-get install ethereum

基于Cnetos安装

  • 准备源码
git clone https://github.com/ethereum/go-ethereum.git
git checkout v1.7.2
  • 安装go环境
wget https://www.golangtc.com/static/go/1.9.2/go1.9.2.linux-amd64.tar.gz
tar -xzf  go1.9.2.linux-amd64.tar.gz -C /usr/local/
vim /etc/profile
export GOPATH=/usr/local/go
export PATH=$GOPATH/bin:$PATH
source /etc/profile
  • 检查go环境
go version

输出如go version go1.9.2 linux/amd64即安装成功

  • 编译go-ethereum
    cd至go-ethereum目录,使用make命令进行build
make geth
make all
  • 为geth配置环境变量
vim /etc/profile
export GETH=/data/git/go-ethereum/build
export PATH=$GETH/bin:$PATH

/data/gitgit clone所在的地址

source /etc/profile
  • 检查geth是否安装成功
geth version

输出如下

Geth
Version: 1.7.2-stable
Git Commit: 1db4ecdc0b9e828ff65777fb466fc7c1d04e0de9
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.9.2
Operating System: linux
GOPATH=/usr/local/go
GOROOT=/usr/local/go

即安装成功

启动节点

nohup geth --rpc --rpcport 8545 --rpcaddr=`hostname -I` --datadir /root/.ethereum --networkid 1

参数说明

--rpc 启用rpc连接

--rpcport rpc端口

--rpcaddr 为rpc设置host,设置为`hostname -I`即可

--datadir 客户端路径,启动后改路径下geth为区块数据,keystore为私钥

--networkid 客户端网络标识,设置为1即Ethereum主网络

节点如上启动后会从Ethereum主网络同步区块,时间会很长(N天),如果已经有区块数据可以在启动前将其传输至/root/.ethereum/geth/chaindata

猜你喜欢

转载自blog.csdn.net/yimcarson/article/details/83821298