Geth在Centos上安装

注:建议在虚拟机上安装(作为Template VM,后续Copy为多节点组成私有链)

下载cmake3.x: (智能合约需要cmake3.x版本才可以编译):

wget https://cmake.org/files/v3.3/cmake-3.3.2.tar.gz
# 解压
tar zxvf cmake-3.3.2.tar.g
cd cmake-3.3.2
# 安装
./configure
make
make install

移动到/usr/local/cmake下:

mkdir /usr/local/cmake
mv -f cmake-3.3.2/* /usr/local/cmake/
# 编辑环境变量配置文件
vim /etc/profile
# 在末尾加上
PATH=/usr/local/cmake/bin:$PATH
export PATH

然后执行: 

# 重新加载系统配置文件
source /etc/profile
# 查看并确认cmake版本信息
cmake --version

安装Git, Nodejs, gcc-c++, ntp, epel 等辅助工具:

yum update -y && yum install git bzip2 gcc-c++ ntp epel-release nodejs -y

安装Golang (go-ethereum是golang编写的):

wget https://storage.googleapis.com/golang/go1.10.2.linux-amd64.tar.gz
tar zxvf go1.10.2.linux-amd64.tar.gz 
mv go /usr/local/
echo "export GOROOT=/usr/local/go" >> /etc/profile 
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
source /etc/profile

下载go-ethereum:
git clone https://github.com/ethereum/go-ethereum.git  
cd go-ethereum/
make all
echo "export PATH=$PATH:/root/go-ethereum/build/bin" >> /etc/profile
source /etc/profile

启动网络时间同步,开启防火墙,打开8087和30303端口(geth用到的端口):

systemctl enable ntpd 
systemctl start ntpd
systemctl start firewalld
firewall-cmd --zone=public --add-port=8087/tcp --permanent
firewall-cmd --zone=public --add-port=30303/tcp --permanent

编写genesiso.json文件:

cd ~
vim genesis.json

{  
  "nonce": "0x0000000000000042",  
  "timestamp": "0x00",  
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",  
  "extraData": "0x00",  
  "gasLimit": "0x80000000",  
  "difficulty": "0x400",  
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",  
  "coinbase": "0x2D356ee3F5b8718d8690AFCD31Fe2CB5E602677e",  
  "alloc": {},  
  "config": {  
    "chainId": 15,  
    "homesteadBlock": 0,  
    "eip155Block": 0,  
    "eip158Block": 0  
  }  
}  

# 创建区块文件夹
mkdir -p /root/ethbase/chain
cd root & geth --datadir "/root/ethbase/chain" init genesis.json
# 输出调试log
geth --dev console 2>> geth_dev_log

然后尝试:

> eth.accounts
"0x3341e796e5d43919287d49a86cb595d74ddea657"
一切ok, 后续就是针对geth的操作了
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值