Virtual Cardano. Guide on setting up Cardano relay node on a Proxmox virtual machine.
First things first: This is a continuation of my series on Proxmox that started with Virtualization and optimization for node operations with example of practical use. So if you want to set up and tune Proxmox then you could read that guide first to set it up.
If you like this article consider delegating to ADA North Pool Cardano staking pool.
With that said this guide is on setting up a Cardano Relay with monitoring. When it comes to monitoring I will show some simpel monitoring but I will not touch into grafana monitoring with prometheus data for your node in this guide, but that could be a next step to take, especially with automatic alarms in case something went wrong.
Before we start the steps you should have uploaded an iso of Ubuntu 22.04 server to your proxmox disks that holds ISO images.
Then with that out of the way lets create a virtual machine in a few steps:
Now select the VM and go to console. You will then be able to install Ubuntu as normal.
To make things simple for yourself also add ssh login and login to your VM with a ssh client such as Putty for windows.
Now we need to grab the latest binaries for cardano-node. You can check this on https://github.com/input-output-hk/cardano-node/releases/ and go to hydra binaries. Copy this link and get it to your server for example with wget (in this case 1.34.1 linux binary) https://hydra.iohk.io/build/13065769/download/1/cardano-node-1.34.1-linux.tar.gz
Tar -xzvf the file and move or rename the cardano-node and cardano-cli to where you plan to do your cardano relay node operations. In my case i have a dedicated nvme mounted on /opt/cardano/ and I create the folders bin, config, db, scripts and sockets and make it owned by the user that will run cardano this could be your own user or say a dedicated cardanonode user. Use root/sudo chown -R user:user folderpath for example sudo chown -R eysteinh:eysteinh /opt/cardano/.
Grab the configuration files from the cardano release and put them in config. Use links from latest configuration links on the cardano-node github page such as https://hydra.iohk.io/build/8111119/download/1/index.html
So before moving on a bit disclaimer on what is out of scope for this article:
In this tutorial to just get the node up and running we will not configure the topology to contact a pool or to update peers such as the guild operators Topology Updater nor will we optimize configurations for pool vs relay nodes. Node optimization and configuration is a subject worthy of its own article. Also remember to have installed Chrony on your VM and optimized it as per the tuning guide linked to in the start of this article. Without a running timesync updater such as Chrony, your relay will not perform optimally. Chrony can be optimized as well and might be part of a node optimization article.
Allright with that out of the way lets create a systemd service. Basically this is a way to create a service that will start everytime the computer will start and that will run in the background. Edit a file with for example nano (sudo nano /etc/systemd/system/adarelay1.service , or any other name):
So what are we doing here. Well we give a description and we say when during boot that the service should start. We then detail the service itself. I give it a higher prioritiy than other services with nice and I set what type of service, when to restart and the user that will run the service. I also set the working directory and then finally we pass the arguments to start up the relay. The limit on number of files is there to make sure we can create a lot of files during operations and you would also have to set the security limits on your os as well and make sure you have the hardware to handle that. In general you might want to skip this line “LimitNOFILE=XXXXX” if you are unsure if your hardware can handle it.
The +RTS -N2 -RTS is informing that I want to run with 2 CPU cores. I could have passed some memory optimizations here but if you have 12 or 16 GB ram this is not needed and it could also affect latency of the node during memory garbage collection. Importantly we load a topology file where the node gets a peer to connect to the network and we set a database folder (preferably fast nvme storage) for our blockchain. Cardano-node uses a socket system so we create a place for the socket file. We use 0.0.0.0 as the host address but we have to be mindfull of this for when we set up firewall. (You can also set this as the internet ip you will be using for the peer). For port we use a none standard port for safety and we make sure this is open with a firewall such as UFW. See this guide on how to setup the firewall.
The multi-user.target is there to set when the node should run. It defines a system state where all network services are started up and the system accept logins (usually).
Now after creating this service we need to enable it with sudo systemctl enable (name of service) adarelay1.service, we then start it with sudo systemctl start adarelay1.service and we can make sure its running with sudo systemctl status adarelay1.service:
Now lets set up two ways to monitor the data. First one is we can follow the journal simply by journalctl -fu adarelay1.service (name of service)
The other and much nicer way is another guild operator script called GuildLiveView. Fetch the files in the scripts folder for your relay.
curl -s -o gLiveView.sh https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/gLiveView.sh curl -s -o env https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/env chmod 755 gLiveView.sh
Edit the env file to match your relays settings:
You can now run gLiveview.sh for a monitoring overview
If you want to see some built in data such as Prometheus you can forward that with ip tunnel to your monitoring computer for example with putty. You can find the port in the config file:
Forward it in for example putty with your ssh login:
And you can now checkout some metrics:
And there you have it a node that is up and running and hopefully synching if you have set your ports and firewall rules correctly :)