CentOS7下安装Geth


1、首先查看cmake的版本:cmake --version,需要3.3以上

安装cmake的方法:

先移除原有版本:

yum remove cmake

下载安装:一步步的执行就好。

cd /usr/local/src
wget https://cmake.org/files/v3.19/cmake-3.19.3.tar.gz
tar zxvf cmake-3.19.3.tar.gz
cd cmake-3.19.3
./configure
make 
make install

这个时候再用cmake --version查看一下版本号,就是刚安装的最新的了。

 

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

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

3、安装golang,Geth使用Golang编译的,所以需要安装Golang。

wget https://studygolang.com/dl/golang/go1.15.7.linux-amd64.tar.gz

tar zxvf go1.15.7.linux-amd64.tar.gz

vim ~/.bash_profile 添加 export PATH=$PATH:/usr/local/src/go/bin保存

source ~/.bash_profile

查看版本:go version

4、下载go-ethereum

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

5、如果在make all的时候报下面的错,请执行:mv /usr/local/include/iconv.h /usr/local/include/iconv.h.back

 

 

 6、加到环境变量:

echo "export PATH=$PATH:/usr/local/src/go-ethereum/build/bin" >> /etc/profile

source /etc/profile

7、完成

 

 

 

 

8、创建初始块

mkdir -p /usr/local/src/go-ethereum/chain

vim genesis.json 代码如下:

{
  "config": {
    "chainId": 888,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block": 0,
    "eip158Block": 0
  },
  "alloc": {
    "dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": {
        "balance": "1606938044258990275541962092341162602522202993782792835301376"
    },
    "e6716f9544a56c530d868e4bfbacb172315bdead": {
        "balance": "1606938044258990275541962092341162602522202993782792835301376"
    }
  },
  "nonce": "0x000000000000002a",
  "difficulty": "0x020000",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x",
  "gasLimit": "0x2fefd8"
}

初始化:geth --datadir data0 init genesis.json

9、制作启动私有链脚本:

vim start.sh

geth --nodiscover --datadir data0 --networkid 4224 --rpc --rpcport 8545 --port 30300 --rpccorsdomain "*" -rpcapi eth,web3,personal,net,db console 2> log.txt

如图所示,启动完成:

 

 

接下来我们搭建浏览器


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM