Skip to content

Instantly share code, notes, and snippets.

@d2x
Last active November 30, 2024 21:25
Show Gist options
  • Save d2x/79927aafcf40f3816d061a56005807c2 to your computer and use it in GitHub Desktop.
Save d2x/79927aafcf40f3816d061a56005807c2 to your computer and use it in GitHub Desktop.
Erigon archive node setup on Debian 12

Quick Erigon setup on Debian

Quick install instructions for running a private Erigon archive node.

Coffee/retirement money appreciated: xetic.eth

Install deps

sudo apt update && sudo apt dist-upgrade -y && sudo apt install build-essential cmake libssl-dev libclang-dev git -y

Install go

wget https://dl.google.com/go/go1.23.3.linux-amd64.tar.gz

sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.23.3.linux-amd64.tar.gz

export PATH=$PATH:/usr/local/go/bin

go version

Clone and build Erigon

git clone https://github.com/erigontech/erigon.git && cd erigon && make erigon

System tuning

Add noatime to mount point and (optionally) disable swap when using high memory system:

sudo nano /etc/fstab

Disable CPU exploit mitigations to boost performance when using bare metal server:

sudo nano /etc/default/grub Add mitigations=off to GRUB_CMDLINE_LINUX.

sudo update-grub

sudo tee /etc/security/limits.d/90-erigon-nofiles.conf > /dev/null <<EOT
# Increase process file descriptor count limit
#<domain> <type> <item> <value>
* - nofile 2000000
EOT
sudo tee /etc/sysctl.d/20-erigon.conf > /dev/null <<EOT
# Increase UDP buffer size
net.core.rmem_max=134217728
net.core.rmem_default=134217728
net.core.wmem_max=134217728
net.core.wmem_default=134217728

# Increase memory mapped files limit
vm.max_map_count=2000000

# Maximize number of file-handles a process can allocate
fs.nr_open=2147483584
EOT

Reboot to load with CPU mitigations disabled if using bare metal:

sudo shutdown -r now

Otherwise, just reload system settings for adjusted performance limits:

sudo sysctl --system

Setup system service

tee /home/debian/run-erigon.sh > /dev/null <EOT
#!/bin/bash

cd /home/debian/erigon
./build/bin/erigon --chain=mainnet --prune.mode=archive --private.api.addr=localhost:9090 --ws --http.api=eth,debug,trace,ots --torrent.download.rate=800mb --torrent.conns.perfile=15 --txpool.disable --http.corsdomain='*'
EOT

chmod +x /home/debian/run-erigon.sh

sudo tee /etc/systemd/system/erigon.service > /dev/null <EOT
[Unit]
Description=Erigon Archive Node
After=network.target

[Service]
User=debian
ExecStart=/home/debian/run-erigon.sh
Restart=always
RestartSec=1
LimitNOFILE=1000000
Environment="PATH=/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

[Install]
WantedBy=multi-user.target
EOT

Start the service

sudo systemctl daemon-reload && sudo systemctl enable --now erigon

sudo systemctl status erigon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment