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