centos安装单节点geth

centos安装单节点geth

安装g++ gcc

yum install gcc
yum install gcc-c++

下载geth

https://github.com/ethereum/go-ethereum/releases

centos安装单节点geth_第1张图片

安装

解压

tar zxvf go-ethereum-1.9.6.tar.gz

修改名字

mv go-ethereum-1.9.6 go-ethereum

进行编译

cd go-ethereum/
make all

若编译出错
“build/env.sh go run build/ci.go install go: github.com/Azure/[email protected]: Get https://proxy.golang.org/github.com/%21azure/azure-pipeline-go/@v/v0.2.2.mod: dial tcp 172.217.160.81:443: connect: connection refused make: *** [all] Error 1”
可执行命令:
go env -w GOPROXY=https://goproxy.cn

echo "export PATH=$PATH:/root/go-ethereum/build/bin" >> /etc/profile
source /etc/profile

编写创世区块

cd ~
vim genesis.json
{  
  "nonce": "0x0000000000000042",  
  "timestamp": "0x00",  
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",  
  "extraData": "0x00",  
  "gasLimit": "0x80000000",  
  "difficulty": "0x1",  
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",  
  "coinbase": "0x2D356ee3F5b8718d8690AFCD31Fe2CB5E602677e",  
  "alloc": {},  
  "config": {  
    "chainId": 15,  
    "homesteadBlock": 0,  
    "eip155Block": 0,  
    "eip158Block": 0  
  }  
}  

创建区块文件夹

mkdir /root/chain

初始化geth

geth --datadir chain init genesis.json

centos安装单节点geth_第2张图片

启动geth控制台并创建日志文件:

geth --datadir chain console 2>> chain/geth.log

打开新的窗口查看日志文件:

tail -f chain/geth.log

geth控制台操作

创建geth账户密码为123456

personal.newAccount("123456")

启动以太坊开始挖矿(第一次创建可能需要较长时间)

miner.start(1)

停止挖矿

miner.stop()

你可能感兴趣的:(以太坊)