How to Build a Cardano Relay Node (Debian Buster)
A comprehensive guide for setting up a Cardano relay node on Debian Buster.
· 1 min read
This guide walks through setting up a Cardano relay node on Debian Buster. This is part of a series focused on building Cardano Stake Pool infrastructure, following the tutorial on compiling Cardano node binaries.
Prerequisites
This guide assumes you have already compiled and installed Cardano binaries to /usr/local/bin and installed all required dependencies on your Debian Buster system.
System Updates
apt update -y
apt upgrade -y
apt dist-upgrade -y
apt autoremove -y
shutdown -r now
Swap Space Configuration
swapon --show
fallocate -l 10G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
swapon --show
shutdown -r now
swapon --show
User Account Creation
Create a dedicated system user for running the Cardano node:
adduser \
--system \
--shell /bin/bash \
--gecos 'Cardano Node' \
--group \
--disabled-password \
--home /home/cardano \
cardano
Verify Installation
cardano-cli version
cardano-node version
Directory Setup
mkdir -p /etc/cardano/
mkdir -p /var/lib/cardano/
mkdir -p /tmp/cardano/
chown cardano:cardano /tmp/cardano
chown cardano:cardano /var/lib/cardano
Configuration File Preparation
mkdir -p ~/src
cd ~/src
git clone https://github.com/input-output-hk/cardano-node.git
cp -R ~/src/cardano-node/configuration/cardano/* /etc/cardano/
rm -rf ~/src
chown -R cardano:cardano /etc/cardano
Relay Node Topology
Edit /etc/cardano/mainnet-topology.json:
{
"Producers": [
{
"addr": "your-cardano-producer.domain.com",
"port": 4020,
"valency": 1
},
{
"addr": "relays-new.cardano-mainnet.iohk.io",
"port": 3001,
"valency": 4
}
]
}
Startup Script
Create /usr/local/bin/cardano-relay-start.sh:
#!/bin/bash
mkdir -p /tmp/cardano/
chown cardano:cardano /tmp/cardano
export CARDANO_NODE_SOCKET_PATH="/tmp/cardano/cardano-node.socket"
/usr/local/bin/cardano-node run \
--topology /etc/cardano/mainnet-topology.json \
--database-path /var/lib/cardano \
--socket-path /tmp/cardano/cardano-node.socket \
--host-addr 0.0.0.0 \
--port 4020 \
--config /etc/cardano/mainnet-config.json
Create and permission the script:
touch /usr/local/bin/cardano-relay-start.sh
chmod 755 /usr/local/bin/cardano-relay-start.sh
Systemd Service
Create /etc/systemd/system/cardano-node.service:
[Unit]
Description = Cardano node service
Wants = network-online.target
After = network-online.target
[Service]
User = cardano
Type = simple
WorkingDirectory= /home/cardano
ExecStart = /bin/bash -c '/usr/local/bin/cardano-relay-start.sh'
KillSignal=SIGINT
RestartKillSignal=SIGINT
TimeoutStopSec=5
LimitNOFILE=32768
Restart=always
RestartSec=7
[Install]
WantedBy= multi-user.target
Service Activation
systemctl daemon-reload
systemctl enable cardano-node --now
Startup Verification
journalctl -u cardano -f