How to set up a non-Docker node using systemd services with the official native storagenode binary

Hello, I have a method for this but I wanted to get through an update cycle to make sure it worked before I posted it.

I’m running two separate nodes with two separate binaries storagenode1 and storagenode2, and then the individual systemd service files for each node. Both nodes use a common storagenode-updater binary.

If you already have a node installed as per the OP instructions, set up the second node as follows.

Prerequisites

  • Set up identities, port forwards, etc, for your second node.
  • Mount appropriate storage mediums at /mnt/storagenode1 and /mnt/storagenode2.

Method for two nodes

Copy the storagenode binaries and systemd service files:

cd /opt/storagenode/bin
mv storagenode storagenode1
cp storagenode1 storagenode2
cd /etc/systemd/system
mv storagenode.service storagenode1.service
mv storagenode-updater.service storagenode1-updater.service
cp storagenode1.service storagenode2.service
cp storagenode1-updater.service storagenode2-updater.service

Contents of /etc/systemd/system/storagenode1.service:

# This is a SystemD unit file for the Storage Node
# To configure:
# - Update the user and group that the service will run as (User & Group below)
# - Ensure that the Storage Node binary is in /usr/local/bin and is named storagenode (or edit the ExecStart line
#   below to reflect the name and location of your binary
# - Ensure that you've run setup and have edited the configuration appropriately prior to starting the
#   service with this script
# To use:
# - Place this file in /etc/systemd/system/ or wherever your SystemD unit files are stored
# - Run systemctl daemon-reload
# - To start run systemctl start storagenode1

[Unit]
Description  = Storage Node service
After        = syslog.target network.target

[Service]
Type         = simple
User         = storj-storagenode
Group        = storj-storagenode
ExecStart    = /opt/storagenode/bin/storagenode1 run --config-dir "/mnt/storagenode1/config"
Restart      = on-failure
NotifyAccess = main

[Install]
Alias        = storagenode1
WantedBy     = multi-user.target

The systemd service /etc/systemd/system/storagenode2.service is the same except replace storagenode1 with storagenode2 in the binary, --config-dir option, and systemd alias.

Contents of /etc/systemd/system/storagenode1-updater.service:

# To configure:
# - Update the user and group that the service will run as (User & Group below)
# - Ensure that the Storage Node binary is in /usr/local/bin and is named storagenode (or edit the ExecStart line
#   below to reflect the name and location of your binary
# - Ensure that you've run setup and have edited the configuration appropriately prior to starting the
#   service with this script
# To use:
# - Place this file in /etc/systemd/system/ or wherever your SystemD unit files are stored
# - Run systemctl daemon-reload
# - To start run systemctl start storagenode1-updater

[Unit]
Description  = Storage Node Updater service
After        = syslog.target network.target

[Service]
Type         = simple
User         = storj-storagenode
Group        = storj-storagenode
ExecStart    = /opt/storagenode/bin/storagenode-updater run --config-dir "/mnt/storagenode1/config" --binary-location "/opt/storagenode/bin/storagenode1" --service-name "storagenode1"
Restart      = on-failure
NotifyAccess = main

[Install]
Alias        = storagenode1-updater
WantedBy     = multi-user.target

The systemd service /etc/systemd/system/storagenode2-updater.service is the same except replace storagenode1 with storagenode2 for the --config-dir, --binary-location, and --service-name options, and change the systemd alias to storagenode2-updater. Note that the binary /opt/storagenode/bin/storagenode-updater remains common for both services.

When complete, run systemctl daemon-reload.

Run the node and updater services for each separate node as indicated in the OP.

1 Like