Skip to content

Eth节点部署

在ubuntu22.04上部署Eth区块链。需要两种客户端,即执行层 (EL) 客户端和共识层 (CL) 客户端。

运行执行客户端

文档: https://docs.nethermind.io/get-started/running-node/

sudo add-apt-repository ppa:nethermindeth/nethermind
sudo apt-get install software-properties-common
sudo apt-get update
sudo apt-get install nethermind -y
sudo wget https://raw.githubusercontent.com/NethermindEth/nethermind/refs/heads/master/src/Nethermind/Nethermind.Runner/configs/mainnet.json
sudo mv mainnet.json /etc/
cd /usr/share/nethermind
screen sudo nethermind -c /etc/mainnet.json

运行共识客户端

文档: https://lighthouse-book.sigmaprime.io/run_a_node.html

wget https://github.com/sigp/lighthouse/releases/download/v5.2.1/lighthouse-v5.2.1-x86_64-unknown-linux-gnu.tar.gz
tar xvzf lighthouse-v5.2.1-x86_64-unknown-linux-gnu.tar.gz
mv lighthouse /usr/local/bin/
sudo chmod +x /usr/local/bin/lighthouse
screen sudo lighthouse bn \
--network mainnet \
--execution-endpoint http://localhost:8551 \
--execution-jwt ~/keystore/jwt-secret \
--checkpoint-sync-url https://mainnet.checkpoint.sigp.io \
--http --http-address 0.0.0.0

查看同步

wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.15.11-36b2371c.tar.gz
tar xvzf geth-linux-amd64-1.15.11-36b2371c.tar.gz
./geth-linux-amd64-1.15.11-36b2371c/geth attach http://127.0.0.1:8545
eth.syncing
eth.blockNumber
exit
echo $(($(curl -s -d '{"id":0,"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false]}' \
-H "Content-Type: application/json" https://eth-rpc.gaojinbo.com/fa33401ffb204164c2d15c5e52ce8035/|jq .result.number|awk -F'"' '{print $2}')))
echo $(($(curl -s -d '{"id":0,"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false]}' \
-H "Content-Type: application/json" http://localhost:8545|jq .result.number|awk -F'"' '{print $2}')))

nginx代理

server {
listen 443 ssl;
server_name eth-rpc.gaojinbo.com;
keepalive_timeout 70;
ssl_certificate ssl/new/eth-rpc.gaojinbo.com.pem;
ssl_certificate_key ssl/new/eth-rpc.gaojinbo.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
#location / {
location ^~/fa33401ffb204164c2d15c5e52ce8035/ {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
#以下代码使支持WebSocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://52.76.65.24:8545/;
}
location / {
return 404;
}
location /123 {
return 200;
}
}

TOP