Starting a relay node
Starting a node as a systemd service in relay mode
After downloading the cardano-node software from the Github Releases page (or building it from the source code, if you prefer: building instructions) and copying the cardano-node
and cardano-cli
binaries to /usr/local/bin
, the next step is to create a dedicated user for running the cardano-node service, create the required folders and download the configuration files.
I am usually creating a user named "cardano", without any extra privileges (and without a password), for this purpose.
To login as this user, after connecting with ssh with an user with sudo rights, I am switching to cardano using the command:
As the cardano user, I am creating the following folders:
The next step is to download the configuration files for the selected network (mainnet, preprod or preview) from here: https://book.world.dev.cardano.org/environments.html
This can be done like this for mainnet (and similar for preview or preprod, but downloading their similar config files):
These files are all the configuration files required for running the cardano node.
After downloading them, the next step is to create a startup script inside the ~/cardano-node/bin
folder:
This will create the startNode.sh
file with the content above starting with #!/bin/bash
and ending before the EOF
towards the end of the code, and chmod 755 startNode.sh
will make the file executable.
Using this file, you can already start the node in relay mode, but you need to let it run inside the console. If you close the console, it will stop. The initial sync will take a long time (probably hours, because the ~/cardano-node/db
folder has close to 100 GB that need to be downloaded. After the initial setup, the node needs to run permanently, to sync the new blocks.
The better way of starting the node is as a systemd service. For this, a systemd service needs to be defined, activated and started. As root (sudo -i
as an user with sudo
rights to become root), run the following commands:
This will create the cardano-node.service
file, enable it (make it start automatically at boot) and start it.
To see and follow the logs, type the following command (as root):
If everything is fine, you should see the node syncing the blocks.
To see the progress of the sync, you can run the query tip command (as the cardano
user):
The response will be like this (with different numbers and block hash, and a percent lower than 100 while the node is still not in sync):
If this command is not running, then you need to set the CARDANO_NODE_SOCKET_PATH
environment variable, pointing to the node socket (defined in the startNode.sh
file above):
To make it set automatically at the login, put it in the .bashrc
file (in the cardano
user's home):
In case you did not do it already, also set the LD_LIBRARY_PATH
environment variable in the ~/.bashrc` file:
In case the cardano-node
or/and cardano-cli
files are not found, make sure you copy them to /usr/local/bin
or another folder which is in your $PATH environment variable. I prefer having them in usr/local/bin
.
Last updated