• Pricing
  • Enterprise
  • Customers
  • Blog

How to run a Solana RPC node

The manual setup instructions in this article are not maintained for accuracy. Your best option to get a running node in seconds is to deploy one with Chainstack.

Introduction

The easiest way to run a Solana RPC node is with Chainstack:

  1. Sign up with Chainstack.
  2. Deploy a Solana RPC node.
  3. Get the deployed node’s endpoint.

That said, this post provides you with the step-by-step instructions on running a non-validating Solana RPC node and connecting it to the mainnet beta cluster.

This tutorial uses the Agave node client by Anza. See Agave documentation.

RPC node hardware requirements

ComponentRequirement
CPU– 2.8GHz base clock speed or faster
– 16 cores / 32 threads minimum
– SHA extensions instruction support
– AMD Gen 3 or newer
– Intel Ice Lake or newer
– AVX2 instruction support
– AVX512f support is helpful
– Higher clock speed preferred over more cores
RAM– 512 GB or more for all account indexes
– Error Correction Code (ECC) memory recommended
– Motherboard with 512GB capacity suggested
Disk– PCIe Gen3 x4 NVME SSD or better for each storage component:
  • Accounts: 1TB+ with high TBW (Total Bytes Written)
  • Ledger: 1TB+ with high TBW (consider larger for longer transaction history)
  • Snapshots: 500GB+ with high TBW
  • OS: 500GB+ (SATA acceptable)
Important: Accounts and ledger should NOT be stored on the same disk
– Samsung 970/980 Pro series SSDs recommended

See also the community maintained Solana hardware compatibility list.

1. Prepare and mount disks

Remember to make sure each of the two mounted disks is 1TB+ in size.

We will store our data in /var/solana on two different mounted disks:

  • disk #1 for ledger and config — /var/solana/data
  • disk #2 for accounts — /var/solana/accounts

Partition the NVMe disks:

root@solana-node-01:~# sgdisk -Z --new=1:2048:0 --typecode=1:8300 /dev/nvme1n1
root@solana-node-01:~# sgdisk -Z --new=1:2048:0 --typecode=1:8300 /dev/nvme2n1

Refresh the partition table:

root@solana-node-01:~# partprobe /dev/nvme1n1
root@solana-node-01:~# partprobe /dev/nvme2n1

Format the new partitions with XFS:

root@solana-node-01:~# mkfs.xfs /dev/nvme1n1p1
root@solana-node-01:~# mkfs.xfs /dev/nvme2n1p1

Label the filesystems:

root@solana-node-01:~# xfs_admin -L disk1 /dev/nvme1n1p1
root@solana-node-01:~# xfs_admin -L disk2 /dev/nvme2n1p1

Update /etc/fstab with labels:

root@solana-node-01:~# sudo bash -c 'cat >> /etc/fstab <<EOF
LABEL=disk1 /var/solana/data xfs defaults 0 0
LABEL=disk2 /var/solana/accounts xfs defaults 0 0
EOF'

Mount the filesystems:

root@solana-node-01:~# mount /var/solana/data
root@solana-node-01:~# mount /var/solana/accounts
root@solana-node-01:~# mkdir -p /var/solana/{data/{ledger,config},accounts/snapshots}

2. sysctl additional values

Increase the memory mapped files limit, increase the UDP buffer size, and optimize the kernel parameters:

root@solana-node-01:~# bash -c "cat >/etc/sysctl.d/20-solana-additionals.conf <<EOF
fs.nr_open=1048576
kernel.hung_task_timeout_secs=600
kernel.nmi_watchdog=0
kernel.pid_max=131072
kernel.sched_min_granularity_ns=10000000
kernel.sched_wakeup_granularity_ns=15000000
kernel.timer_migration=0
net.core.rmem_default=134217728
net.core.rmem_max=134217728
net.core.wmem_default=134217728
net.core.wmem_max=134217728
net.ipv4.tcp_fastopen=3
vm.dirty_background_ratio=10
vm.dirty_expire_centisecs=36000
vm.dirty_ratio=40
vm.dirty_writeback_centisecs=3000
vm.dirtytime_expire_seconds=43200
vm.max_map_count=2000000
vm.stat_interval=10
EOF"
root@solana-node-01:~# sysctl -p /etc/sysctl.d/20-solana-additionals.conf

3. Create a user for Solana

root@solana-node-01:~# adduser  solana
root@solana-node-01:~# chown solana:solana /var/solana/data/
root@solana-node-01:~# chown solana:solana /var/solana/accounts/

4. Install Solana CLI

The Solana CLI tool will install the Agave node client through a script at the next step.

Install the CLI tool by following the Agave docs: Install Solana CLI.

5. Create a run script

solana@solana-node-01:~$ mkdir /home/solana/bin && cd /home/solana/bin
solana@solana-node-01:~$ bash -c "cat > validator.sh <<EOF
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
[ -f /var/solana/data/config/validator-keypair.json ] && echo "Identity exists" || (/opt/solana/solana-release/bin/solana-keygen new -o /var/solana/data/config/validator-keypair.json --no-passphrase --silent && echo "Identity created" )
/opt/solana/solana-release/bin/agave-validator \
--ledger "/pv-disks/disk1/ledger" \
--identity "/pv-disks/disk1/config/validator-keypair.json" \
--known-validator 6WgdYhhGE53WrZ7ywJA15hBVkw7CRbQ8yDBBTwmBtAHN \
--known-validator 7Np41oeYqPefeNQEHSv1UDhYrehxin3NStELsSKCT4K2 \
--known-validator C1ocKDYMCm2ooWptMMnpd5VEB2Nx4UMJgRuYofysyzcA \
--known-validator CakcnaRDHka2gXyfbEd2d3xsvkJkqsLw2akB3zsN1D2S \
--known-validator DE1bawNcRJB9rVm3buyMVfr8mBEoyyu73NBovf2oXJsJ \
--known-validator GdnSyH3YtwcxFvQrVVJMm1JhTS4QVX7MFsX56uJLUfiZ \
--known-validator GwHH8ciFhR8vejWCqmg8FWZUCNtubPY2esALvy5tBvji \
--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 \
--snapshots /pv-disks/disk2/snapshots \
--no-voting \
--private-rpc \
--rpc-bind-address 127.0.0.1 \
--rpc-port 8799 \
--gossip-port 8801 \
--dynamic-port-range "8000-8020" \
--full-rpc-api \
--wal-recovery-mode skip_any_corrupted_record \
--enable-rpc-transaction-history \
--enable-cpi-and-log-storage \
--init-complete-file "/pv-disks/disk1/init-completed" \
--limit-ledger-size 100000000 \
--account-index program-id \
--account-index spl-token-owner \
--account-index spl-token-mint \
--account-index-exclude-key kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6 \
--account-index-exclude-key TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA \
--accounts-index-path "/pv-disks/disk2/accounts_index" \
--accounts-index-memory-limit-mb 204800 \
--accounts "/pv-disks/disk2/accounts" \
--expected-shred-version 50093 \
--rpc-pubsub-enable-block-subscription \
--block-verification-method unified-scheduler \
--minimal-snapshot-download-speed 50000000 \
--maximum-snapshot-download-abort 10000 \
--log -
EOF"
solana@solana-node-01:~$ chmod +x validator.sh

6. Create a service for Solana

root@solana-node-01:~# bash -c "cat > /etc/systemd/system/sol.service <<EOF
[Unit]
Description=Solana Validator
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=solana
LimitNOFILE=1000000
LogRateLimitIntervalSec=0
Environment="PATH=/bin:/usr/bin:/home/solana/.local/share/solana/install/active_release/bin"
ExecStart=/home/solana/bin/validator.sh
[Install]
WantedBy=multi-user.target
EOF"

7. Install Prometheus Node Exporter

Install the Prometheus Node Exporter to export node metrics that you can later feed into your monitoring tools.

Note that you may want to change the version to the latest one here download/v1.3.1/

root@solana-node-01:~# wget https://github.com/prometheus/node_exporter/releases/download/v1.9.1/node_exporter-1.9.1.linux-amd64.tar.gz
root@solana-node-01:~# tar xvfz node_exporter-1.9.1.linux-amd64.tar.gz
root@solana-node-01:~# mv node_exporter-1.9.1.linux-amd64/node_exporter /usr/local/bin/
root@solana-node-01:~# useradd -rs /bin/false node_exporter
root@solana-node-01:~# tee /etc/systemd/system/node_exporter.service<<EOF
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
EOF

…if you need to change port:

root@solana-node-01:~# tee /etc/prometheus.conf<<EOF
ARGS=--web.listen-address=localhost:9101
EOF

Change /etc/systemd/system/node_exporter.service to the ExecStart string to look like this:
ExecStart=/usr/local/bin/node_exporter $ARGS

…continue:

root@solana-node-01:~# systemctl daemon-reload
root@solana-node-01:~# systemctl start node_exporter
root@solana-node-01:~# systemctl enable node_exporter
root@solana-node-01:~# systemctl enable --now sol

8. Install and configure Nginx

Enable secure access to your Solana’s node endpoint with Nginx.

8.1 Install Nginx

root@solana-node-01:~# apt update && apt install nginx
root@solana-node-01:~# cd /etc/nginx/sites-available/
root@solana-node-01:~# vim default

8.2 In location /, set proxy_pass http://solana, save

root@solana-node-01:~# cd ../ && vim nginx.conf

8.3 At the end of the http section, add:

upstream solana{
    server 127.0.0.1:8799;
}

Save.

8.4 Set your domain name, if needed

In /etc/nginx/sites-available/default, add the string server_name {{YOUR DOMAIN NAME HERE}} in the server section.

8.5 Test the Nginx configuration by executing the following:

root@solana-node-01:~# nginx -t

8.6 Reload Nginx

root@solana-node-01:~# systemctl reload nginx

9. Obtain the SSL certificate

9.1 Install Certbot

root@solana-node-01:~# apt install certbot python3-certbot-nginx

9.2 Obtain and apply the certificate

root@solana-node-01:~# certbot --nginx -d {{YOUR DOMAIN NAME HERE}}

10. Enable basic authentication on the endpoint

Run:

root@solana-node-01:~# apt install apache2-utils -y
root@solana-node-01:~# cd /etc/nginx/
root@solana-node-01:~# htpasswd -c .htpasswd {{YOUR_BASIC_AUTH_USER}}

Edit the Nginx configuration:

root@solana-node-01:~# cd sites-available/
root@solana-node-01:~# vim default

Add the following lines inside the server section:

    auth_basic           "Authorization required";
    auth_basic_user_file /etc/nginx/.htpasswd;

Restart Nginx:

root@solana-node-01:~# nginx -t
root@solana-node-01:~# systemctl restart nginx

Further reading

Expand your Solana knowledge and skills with these comprehensive Chainstack resources:

Conclusion

This tutorial walked you through the basics of setting up a non-validating Solana RPC node with a protected RPC endpoint.

Have you already explored what you can achieve with Chainstack? Get started for free today.

SHARE THIS ARTICLE

Simplifying Web3 infrastructure costs

Learn about the challenges of Web3 node pricing and how Chainstack’s transparent pricing strategy can help developers and businesses predict infrastructure costs accurately. Discover the benefits of switching to Chainstack and why it has become the preferred choice of hundreds of projects in the Web3 industry.

Wen Chiao Su
Apr 24
Customer Stories

TrustPad

Creating a better crowdfunding environment by reducing the number of dropped requests.

Curra

Curra creates a new paradigm for decentralized crypto payments with exceptional reliability from Chainstack infrastructure.

Darkpool Liquidity

Develop on various networks and protocols with ease, expanding at scale in a short period of time.