名称: 节点运维 描述: 区块链节点部署与运维。支持以太坊执行层和共识层客户端、验证器操作、节点监控、MEV-Boost配置和归档节点管理。 允许工具: 读取, 搜索, 写入, Bash, 编辑, 全局匹配, 网络获取
区块链节点运维技能
以太坊及EVM兼容网络的专家级区块链节点部署与运维。
能力范围
- 执行层客户端: 部署Geth、Nethermind、Besu、Erigon
- 共识层客户端: 配置Prysm、Lighthouse、Teku、Lodestar
- 验证器操作: 设置验证器并管理密钥
- 监控: 监控同步状态和性能
- MEV-Boost: 为验证器配置MEV-Boost
- 归档节点: 设置用于索引的归档节点
- 迁移: 处理节点升级和迁移
执行层客户端设置
Geth安装
# 安装Geth
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
# 或下载二进制文件
wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.13.0-xxx.tar.gz
tar -xvf geth-linux-amd64-*.tar.gz
sudo mv geth-linux-amd64-*/geth /usr/local/bin/
Geth配置
# 创建数据目录
mkdir -p /var/lib/geth
# 创建服务文件
cat > /etc/systemd/system/geth.service << EOF
[Unit]
Description=Geth执行层客户端
After=network.target
Wants=network.target
[Service]
User=geth
Group=geth
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/geth \
--mainnet \
--datadir /var/lib/geth \
--http \
--http.addr 0.0.0.0 \
--http.port 8545 \
--http.api eth,net,web3,engine,admin \
--ws \
--ws.addr 0.0.0.0 \
--ws.port 8546 \
--authrpc.addr localhost \
--authrpc.port 8551 \
--authrpc.vhosts localhost \
--authrpc.jwtsecret /var/lib/geth/jwt.hex \
--metrics \
--metrics.addr 0.0.0.0 \
--metrics.port 6060 \
--syncmode snap \
--maxpeers 50
[Install]
WantedBy=multi-user.target
EOF
# 生成JWT密钥
openssl rand -hex 32 > /var/lib/geth/jwt.hex
# 启动服务
sudo systemctl daemon-reload
sudo systemctl enable geth
sudo systemctl start geth
Nethermind配置
cat > /etc/systemd/system/nethermind.service << EOF
[Unit]
Description=Nethermind执行层客户端
After=network.target
[Service]
User=nethermind
Type=simple
Restart=always
ExecStart=/usr/local/bin/nethermind \
--config mainnet \
--datadir /var/lib/nethermind \
--JsonRpc.Enabled true \
--JsonRpc.Host 0.0.0.0 \
--JsonRpc.Port 8545 \
--JsonRpc.JwtSecretFile /var/lib/nethermind/jwt.hex \
--JsonRpc.EngineHost 127.0.0.1 \
--JsonRpc.EnginePort 8551 \
--Metrics.Enabled true \
--Metrics.ExposePort 6060 \
--Sync.SnapSync true
[Install]
WantedBy=multi-user.target
EOF
共识层客户端设置
Lighthouse
# 安装Lighthouse
curl -LO https://github.com/sigp/lighthouse/releases/download/v4.5.0/lighthouse-v4.5.0-x86_64-unknown-linux-gnu.tar.gz
tar -xvf lighthouse-*.tar.gz
sudo mv lighthouse /usr/local/bin/
# 信标节点服务
cat > /etc/systemd/system/lighthouse-beacon.service << EOF
[Unit]
Description=Lighthouse信标节点
After=network.target geth.service
Wants=geth.service
[Service]
User=lighthouse
Type=simple
Restart=always
ExecStart=/usr/local/bin/lighthouse bn \
--network mainnet \
--datadir /var/lib/lighthouse \
--execution-endpoint http://localhost:8551 \
--execution-jwt /var/lib/geth/jwt.hex \
--checkpoint-sync-url https://beaconstate.ethstaker.cc \
--http \
--http-address 0.0.0.0 \
--http-port 5052 \
--metrics \
--metrics-address 0.0.0.0 \
--metrics-port 5054
[Install]
WantedBy=multi-user.target
EOF
Prysm
# 安装Prysm
curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh
chmod +x prysm.sh
# 信标节点服务
cat > /etc/systemd/system/prysm-beacon.service << EOF
[Unit]
Description=Prysm信标节点
After=network.target
[Service]
User=prysm
Type=simple
Restart=always
ExecStart=/usr/local/bin/prysm.sh beacon-chain \
--mainnet \
--datadir=/var/lib/prysm \
--execution-endpoint=http://localhost:8551 \
--jwt-secret=/var/lib/geth/jwt.hex \
--checkpoint-sync-url=https://beaconstate.ethstaker.cc \
--genesis-beacon-api-url=https://beaconstate.ethstaker.cc \
--grpc-gateway-host=0.0.0.0 \
--grpc-gateway-port=3500 \
--monitoring-host=0.0.0.0 \
--monitoring-port=8080
[Install]
WantedBy=multi-user.target
EOF
验证器设置
密钥生成
# 安装存款命令行工具
wget https://github.com/ethereum/staking-deposit-cli/releases/download/v2.7.0/staking_deposit-cli-fdab65d-linux-amd64.tar.gz
tar -xvf staking_deposit-cli-*.tar.gz
# 生成验证器密钥
./deposit new-mnemonic --num_validators 1 --chain mainnet
# 导入密钥到Lighthouse
lighthouse account validator import \
--network mainnet \
--datadir /var/lib/lighthouse \
--directory validator_keys
# 导入密钥到Prysm
./prysm.sh validator accounts import \
--mainnet \
--keys-dir=validator_keys
验证器客户端
# Lighthouse验证器服务
cat > /etc/systemd/system/lighthouse-validator.service << EOF
[Unit]
Description=Lighthouse验证器
After=lighthouse-beacon.service
Wants=lighthouse-beacon.service
[Service]
User=lighthouse
Type=simple
Restart=always
ExecStart=/usr/local/bin/lighthouse vc \
--network mainnet \
--datadir /var/lib/lighthouse \
--beacon-nodes http://localhost:5052 \
--graffiti "我的验证器" \
--metrics \
--metrics-address 0.0.0.0 \
--metrics-port 5064 \
--suggested-fee-recipient 0x您的地址
[Install]
WantedBy=multi-user.target
EOF
MEV-Boost设置
# 安装MEV-Boost
go install github.com/flashbots/mev-boost@latest
# MEV-Boost服务
cat > /etc/systemd/system/mev-boost.service << EOF
[Unit]
Description=MEV-Boost
After=network.target
[Service]
User=mevboost
Type=simple
Restart=always
ExecStart=/usr/local/bin/mev-boost \
-mainnet \
-relay-check \
-relay https://0xac6e77dfe25ecd6110b8e780608cce0dab71fdd5ebea22a16c0205200f2f8e2e3ad3b71d3499c54ad14d6c21b41a37ae@boost-relay.flashbots.net \
-relay https://0xa1559ace749633b997cb3fdacffb890aeebdb0f5a3b6aaa7eeeaf1a38af0a8fe88b9e4b1f61f236d2e64d95733327a62@relay.ultrasound.money
[Install]
WantedBy=multi-user.target
EOF
监控
Prometheus配置
# prometheus.yml
scrape_configs:
- job_name: 'geth'
static_configs:
- targets: ['localhost:6060']
- job_name: 'lighthouse_beacon'
static_configs:
- targets: ['localhost:5054']
- job_name: 'lighthouse_validator'
static_configs:
- targets: ['localhost:5064']
实用监控命令
# 检查Geth同步状态
geth attach http://localhost:8545 --exec "eth.syncing"
# 检查Lighthouse同步状态
curl -s http://localhost:5052/eth/v1/node/syncing | jq
# 检查验证器状态
curl -s http://localhost:5052/eth/v1/beacon/states/head/validators/0x... | jq
# 检查对等节点数量
geth attach --exec "admin.peers.length"
curl -s http://localhost:5052/eth/v1/node/peers | jq '.data | length'
归档节点配置
# Geth归档模式
ExecStart=/usr/local/bin/geth \
--mainnet \
--datadir /var/lib/geth \
--gcmode archive \
--syncmode full \
# ... 其他参数
# Erigon (为归档优化)
ExecStart=/usr/local/bin/erigon \
--datadir /var/lib/erigon \
--chain mainnet \
--prune=htc \
# ... 其他参数
流程集成
| 流程 | 用途 |
|---|---|
blockchain-node-setup.js |
节点部署 |
validator-node-operation.js |
验证器设置 |
blockchain-indexer-development.js |
索引基础设施 |
最佳实践
- 使用检查点同步以加速初始同步
- 监控磁盘空间 (归档节点需要TB级)
- 设置错过证明的警报
- 保持客户端更新
- 为执行层和共识层使用独立机器
- 安全备份验证器密钥
相关参考
agents/blockchain-infra/AGENT.md- 基础设施专家- Ethereum.org质押
- EthStaker