CentOS 7 安装以太坊(Etherum)Geth尝试挖矿
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
本地私有链尝试以太坊挖矿功能
参考
虚拟机环境
2C4G20G,CentOS Linux release 7.4.1708 (Core)
安装所需基础工具:
yum update -y && yum install git wget bzip2 vim gcc-c++ ntp epel-release nodejs cmake -y
安装Go
wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.10.linux-amd64.tar.gz
echo 'export GOROOT=/usr/local/go' >> /etc/profile
echo 'export PATH=$PATH:$GOROOT/bin' >> /etc/profile
echo 'export GOPATH=/root/go' >> /etc/profile
echo 'export PATH=$PATH:$GOPATH/bin' >> /etc/profile
source /etc/profile
验证
$ go version
go version go1.10 linux/amd64
克隆编译项目go-ethereum
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum
make all
在path中加入geth路径
echo 'export PATH=$PATH:/opt/go-ethereum/build/bin' >> /etc/profile
source /etc/profile
验证
$ geth version
Geth
Version: 1.8.2-unstable
Git Commit: bd6879ac518431174a490ba42f7e6e822dcb3ee1
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.10
Operating System: linux
GOPATH=/root/go
GOROOT=/usr/local/go
配置私有链初始状态,新建文件genesis.json
{
"config": {
"chainId": 22,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x400",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000038",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}
初始化区块链,生成创世区块和初始状态
geth --datadir /opt/data init /opt/eth/genesis.json
启动节点,进入Geth的cli界面挖矿
geth --identity "TestNode" --rpc --rpcport "8545" --datadir /opt/data/ --port "30303" --nodiscover console
mine.start()总是null,挖不到,于是清空数据换一种方式启动节点,进入Geth的cli界面并直接开始挖矿
geth --identity "TestNode" --rpc --rpcport "8545" --datadir /opt/data/ --port "30303" --nodiscover --dev --dev.period 1 console
加了两个参数:--dev 表示自动创建一个账户并直接开始挖矿,--dev.period 1表示不用等有交易了才挖,如果设成0的话没有交易挖矿就是null
查看账号
personal.listAccounts
[]
新建账号,密码123456
personal.newAccount(“123456”)
"0x7d84a2638c9b25a758026446e67c822f34247bd8"
查看cionbase
eth.coinbase
"0x7d84a2638c9b25a758026446e67c822f34247bd8"
查看区块数量
eth.blockNumber
19
查看账号余额
myAddress = "0x7d84a2638c9b25a758026446e67c822f34247bd8"
"0x480086c9411cc3297c4aa6773a2e07c7b1efbafe"
eth.getBalance("0x7d84a2638c9b25a758026446e67c822f34247bd8")
1.15792089237316195423570985008687907853269984665640564039457584007913129639927e+77
换另一个用户挖矿
miner.setEtherbase("0x3e5b31e581546f2900c0f3289153c788c92a2b41")
报错
WARN [03-05|23:08:47] Block sealing failed err="authentication needed: password or unlock"
解锁挖矿用户
personal.unlockAccount(eth.coinbase)
再更换挖矿用户挖,又报错
WARN [03-05|23:18:48] Block sealing failed err=unauthorized
再用谁挖都是null,暂时不试了,再继续深入学习。
GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献2条内容
所有评论(0)