Searchโ€ฆ
Pi-Relay
Pi-Node to Pi-Relay
To turn Pi-Node into a active relay we have to.
    1.
    Configure hostname.
    2.
    Configure static IP.
    3.
    Configure port for cardano-service.
    4.
    Configure port forwarding on router.
    5.
    Update port in env file.
    6.
    Enable cron job.
    7.
    Configure both topology scripts.
    8.
    Wait for service on boarding(4 hours).
    9.
    Pull in new list of peers.
    10.
    Prune list of best peers.
    11.
    Update gLiveView's env file.
    12.
    Edit the alias name for Prometheus.
    13.
    Reboot.

Hostname

To set a fully qualified domain name (FQDN) for our relay edit /etc/hostname & /etc/hosts.
1
sudo nano /etc/hostname
Copied!
Replace ubuntu with your desired FQDN.
1
r1.example.com
Copied!
Save and exit.
1
sudo nano /etc/hosts
Copied!
Edit the file accordingly, take note that you may not be using the 192.168.1.xxx IP range.
1
127.0.0.1 localhost
2
127.0.1.1 r1.example.com r1
3
โ€‹
4
# The following lines are desirable for IPv6 capable hosts
5
::1 ip6-localhost ip6-loopback
6
fe00::0 ip6-localnet
7
ff00::0 ip6-mcastprefix
8
ff02::1 ip6-allnodes
9
ff02::2 ip6-allrouters
10
ff02::3 ip6-allhosts
11
โ€‹
Copied!
Save and exit.

Network

Static IP

Open 50-cloud-init.yaml and replace the contents of the file with below.
Be sure to use an address on your LAN subnet. In this example I am using 192.168.1.xxx. Your network may very well be using a different private range.
1
sudo nano /etc/netplan/50-cloud-init.yaml
Copied!
1
# This file is generated from information provided by the datasource. Changes
2
# to it will not persist across an instance reboot. To disable cloud-init's
3
# network configuration capabilities, write a file
4
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
5
# network: {config: disabled}
6
network:
7
version: 2
8
renderer: networkd
9
ethernets:
10
eth0:
11
dhcp4: no
12
addresses:
13
- 192.168.1.151/24
14
gateway4: 192.168.1.1
15
nameservers:
16
# Home router IP & QUAD9 https://quad9.net/
17
addresses: [192.168.1.1, 9.9.9.9, 149.112.112.112]
Copied!
Create a file named 99-disable-network-config.cfg to disable cloud-init.
1
sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Copied!
Add the following, save and exit.
1
network: {config: disabled}
Copied!
Apply your changes.
1
sudo netplan apply
Copied!

Configure service port

Open the cardano service file and change the port it listens on.
1
nano /home/ada/.local/bin/cardano-service
Copied!
Save and exit. ctrl+x then y.
1
#!/bin/bash
2
DIRECTORY=/home/ada/pi-pool
3
FILES=/home/ada/pi-pool/files
4
PORT=3001
5
HOSTADDR=0.0.0.0
6
TOPOLOGY=${FILES}/mainnet-topology.json
7
DB_PATH=${DIRECTORY}/db
8
SOCKET_PATH=${DIRECTORY}/db/socket
9
CONFIG=${FILES}/mainnet-config.json
10
## +RTS -N4 -RTS = Multicore(4)
11
cardano-node run \
12
--topology ${TOPOLOGY} \
13
--database-path ${DB_PATH} \
14
--socket-path ${SOCKET_PATH} \
15
--host-addr ${HOSTADDR} \
16
--port ${PORT} \
17
--config ${CONFIG}
Copied!
Enable cardano-service at boot & restart the service to load changes.
1
cardano-service enable
2
cardano-service restart
Copied!

Forward port on router

Do not forward a port to your Core machine it only connects to your relay(s) on your LAN
Log into your router and forward port 3001 to your relay nodes LAN IPv4 address port 3001. Second relay forward port 3002 to LAN IPv4 address for relay 2 to port 3002.

Topology Updater

1
cd $NODE_HOME/scripts
Copied!
Configure the script to match your environment.
If you are using IPv4 leave CNODE_HOSTNAME the way it is. The service will pick up your public IP address on it's own. I repeat only change the port to 3001. For DNS change only the first instance. Do not edit "CHANGE ME" further down in the file.
1
cd /home/ada/pi-pool/scripts/
Copied!
1
nano topologyUpdater.sh
Copied!
Run the updater once to confirm it is working.
1
./topologyUpdater.sh
Copied!
Should look similar to this.
{ "resultcode": "201", "datetime":"2021-05-20 10:13:40", "clientIp": "1.2.3.4", "iptype": 4, "msg": "nice to meet you" }
Enable the cron job by removing the # character from crontab.
1
crontab -e
Copied!
1
33 * * * * /home/ada/pi-pool/scripts/topologyUpdater.sh
Copied!
Save and exit.

Pull in your list of peers

Wait four hours or so and run the relay-topology_pull.sh to replace your mainnet-topology file with the list created in the log directory.
Open relay-topology_pull.sh and configure it for your environment.
1
nano /home/ada/pi-pool/scripts/relay-topology_pull.sh
Copied!
1
#!/bin/bash
2
BLOCKPRODUCING_IP=<core nodes private IPv4 address>
3
BLOCKPRODUCING_PORT=3000
4
curl -4 -s -o /home/ada/pi-pool/files/mainnet-topology.json "https://api.clio.one/htopology/v1/fetch/?max=15&customPeers=${BLOCKPRODUCING_IP}:${BLOCKPRODUCING_PORT}:1|relays-new.cardano-mainnet.iohk.io:3001:2"
Copied!
Save and exit.
After four hours of on boarding your relay(s) will start to be available to other peers on the network. topologyUpdater.sh will create a list in /home/ada/pi-pool/logs.
relay-topology_pull.sh will replace the contents of your relays mainnet-topology file.
1
cd /home/ada/pi-pool/scripts
2
./relay-topology_pull.sh
Copied!

Prune the list

Open your topolgy file and use ctrl+k to cut the entire line of any peer over 5,000 miles away.
Remember to remove the last entries comma in your list or cardano-node will fail to start.
1
nano /home/ada/pi-pool/files/mainnet-topology.json
Copied!

Enable blockfetch tracing

1
sed -i ${NODE_FILES}/mainnet-config.json \
2
-e "s/TraceBlockFetchDecisions\": false/TraceBlockFetchDecisions\": true/g"
Copied!

Update gLiveView port

Open the env file in the scripts directory.
1
nano /home/ada/pi-pool/scripts/env
Copied!
Update the port number to match the one set in the cardano-service file. 3001 in this guide.
Reboot your new relay and let it sync back to the tip of the chain.
Use gLiveView.sh to view peer info.
1
cd /home/ada/pi-pool/scripts
2
./gLiveView.sh
Copied!
Many operators block icmp syn packets(ping) because of a security flaw that was patched a decade ago. So expect to see --- for RTT because we are not receiving a response from that server.
More incoming connections is generally a good thing, it increases the odds that you will get network data sooner. Though you may want to put a limit on how many connect. The only way to stop incoming connections would be to block the IPv4 address with ufw.

Prometheus

Last thing we should do is change the name Prometheus is serving to Grafana.
1
sudo nano /etc/prometheus/prometheus.yml
Copied!
You can change.
1
alias: 'N1'
Copied!
to
1
alias: 'R1'
Copied!
In an upcoming guide I will show how to have Prometheus running on a separate Pi scraping data from the pool instead of having Prometheus using system resources on those machines.
Update, save and exit.
1
global:
2
scrape_interval: 15s # By default, scrape targets every 15 seconds.
3
โ€‹
4
# Attach these labels to any time series or alerts when communicating with
5
# external systems (federation, remote storage, Alertmanager).
6
external_labels:
7
monitor: 'codelab-monitor'
8
โ€‹
9
# A scrape configuration containing exactly one endpoint to scrape:
10
# Here it's Prometheus itself.
11
scrape_configs:
12
# The job name is added as a label job=<job_name> to any timeseries scraped from this config.
13
- job_name: 'Prometheus' # To scrape data from the cardano node
14
scrape_interval: 5s
15
static_configs:
16
# - targets: ['<CORE PRIVATE IP>:12798']
17
# labels:
18
# alias: 'C1'
19
# type: 'cardano-node'
20
# - targets: ['<RELAY PRIVATE IP>:12798']
21
# labels:
22
# alias: 'R1'
23
# type: 'cardano-node'
24
- targets: ['localhost:12798']
25
labels:
26
alias: 'R1'
27
type: 'cardano-node'
28
โ€‹
29
# - targets: ['<CORE PRIVATE IP>:9100']
30
# labels:
31
# alias: 'C1'
32
# type: 'node'
33
# - targets: ['<RELAY PRIVATE IP>:9100']
34
# labels:
35
# alias: 'R1'
36
# type: 'node'
37
- targets: ['localhost:9100']
38
labels:
39
alias: 'R1'
40
type: 'node'
Copied!
Reboot the server and give it a while to sync back up. That is just about it. Please feel free to join our Telegram channel for support. https://t.me/armada_alliโ€‹
Last modified 10d ago