├── README.md ├── disk.sh ├── get_health.sh ├── openssl1.1.sh ├── optimize-sysctl.sh ├── redo_node.sh ├── restart_node.sh ├── sol.service ├── ufw.sh ├── validator.sh └── yellowstone-config.json /README.md: -------------------------------------------------------------------------------- 1 | # solana-rpc-install 2 | 3 | #### 建议最低配置: 4 | * CPU: AMD Ryzen 9 9950X 5 | * RAM: 128 GB 6 | 7 | #### 挂载磁盘 8 | * 准备至少 3 个 NVMe 盘,一个系统盘,一个存账户数据,一个存账本数据。除系统盘外,每个硬盘推荐使用 2T 的存储空间。 9 | 10 | ### 1. 安装openssl1.1 11 | ```shell 12 | wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb 13 | 14 | sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb 15 | ``` 16 | 17 | ### 2. 创建目录和挂载硬盘命令 18 | ```shell 19 | sudo mkdir -p /root/sol/accounts 20 | sudo mkdir -p /root/sol/ledger 21 | sudo mkdir -p /root/sol/snapshot 22 | 23 | sudo mkfs.ext4 /dev/nvme0n1 24 | sudo mount /dev/nvme0n1 /root/sol/ledger 25 | 26 | sudo mkfs.ext4 /dev/nvme1n1 27 | sudo mount /dev/nvme1n1 /root/sol/accounts 28 | ``` 29 | 30 | ### 3. 修改/etc/fstab配置,设置挂盘盘和关闭swap 31 | ```shell 32 | vim /etc/fstab 33 | 34 | # 增加下面两行 35 | /dev/nvme0n1 /root/sol/ledger ext4 defaults 0 0 36 | /dev/nvme1n1 /root/sol/accounts ext4 defaults 0 0 37 | 38 | # 注释包含 none swap sw 0 0,并wq保存修改 39 | UUID=xxxx-xxxx-xxxx-xxxx none swap sw 0 0 40 | 41 | # 临时关闭swap 42 | sudo swapoff -a 43 | ``` 44 | 45 | ### 4. 将 cpu 设置为 performance 模式 46 | ```shell 47 | apt install linux-tools-common linux-tools-$(uname -r) 48 | 49 | cpupower frequency-info 50 | 51 | cpupower frequency-set --governor performance 52 | 53 | watch "grep 'cpu MHz' /proc/cpuinfo" 54 | ``` 55 | 56 | ### 5. 下载安装solana客户端 57 | ```shell 58 | sh -c "$(curl -sSfL https://release.anza.xyz/v2.1.18/install)" 59 | 60 | vim /root/.bashrc 61 | export PATH="/root/.local/share/solana/install/active_release/bin:$PATH" 62 | source /root/.bashrc 63 | 64 | solana --version 65 | ``` 66 | 67 | ### 6. 创建验证者私钥 68 | ```shell 69 | cd /root/sol/bin 70 | solana-keygen new -o validator-keypair.json 71 | ``` 72 | 73 | ### 7. 系统调优 74 | 75 | #### 修改/etc/sysctl.conf 76 | ```shell 77 | vim /etc/sysctl.conf 78 | # 添加下面的内容 79 | 80 | # TCP Buffer Sizes (10k min, 87.38k default, 12M max) 81 | net.ipv4.tcp_rmem=10240 87380 12582912 82 | net.ipv4.tcp_wmem=10240 87380 12582912 83 | 84 | # TCP Optimization 85 | net.ipv4.tcp_congestion_control=westwood 86 | net.ipv4.tcp_fastopen=3 87 | net.ipv4.tcp_timestamps=0 88 | net.ipv4.tcp_sack=1 89 | net.ipv4.tcp_low_latency=1 90 | net.ipv4.tcp_tw_reuse=1 91 | net.ipv4.tcp_no_metrics_save=1 92 | net.ipv4.tcp_moderate_rcvbuf=1 93 | 94 | # Kernel Optimization 95 | kernel.timer_migration=0 96 | kernel.hung_task_timeout_secs=30 97 | kernel.pid_max=49152 98 | 99 | # Virtual Memory Tuning 100 | vm.swappiness=30 101 | vm.max_map_count=2000000 102 | vm.stat_interval=10 103 | vm.dirty_ratio=40 104 | vm.dirty_background_ratio=10 105 | vm.min_free_kbytes=3000000 106 | vm.dirty_expire_centisecs=36000 107 | vm.dirty_writeback_centisecs=3000 108 | vm.dirtytime_expire_seconds=43200 109 | 110 | # Solana Specific Tuning 111 | net.core.rmem_max=134217728 112 | net.core.rmem_default=134217728 113 | net.core.wmem_max=134217728 114 | net.core.wmem_default=134217728 115 | 116 | # Increase number of allowed open file descriptors 117 | fs.nr_open = 1000000 118 | ``` 119 | 120 | ```shell 121 | # 重新加载配置生效 122 | sysctl -p 123 | ``` 124 | 125 | #### 修改/etc/systemd/system.conf 126 | ```shell 127 | vim /etc/systemd/system.conf 128 | # 添加下面的内容 129 | 130 | DefaultLimitNOFILE=1000000 131 | 132 | 133 | # 重新加载配置 134 | systemctl daemon-reload 135 | ``` 136 | 137 | #### 修改/etc/security/limits.conf 138 | ```shell 139 | vim /etc/security/limits.conf 140 | # 添加下面的内容 141 | 142 | # Increase process file descriptor count limit 143 | * - nofile 1000000 144 | 145 | # 手动设置一下,不然需要重启机器 146 | ulimit -n 1000000 147 | ``` 148 | 149 | ### 8. 开启防火墙 150 | ```shell 151 | sudo ufw enable 152 | 153 | sudo ufw allow 22 154 | sudo ufw allow 8000:8020/tcp 155 | sudo ufw allow 8000:8020/udp 156 | sudo ufw allow 8899 # http 端口 157 | sudo ufw allow 8900 # websocket 端口 158 | sudo ufw allow 10900 # GRPC 端口 159 | 160 | sudo ufw status 161 | ``` 162 | 163 | ### 9. 创建启动脚本和服务 164 | ```shell 165 | vim /root/sol/bin/validator.sh 166 | # 添加下面的内容 167 | 168 | ##!/bin/bash 169 | 170 | RUST_LOG=warn agave-validator \ 171 | --geyser-plugin-config /root/sol/bin/yellowstone-config.json \ 172 | --ledger /root/sol/ledger \ 173 | --accounts /root/sol/accounts \ 174 | --identity /root/sol/bin/validator-keypair.json \ 175 | --snapshots /root/sol/snapshot \ 176 | --log /root/solana-rpc.log \ 177 | --entrypoint entrypoint.mainnet-beta.solana.com:8001 \ 178 | --entrypoint entrypoint2.mainnet-beta.solana.com:8001 \ 179 | --entrypoint entrypoint3.mainnet-beta.solana.com:8001 \ 180 | --entrypoint entrypoint4.mainnet-beta.solana.com:8001 \ 181 | --entrypoint entrypoint5.mainnet-beta.solana.com:8001 \ 182 | --known-validator Certusm1sa411sMpV9FPqU5dXAYhmmhygvxJ23S6hJ24 \ 183 | --known-validator 7Np41oeYqPefeNQEHSv1UDhYrehxin3NStELsSKCT4K2 \ 184 | --known-validator GdnSyH3YtwcxFvQrVVJMm1JhTS4QVX7MFsX56uJLUfiZ \ 185 | --known-validator CakcnaRDHka2gXyfbEd2d3xsvkJkqsLw2akB3zsN1D2S \ 186 | --known-validator DE1bawNcRJB9rVm3buyMVfr8mBEoyyu73NBovf2oXJsJ \ 187 | --known-validator CakcnaRDHka2gXyfbEd2d3xsvkJkqsLw2akB3zsN1D2S \ 188 | --expected-genesis-hash 5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d \ 189 | --only-known-rpc \ 190 | --disable-banking-trace \ 191 | --rpc-bind-address 0.0.0.0 \ 192 | --rpc-port 8899 \ 193 | --full-rpc-api \ 194 | --private-rpc \ 195 | --no-voting \ 196 | --dynamic-port-range 8000-8020 \ 197 | --enable-rpc-transaction-history \ 198 | --enable-cpi-and-log-storage \ 199 | --wal-recovery-mode skip_any_corrupted_record \ 200 | --limit-ledger-size 60000000 \ 201 | --no-port-check \ 202 | --no-snapshot-fetch \ 203 | --account-index-include-key AddressLookupTab1e1111111111111111111111111 \ 204 | --account-index program-id \ 205 | --rpc-bigtable-timeout 300 \ 206 | --full-snapshot-interval-slots 1577880000 \ 207 | --incremental-snapshot-interval-slots 788940000 \ 208 | --incremental-snapshot-archive-path /root/sol/snapshot 209 | 210 | chmod +x /root/sol/bin/validator.sh 211 | ``` 212 | 213 | #### 新增 /etc/systemd/system/sol.service 214 | ```shell 215 | vim /etc/systemd/system/sol.service 216 | # 添加下面的内容 217 | 218 | [Unit] 219 | Description=Solana Validator 220 | After=network.target 221 | StartLimitIntervalSec=0 222 | 223 | [Service] 224 | Type=simple 225 | Restart=always 226 | RestartSec=1 227 | User=root 228 | LimitNOFILE=1000000 229 | LogRateLimitIntervalSec=0 230 | Environment="PATH=/bin:/usr/bin:/root/.local/share/solana/install/active_release/bin" 231 | ExecStart=/root/sol/bin/validator.sh 232 | 233 | [Install] 234 | WantedBy=multi-user.target 235 | ``` 236 | 237 | ### 10. 配置GRPC 238 | ```shell 239 | # 安装解压缩包工具 240 | sudo apt-get install bzip2 241 | 242 | # 进入bin目录 243 | cd /root/sol/bin 244 | 245 | # 下载yellowstone-grpc压缩包 246 | sudo wget https://github.com/rpcpool/yellowstone-grpc/releases/download/v5.0.1%2Bsolana.2.1.16/yellowstone-grpc-geyser-release-x86_64-unknown-linux-gnu.tar.bz2 247 | 248 | # 解压缩包 249 | tar -xvjf yellowstone-grpc-geyser-release-x86_64-unknown-linux-gnu.tar.bz2 250 | 251 | # 下载yellowstone-config.json配置文件, 这里面配置的GRPC端口号是: 10900 252 | sudo wget https://github.com/0xfnzero/solana-rpc-install/releases/download/v1.1/yellowstone-config.json 253 | ``` 254 | 255 | ### 11. 用脚本启动RPC节点 256 | ```shell 257 | # 进入root目录 258 | cd /root 259 | 260 | # 下载重做节点脚本 261 | sudo wget https://github.com/0xfnzero/solana-rpc-install/releases/download/v1.1/redo_node.sh 262 | 263 | # 赋予脚本可执行权限 264 | sudo chmod +x redo_node.sh 265 | 266 | # 执行脚本,会自动下载快照,下载完成后启动RPC节点 267 | sudo ./redo_node.sh 268 | 269 | # 上面步骤执行完后, 通过下面命令可查看节点状态(需等待一些时间,大概1-2小时) 270 | curl -X POST -H "Content-Type: application/json" \ 271 | -d '{"jsonrpc":"2.0", "id":1, "method":"getHealth"}' \ 272 | http://127.0.0.1:8899 273 | ``` 274 | 275 | ### 12. 相关命令 276 | ```shell 277 | # 系统服务相关命令 278 | systemctl start sol 279 | systemctl status sol 280 | systemctl stop sol 281 | systemctl restart sol 282 | systemctl daemon-reload 283 | 284 | # 查看服务是否正常运行 285 | tail -f /root/solana-rpc.log 286 | journalctl -u sol -f --no-hostname -o cat 287 | ps aux | grep solana-validator 288 | 289 | # 查看同步进度 290 | solana-keygen pubkey /root/sol/bin/validator-keypair.json 291 | solana gossip | grep {pubkey} 292 | solana catchup {pubkey} 293 | ``` 294 | 295 | #### Telegram group: 296 | https://t.me/fnzero_group 297 | -------------------------------------------------------------------------------- /disk.sh: -------------------------------------------------------------------------------- 1 | sudo mkdir -p /root/sol/accounts 2 | sudo mkdir -p /root/sol/ledger 3 | sudo mkdir -p /root/sol/snapshot 4 | 5 | sudo mkfs.ext4 /dev/nvme0n1 6 | sudo mount /dev/nvme0n1 /root/sol/ledger 7 | 8 | sudo mkfs.ext4 /dev/nvme1n1 9 | sudo mount /dev/nvme1n1 /root/sol/accounts 10 | -------------------------------------------------------------------------------- /get_health.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | curl -X POST -H "Content-Type: application/json" \ 4 | -d '{"jsonrpc":"2.0", "id":1, "method":"getHealth"}' \ 5 | http://127.0.0.1:8899 -------------------------------------------------------------------------------- /openssl1.1.sh: -------------------------------------------------------------------------------- 1 | wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb 2 | 3 | sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb -------------------------------------------------------------------------------- /optimize-sysctl.sh: -------------------------------------------------------------------------------- 1 | # /etc/sysctl.conf 2 | 3 | # TCP Buffer Sizes (10k min, 87.38k default, 12M max) 4 | net.ipv4.tcp_rmem=10240 87380 12582912 5 | net.ipv4.tcp_wmem=10240 87380 12582912 6 | 7 | # TCP Optimization 8 | net.ipv4.tcp_congestion_control=westwood 9 | net.ipv4.tcp_fastopen=3 10 | net.ipv4.tcp_timestamps=0 11 | net.ipv4.tcp_sack=1 12 | net.ipv4.tcp_low_latency=1 13 | net.ipv4.tcp_tw_reuse=1 14 | net.ipv4.tcp_no_metrics_save=1 15 | net.ipv4.tcp_moderate_rcvbuf=1 16 | 17 | # Kernel Optimization 18 | kernel.timer_migration=0 19 | kernel.hung_task_timeout_secs=30 20 | kernel.pid_max=49152 21 | 22 | # Virtual Memory Tuning 23 | vm.swappiness=30 24 | vm.max_map_count=2000000 25 | vm.stat_interval=10 26 | vm.dirty_ratio=40 27 | vm.dirty_background_ratio=10 28 | vm.min_free_kbytes=3000000 29 | vm.dirty_expire_centisecs=36000 30 | vm.dirty_writeback_centisecs=3000 31 | vm.dirtytime_expire_seconds=43200 32 | 33 | # Solana Specific Tuning 34 | net.core.rmem_max=134217728 35 | net.core.rmem_default=134217728 36 | net.core.wmem_max=134217728 37 | net.core.wmem_default=134217728 -------------------------------------------------------------------------------- /redo_node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e # 遇到错误就退出 4 | 5 | # 停止 sol 服务 6 | echo "Stopping sol service..." 7 | systemctl stop sol 8 | 9 | rm -rf solana-rpc.log 10 | 11 | # 定义要清空的目录列表 12 | dirs=( 13 | "/root/sol/ledger" 14 | "/root/sol/accounts" 15 | "/root/sol/snapshot" 16 | ) 17 | 18 | # 清空目录内容但保留目录 19 | for dir in "${dirs[@]}"; do 20 | if [ -d "$dir" ]; then 21 | echo "Cleaning directory: $dir" 22 | rm -rf "$dir"/* "$dir"/.[!.]* "$dir"/..?* || true 23 | else 24 | echo "Directory does not exist: $dir (skipping)" 25 | fi 26 | done 27 | 28 | # 安装依赖 29 | echo "Updating packages and installing dependencies..." 30 | sudo apt-get update 31 | sudo apt-get install -y python3-venv git 32 | 33 | # 克隆或更新 solana-snapshot-finder 仓库 34 | if [ ! -d "solana-snapshot-finder" ]; then 35 | echo "Cloning solana-snapshot-finder repository..." 36 | git clone https://github.com/c29r3/solana-snapshot-finder.git 37 | else 38 | echo "Repository solana-snapshot-finder already exists, pulling latest changes..." 39 | cd solana-snapshot-finder 40 | git pull 41 | cd .. 42 | fi 43 | 44 | # 进入目录并创建虚拟环境 45 | cd solana-snapshot-finder 46 | if [ ! -d "venv" ]; then 47 | echo "Creating Python virtual environment..." 48 | python3 -m venv venv 49 | fi 50 | 51 | echo "Activating virtual environment and installing Python dependencies..." 52 | source ./venv/bin/activate 53 | pip3 install --upgrade pip 54 | pip3 install -r requirements.txt 55 | 56 | # 运行 snapshot finder 57 | echo "Running snapshot-finder..." 58 | python3 snapshot-finder.py --snapshot_path /root/sol/snapshot 59 | 60 | # 重启 sol 服务 61 | echo "Starting sol service..." 62 | systemctl start sol 63 | 64 | echo "Script completed successfully." -------------------------------------------------------------------------------- /restart_node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo systemctl stop sol 4 | sudo rm -rf /root/sol/snapshot/* 5 | sudo find /root/sol/ledger/ -mindepth 1 -not -name 'contact-info.bin' -delete 6 | cd /root/sol/snapshot && aria2c -x16 -s16 --force-sequential=true https://snapshots.avorio.network/mainnet-beta/snapshot.tar.bz2 https://snapshots.avorio.network/mainnet-beta/incremental-snapshot.tar.bz2 7 | sudo systemctl start sol -------------------------------------------------------------------------------- /sol.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Solana Validator 3 | After=network.target 4 | StartLimitIntervalSec=0 5 | 6 | [Service] 7 | Type=simple 8 | Restart=always 9 | RestartSec=1 10 | User=root 11 | LimitNOFILE=1000000 12 | LogRateLimitIntervalSec=0 13 | Environment="PATH=/bin:/usr/bin:/root/.local/share/solana/install/active_release/bin" 14 | ExecStart=/root/sol/bin/validator.sh 15 | 16 | [Install] 17 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /ufw.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e # 脚本有报错就终止 4 | 5 | # 开启 UFW(如果没启用) 6 | ufw enable 7 | 8 | sudo ufw allow 22 9 | sudo ufw allow 8000:8020/tcp 10 | sudo ufw allow 8000:8020/udp 11 | sudo ufw allow 8899 # http 端口 12 | sudo ufw allow 8900 # websocket 端口 -------------------------------------------------------------------------------- /validator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RUST_LOG=warn agave-validator \ 4 | --geyser-plugin-config /root/sol/bin/yellowstone-config.json \ 5 | --ledger /root/sol/ledger \ 6 | --accounts /root/sol/accounts \ 7 | --identity /root/sol/bin/validator-keypair.json \ 8 | --snapshots /root/sol/snapshot \ 9 | --log /root/solana-rpc.log \ 10 | --entrypoint entrypoint.mainnet-beta.solana.com:8001 \ 11 | --entrypoint entrypoint2.mainnet-beta.solana.com:8001 \ 12 | --entrypoint entrypoint3.mainnet-beta.solana.com:8001 \ 13 | --entrypoint entrypoint4.mainnet-beta.solana.com:8001 \ 14 | --entrypoint entrypoint5.mainnet-beta.solana.com:8001 \ 15 | --known-validator Certusm1sa411sMpV9FPqU5dXAYhmmhygvxJ23S6hJ24 \ 16 | --known-validator 7Np41oeYqPefeNQEHSv1UDhYrehxin3NStELsSKCT4K2 \ 17 | --known-validator GdnSyH3YtwcxFvQrVVJMm1JhTS4QVX7MFsX56uJLUfiZ \ 18 | --known-validator CakcnaRDHka2gXyfbEd2d3xsvkJkqsLw2akB3zsN1D2S \ 19 | --known-validator DE1bawNcRJB9rVm3buyMVfr8mBEoyyu73NBovf2oXJsJ \ 20 | --known-validator CakcnaRDHka2gXyfbEd2d3xsvkJkqsLw2akB3zsN1D2S \ 21 | --expected-genesis-hash 5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d \ 22 | --only-known-rpc \ 23 | --disable-banking-trace \ 24 | --rpc-bind-address 0.0.0.0 \ 25 | --rpc-port 8899 \ 26 | --full-rpc-api \ 27 | --private-rpc \ 28 | --no-voting \ 29 | --dynamic-port-range 8000-8020 \ 30 | --enable-rpc-transaction-history \ 31 | --enable-cpi-and-log-storage \ 32 | --wal-recovery-mode skip_any_corrupted_record \ 33 | --limit-ledger-size 60000000 \ 34 | --no-port-check \ 35 | --no-snapshot-fetch \ 36 | --account-index-include-key AddressLookupTab1e1111111111111111111111111 \ 37 | --account-index program-id \ 38 | --rpc-bigtable-timeout 300 \ 39 | --full-snapshot-interval-slots 1577880000 \ 40 | --incremental-snapshot-interval-slots 788940000 \ 41 | --incremental-snapshot-archive-path /root/sol/snapshot -------------------------------------------------------------------------------- /yellowstone-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "libpath": "/root/sol/bin/yellowstone-grpc-geyser-release/lib/libyellowstone_grpc_geyser.so", 3 | "log": { 4 | "level": "info" 5 | }, 6 | "grpc": { 7 | "address": "0.0.0.0:10900", 8 | "compression": { 9 | "accept": ["gzip", "zstd"], 10 | "send": ["gzip", "zstd"] 11 | }, 12 | "max_decoding_message_size": "8_388_608", 13 | "snapshot_plugin_channel_capacity": null, 14 | "snapshot_client_channel_capacity": "50_000_000", 15 | "channel_capacity": "200_000", 16 | "unary_concurrency_limit": 1000, 17 | "unary_disabled": false, 18 | "filters": { 19 | "accounts": { 20 | "max": 100, 21 | "any": false, 22 | "account_max": 100, 23 | "account_reject": [ 24 | "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" 25 | ], 26 | "owner_max": 10, 27 | "owner_reject": [ 28 | "11111111111111111111111111111111" 29 | ] 30 | }, 31 | "slots": { 32 | "max": 1 33 | }, 34 | "transactions": { 35 | "max": 100, 36 | "any": false, 37 | "account_include_max": 100, 38 | "account_include_reject": [ 39 | "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" 40 | ], 41 | "account_exclude_max": 100, 42 | "account_required_max": 100 43 | }, 44 | "transactions_status": { 45 | "max": 100, 46 | "any": false, 47 | "account_include_max": 100, 48 | "account_include_reject": [ 49 | "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" 50 | ], 51 | "account_exclude_max": 100, 52 | "account_required_max": 100 53 | }, 54 | "blocks": { 55 | "max": 1, 56 | "account_include_max": 100, 57 | "account_include_any": false, 58 | "account_include_reject": [ 59 | "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" 60 | ], 61 | "include_transactions": true, 62 | "include_accounts": false, 63 | "include_entries": false 64 | }, 65 | "blocks_meta": { 66 | "max": 1 67 | }, 68 | "entries": { 69 | "max": 1 70 | } 71 | } 72 | } 73 | } --------------------------------------------------------------------------------