以太坊全节点搭建
需要运行执行层和共识层两个程序。
Linux
执行层选择Geth,下载:https://geth.ethereum.org/downloads ,本文使用版本:1.14.12-stable-293a300d
共识层选择Prysm,下载:https://github.com/OffchainLabs/prysm/releases ,本文使用版本:v5.2.0/ac1717f1
执行层Geth系统服务配置:
ini
# /etc/systemd/system/geth_full.service
[Unit]
Description=Ethereum geth client
After=syslog.target network.target
[Service]
User=root
Group=root
Type=simple
Environment="https_proxy=" "http_proxy=" "all_proxy="
ExecStart=/usr/local/bin/geth --datadir=/root/.ethereum
KillMode=process
KillSignal=SIGINT
TimeoutStopSec=90
Restart=on-failure
RestartSec=10s
[Install]
WantedBy=multi-user.target
共识层Prysm系统服务配置:
ini
# /etc/systemd/system/beacon_chain_full.service
[Unit]
Description=Ethereum beacon chain
After=syslog.target network.target
[Service]
User=root
Group=root
Type=simple
Environment="https_proxy=" "http_proxy=" "all_proxy="
ExecStart=/usr/local/bin/beacon-chain-v5.2.0-linux-amd64 \
--accept-terms-of-use \
--jwt-secret=/root/.ethereum/geth/jwtsecret \
--checkpoint-sync-url=https://mainnet.checkpoint.sigp.io \
--genesis-beacon-api-url=https://mainnet.checkpoint.sigp.io \
--suggested-fee-recipient=0x11dbF181dD5c075C2abD92Cb9579c4809406b5Be \
--datadir=/root/.eth2
KillMode=process
KillSignal=SIGINT
TimeoutStopSec=90
Restart=on-failure
RestartSec=10s
[Install]
WantedBy=multi-user.target
启动Geth:
bash
# 开机启动
systemctl enable geth_full
# 启动
systemctl start geth_full
# 查看状态
systemctl status geth_full
# 停止
systemctl stop geth_full
# 取消开机启动
systemctl disable geth_full
# 查看日志
journalctl -u geth_full -f
启动Prysm:
bash
# 开机启动
systemctl enable beacon_chain_full
# 启动
systemctl start beacon_chain_full
# 查看状态
systemctl status beacon_chain_full
# 停止
systemctl stop beacon_chain_full
# 取消开机启动
systemctl disable beacon_chain_full
# 查看日志
journalctl -u beacon_chain_full -f
执行层操作:
bash
# 进入 Geth 控制台
/usr/bin/geth attach --datadir=/root/.ethereum
# 查看执行层同步状态
/usr/bin/geth attach --datadir=/root/.ethereum --exec=eth.syncing
共识层操作:
bash
# 查看共识层同步状态
curl http://127.0.0.1:3500/eth/v1/node/syncing
macOS
bash
# 安装 Geth
brew install ethereum
# 查看版本
geth --version
下载:https://github.com/OffchainLabs/prysm/releases/,本文使用版本:`v6.0.0`
执行层Geth系统服务配置/Library/LaunchDaemons/geth.plist
:
xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>geth</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/geth</string>
<string>--datadir=/Volumes/KINGSTON SNV3S2000G/.ethereum</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/var/log/geth.log</string>
<key>StandardErrorPath</key>
<string>/var/log/geth.log</string>
</dict>
</plist>
检查plist语法是否正确:
bash
plutil /Library/LaunchDaemons/geth.plist
共识层Prysm系统服务配置/Library/LaunchDaemons/beacon-chain.plist
:
xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>beacon-chain</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/beacon-chain</string>
<string>--accept-terms-of-use</string>
<string>--jwt-secret=/Volumes/KINGSTON SNV3S2000G/.ethereum/geth/jwtsecret</string>
<string>--checkpoint-sync-url=https://mainnet.checkpoint.sigp.io</string>
<string>--genesis-beacon-api-url=https://mainnet.checkpoint.sigp.io</string>
<string>--suggested-fee-recipient=0x11dbF181dD5c075C2abD92Cb9579c4809406b5Be</string>
<string>--datadir=/Volumes/KINGSTON SNV3S2000G/.eth2</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/var/log/beacon-chain.log</string>
<key>StandardErrorPath</key>
<string>/var/log/beacon-chain.log</string>
</dict>
</plist>
检查plist语法是否正确:
bash
plutil /Library/LaunchDaemons/beacon-chain.plist
启动Geth:
bash
# 开机启动
launchctl load /Library/LaunchDaemons/geth.plist
# 启动服务
launchctl start geth
# 查看状态
launchctl print system/geth
# 停止
launchctl stop geth
# 取消开机启动
launchctl unload /Library/LaunchDaemons/geth.plist
# 查看日志
tail -f /var/log/geth.*
启动Prysm:
bash
# 开机启动
launchctl load /Library/LaunchDaemons/beacon-chain.plist
# 启动服务
launchctl start beacon-chain
# 查看状态
launchctl print system/beacon-chain
# 停止
launchctl stop beacon-chain
# 取消开机启动
launchctl unload /Library/LaunchDaemons/beacon-chain.plist
# 查看日志
tail -f /var/log/beacon-chain.*
执行层操作:
bash
# 进入 Geth 控制台
geth attach --datadir=/Volumes/KINGSTON\ SNV3S2000G/.ethereum
# 查看执行层同步状态
geth attach --datadir=/Volumes/KINGSTON\ SNV3S2000G/.ethereum --exec=eth.syncing
共识层操作:
bash
# 查看共识层同步状态
curl http://127.0.0.1:3500/eth/v1/node/syncing
datadir 在外接硬盘时读写无权限的问题
在设置中要授予二进制文件“完全磁盘访问权限”:
