2024/08/07更新
根据官方要求,Solana RPC 节点至少需要 512GB 内存。实际测试下来,在开启 account-index 参数后,v1.18+ 版本节点稳定时需要 330GB 左右内存,偶尔峰值会到 430G(推荐 512G,不然可能会内存溢出),而 v1.17+ 版本则需要近 1TB 内存。
官方推荐机器至少 3 个 NVMe 盘,一个系统盘,一个存账户数据,一个存账本数据。除系统盘外,每个硬盘推荐使用 2T 的存储空间。以下为创建项目目录和挂载磁盘的命令:
mkdir /root/sol
mkdir /root/sol/accounts
mkdir /root/sol/ledger
mkdir /root/sol/bin
# n + e
fdisk /dev/nvme0n1
fdisk /dev/nvme1n1
mkfs -t ext4 /dev/nvme0n1
mkfs -t ext4 /dev/nvme1n1
mount /dev/nvme0n1 /root/sol/ledger
mount /dev/nvme1n1 /root/sol/accounts
vim /etc/fstab
/dev/nvme0n1 /root/sol/ledger ext4 defaults 0 0
/dev/nvme1n1 /root/sol/accounts ext4 defaults 0 0
Solana 节点对 cpu 主频要求较高,推荐使用高频 cpu 并将性能设置为 performance 模式。
apt install linux-tools-common linux-tools-$(uname -r)
cpupower frequency-info
cpupower frequency-set --governor performance
watch "grep 'cpu MHz' /proc/cpuinfo"
# sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
# 使用v1.18+版本,内存占用少
sh -c "$(curl -sSfL https://release.solana.com/v1.18.15/install)"
vim /root/.bashrc
export PATH="/root/.local/share/solana/install/active_release/bin:$PATH"
source /root/.bashrc
solana --version
solana-keygen new -o validator-keypair.json
vim /etc/sysctl.conf
添加如下
# Increase UDP buffer sizes
net.core.rmem_default = 134217728
net.core.rmem_max = 134217728
net.core.wmem_default = 134217728
net.core.wmem_max = 134217728
# Increase memory mapped files limit
vm.max_map_count = 1000000
# Increase number of allowed open file descriptors
fs.nr_open = 1000000
sysctl -p
vim /etc/systemd/system.conf
添加如下
DefaultLimitNOFILE=1000000
systemctl daemon-reload
vim /etc/security/limits.conf
添加如下
# Increase process file descriptor count limit
* - nofile 1000000
ulimit -n 1000000 # 手动设置一下,不然需要重启机器
sudo ufw allow 22
sudo ufw allow 8000:8020/tcp
sudo ufw allow 8000:8020/udp
sudo ufw allow 8899 # http 端口
sudo ufw allow 8900 # websocket 端口
sudo ufw enable
sudo ufw status
vim /root/sol/bin/validator.sh
添加如下
#!/bin/bash
exec solana-validator \
--ledger /root/sol/ledger \
--accounts /root/sol/accounts \
--identity /root/validator-keypair.json \
--known-validator 7Np41oeYqPefeNQEHSv1UDhYrehxin3NStELsSKCT4K2 \
--known-validator GdnSyH3YtwcxFvQrVVJMm1JhTS4QVX7MFsX56uJLUfiZ \
--known-validator DE1bawNcRJB9rVm3buyMVfr8mBEoyyu73NBovf2oXJsJ \
--known-validator CakcnaRDHka2gXyfbEd2d3xsvkJkqsLw2akB3zsN1D2S \
--entrypoint entrypoint.mainnet-beta.solana.com:8001 \
--entrypoint entrypoint2.mainnet-beta.solana.com:8001 \
--entrypoint entrypoint3.mainnet-beta.solana.com:8001 \
--entrypoint entrypoint4.mainnet-beta.solana.com:8001 \
--entrypoint entrypoint5.mainnet-beta.solana.com:8001 \
--expected-genesis-hash 5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d \
--full-rpc-api \
--no-voting \
--private-rpc \
--rpc-port 8899 \
--gossip-port 8001 \
--dynamic-port-range 8000-8020 \
--wal-recovery-mode skip_any_corrupted_record \
--limit-ledger-size \
--account-index program-id \
--account-index spl-token-mint \
--account-index spl-token-owner \
--enable-rpc-transaction-history \
--enable-cpi-and-log-storage \
--init-complete-file /root/init-completed \
--log /root/solana-rpc.log
# 以下参数按需选择添加
# 务必了解每个参数的功能
# --rpc-bind-address 0.0.0.0 \
# --tpu-enable-udp \
# --only-known-rpc \
# --rpc-send-default-max-retries 0 \
# --rpc-send-service-max-retries 0 \
# --rpc-send-retry-ms 2000 \
# --minimal-snapshot-download-speed 1073741824 \
# --maximum-snapshot-download-abort 3 \
# --rpc-send-leader-count 1500 \
# --private-rpc \
# --accounts-index-memory-limit-mb 1024000 \
# --limit-ledger-size 50000000 \
# --minimal-snapshot-download-speed 1073741824 \
chmod +x /root/sol/bin/validator.sh
vim /etc/systemd/system/sol.service
添加如下
[Unit]
Description=Solana Validator
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=root
LimitNOFILE=1000000
LogRateLimitIntervalSec=0
Environment="PATH=/bin:/usr/bin:/root/.local/share/solana/install/active_release/bin"
ExecStart=/root/sol/bin/validator.sh
[Install]
WantedBy=multi-user.target
# 系统服务相关命令
systemctl start sol
systemctl status sol
systemctl stop sol
systemctl restart sol
systemctl daemon-reload
# 查看服务是否正常运行
tail -f /root/solana-rpc.log
journalctl -u sol -f --no-hostname -o cat
ps aux | grep solana-validator
solana-keygen pubkey /root/validator-keypair.json
solana gossip | grep {pubkey}
solana catchup {pubkey}
如果机器配置和网络没问题的话,应该可以看到在慢慢追块。