Launching Cardano Relay Node

Previously we launched the node in active ssh session, which means, as soon we close the browser, the node will stop working

To "nicely" launch node in one window we will be using the tmux

tmux is a terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command-line program at the same time. Here you can find keyboard shortcuts to manage tmux session https://tmuxcheatsheet.com

Let's go to our scripts folder:

cd ~/cnode/scripts/

Here are some simple scripts which we will use: 1) start_all.sh - to start all nodes 2) stop_all.sh - to stop all nodes 3) node.sh node start script (used by start_all.sh script)

you can create these scripts in your terminal or download them bellow

start_all.sh
stop_all.sh
node.sh
start_all.sh
nano start_all.sh

#!/bin/bash

session="cardano" # Check if the session exists, discarding output # We can check $? for the exit status (zero for success, non-zero for failure)

tmux has-session -t $session 2>/dev/null if [ $? != 0 ]; then tmux attach-session -t $session tmux new -s "cardano" -n "node" -d tmux split-window -v tmux split-window -h tmux select-pane -t 'cardano:node.0' tmux split-window -h tmux send-keys -t 'cardano:node.0' './node.sh' Enter tmux send-keys -t 'cardano:node.1' 'htop' Enter tmux send-keys -t 'cardano:node.2' 'nload' Enter tmux send-keys -t 'cardano:node.3' Enter fi tmux attach-session -t $session

stop_all.sh
nano stop_all.sh

#!/bin/bash

# Check if the session exists, discarding output # We can check $? for the exit status (zero for success, non-zero for failure)

session="cardano" # Check if the session exists, discarding output # We can check $? for the exit status (zero for success, non-zero for failure) tmux has-session -t $session 2>/dev/null if [ $? != 0 ]; then echo "Session not found." else echo "Killing session" tmux kill-session -t cardano fi

node.sh
nano node.sh

#!/bin/bash cardano-node run \ --database-path ~/cnode/db/ \ --socket-path ~/cnode/sockets/node.socket \ --port 3000 \ --config ~/cnode/config/mainnet-config.json \ --topology ~/cnode/config/mainnet-topology.json

Let's flag these files as executive scripts:

chmod +x start_all.sh stop_all.sh node.sh

If you want - you can also download the scripts from GitHub, but if you copied - then skip to the chmod command: https://github.com/stakepool247/CardanoHaskellTestnetScripts

cd ~/git
git clone https://github.com/stakepool247/CardanoHaskellTestnetScripts.git
cd CardanoHaskellTestnetScripts/
git checkout master

let's copy them to cardano-node script folder

cp *.sh ~/cnode/scripts/

After creating these scripts you will need to make them executable by using chmod command

cd ~/cnode/scripts/
chmod +x start_all.sh stop_all.sh node.sh

to start the node, just type the following command from your script folder:

./start_all.sh

You should see your screen similar to this, where in the first window you see the node, then in next you see the running processes and below that, you see the network traffic data. There is an "empty" window where you can run some commands when needed.

To exit the tmux session (detach) press ctrl+b and then d after pressing this the nodes will still running in the background to re-attach to the session you can run ./start_all.sh script again or type tmux a to end/kill the session - launch the ./stop_all.sh script

We have set up your first relay node!

As a next step - you can do the same for your core/relay server as you need a minimum of 2 servers

1) Relay node, a server which is between your core server and other relay servers, serves as a protection to your core 2) core node (producer): a server which is producing blocks 3) cold PC: a secure computer on which you are generating Stake Pool Keys and wallets.

Ideally, for each core server, you would have 2 relay servers where they can connect

NEVER, EVER generate your wallet and stake pool keys on your online servers! It's a BAD, BAD practice. Install on your local machine VirtualBox+Ubuntu and do the wallet and key registration (either by hand or using CNTOOLS or Martins scripts)

if you need any help - you can contact us directly using Telegram: https://t.me/StakePool247help