How to Build a Cardano Relay Node (Debian Buster)

In our last blog post we discussed how to link:/blog/compile-cardano-debian-10[Compile Cardano Node Binaries on Debian 10 (Buster)]. We created this series as we wanted to share the specific procedures we use to build and install the applications for our Cardano Stake Pool infrastructure.

The directions below will instruct you on how to build a Cardano Relay Node. These directions are designed with Debian Buster as the base OS. These directions also assume cardano-cli and cardano-node have been installed to /usr/local/bin and all dependencies have been installed.

Update the Operating System

apt update -y
apt upgrade -y
apt dist-upgrade -y
apt autoremove -y
shutdown -r now

Configure Swap Space

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

Add Cardano User

adduser \
    --system \
    --shell /bin/bash \
    --gecos 'Cardano Node' \
    --group \
    --disabled-password \
    --home /home/cardano \

Verify Cardano node files are installed

cardano-cli version
cardano-node version

Create Config & Database Folders

mkdir -p /etc/cardano/
mkdir -p /var/lib/cardano/
mkdir -p /tmp/cardano/
chown cardano:cardano /tmp/cardano
chown cardano:cardano /var/lib/cardano

Create Configuration Files

mkdir -p ~/src
cd ~/src
git clone
cp -R ~/src/cardano-node/configuration/cardano/* /etc/cardano/
rm -rf ~/src

Modify Topology File

Modify /etc/cardano/mainnet-topology.json to reflect only the following lines

  "Producers": [
      "addr": "",
      "port": 4020,
      "valency": 1
      "addr": "",
      "port": 3001,
      "valency": 4

Set Config Permissions

chown -R cardano:cardano /etc/cardano

Node Startup Files

Create Relay Node Startup Script

touch /usr/local/bin/
chmod 755 /usr/local/bin/

Add the following to /usr/local/bin/

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 \
--port 4020 \
--config /etc/cardano/mainnet-config.json

Setup systemd startup

Create the file /etc/systemd/system/cardano-node.service with the following contents

# The Cardano node service (part of systemd)
# file: /etc/systemd/system/cardano-node.service 

Description     = Cardano node service
Wants           =
After           = 

User            = cardano
Type            = simple
WorkingDirectory= /home/cardano
ExecStart       = /bin/bash -c '/usr/local/bin/'


Start Relay Node

systemctl daemon-reload
systemctl enable cardano-node --now

Verify Successful Startup

journalctl -u cardano -f