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

Following the [Tech Preview] post below, here’s my method for standing up the Linux-native storagenode and storagenode-updater services on Ubuntu 20.04.

Prerequisites

  • Create and authorize a Storj identity as per Storj Documentation.
  • Install Ubuntu 20.04 server.
  • Set up a static IP and configure port forwarding
  • Set up an appropriate storage medium and mount to /mnt/storagenode.
  • Create a storj-storagenode system user: adduser --system --group --home /mnt/storagenode --no-create-home storj-storagenode.
  • Move Storj identity into /mnt/storagenode/identity.
  • Set permissions: chown -R storj-storagenode:storj-storagenode /mnt/storagenode.

Download and Install v1.16.1 Binaries

I opted to install these in a dedicated directory /opt/storagenode that is owned by the storj-storagenode user rather than installing in /usr/local/bin. Otherwise, the storagenode-updater service below won’t be able to write to the folder to update the binary.

Run the following steps either as root or using sudo where appropriate.

wget https://github.com/storj/storj/releases/download/v1.16.1/storagenode_linux_amd64.zip
wget https://github.com/storj/storj/releases/download/v1.16.1/storagenode-updater_linux_amd64.zip
unzip storagenode_linux_amd64.zip
unzip storagenode-updater_linux_amd64.zip
chmod +x storagenode
chmod +x storagenode-updater
mkdir -p /opt/storagenode/bin
mv storagenode storagenode-updater /opt/storagenode/bin
chown -R storj-storagenode:storj-storagenode /opt/storagenode

If using a Raspberry Pi, ODroid, or other ARM devices, please select the appropriate binary for your system at the v1.16.1 Release Page.

Create SystemD service files

Run the following steps either as root or using sudo where appropriate.

Contents of /etc/systemd/system/storagenode.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 storagenode

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

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

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

Contents of /etc/systemd/system/storagenode-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 storagenode

[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/storagenode/config" --binary-location "/opt/storagenode/bin/storagenode" --service-name "storagenode"
Restart      = always
NotifyAccess = main

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

Then run:

systemctl daemon-reload

First Run

Change to the new storj-storagenode user.

# first become root if not already
sudo su -
# change to storj-storagenode user
su - storj-storagenode -s /bin/bash

To create the config.yaml file.

/opt/storagenode/bin/storagenode setup --config-dir "/mnt/storagenode/config" --identity-dir "/mnt/storagenode/identity"

Edit the /mnt/storagenode/config/config.yaml file and ensure the following parameters are set:

console.address: :14002   # to access the web dashboard from another machine
contact.external-address: "storj.example.com:28967"
operator.email: "email@example.com"
operator.wallet: "<wallet address>"
server.address: :28967
storage.allocated-disk-space: 1.00 TB

Exit from the storj-storagenode user shell:

exit

Subsequent Runs

Run the following steps either as root or using sudo where appropriate.

Start the services using systemd.

systemctl start storagenode
systemctl start storagenode-updater

Ensure services are running without errors using:

journalctl -efu storagenode
# check, and then Ctrl-C to exit from the follow mode
journalctl -efu storagenode-updater

If all looks well, enable the systemd units for autostart:

systemctl enable storagenode
systemctl enable storagenode-updater

FUTURE TODO:

  • Create a systemd unit to mount /mnt/storage instead of using /etc/fstab and add that to the After= line item in storagenode.service. This will ensure that systemd manages the order of mounting the data prior to loading the service.
11 Likes

Tested the installation on VDS KVM, an error takes off at startup. wrote in a personal

Please post here instead. The PM is useful only for personal information.
The problem and solution could help many.

Unfortunately, it failed to run on ubuntu 20.04
I did everything 1 in 1
run on user root
EROR START (log)
systemctl status storagenode

storagenode.service: Main process exited, code=exited, status=203/EXEC storagenode.service: Failed with result 'exit-code'. storagenode.service: Scheduled restart job, restart counter is at 5. Stopped Storage Node service. storagenode.service: Start request repeated too quickly. storagenode.service: Failed with result 'exit-code'. Failed to start Storage Node service.

help. test install on VDS kvm

Check the logs systemctl status storagenode-updater

You can also run the storagenode-updater manually and see what it prints out.

systemctl status storagenode-updater

root@bez-domena-izi:/opt/storagenode/bin# systemctl status storagenode-updater

  • storagenode-updater.service - Storage Node Updater service
    Loaded: loaded (/etc/systemd/system/storagenode-updater.service; disabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Sun 2020-11-08 16:14:54 UTC; 23min ago
    Process: 2351 ExecStart=/opt/storagenode/bin/storagenode-updater run --config-dir /mnt/storagenode/config --binary-location /opt/storagenode/bin/storagenode >
    Main PID: 2351 (code=exited, status=203/EXEC)

Nov 08 16:14:54 bez-domena-izi.com systemd[1]: storagenode-updater.service: Scheduled restart job, restart counter is at 5.
Nov 08 16:14:54 bez-domena-izi.com systemd[1]: Stopped Storage Node Updater service.
Nov 08 16:14:54 bez-domena-izi.com systemd[1]: storagenode-updater.service: Start request repeated too quickly.
Nov 08 16:14:54 bez-domena-izi.com systemd[1]: storagenode-updater.service: Failed with result ‘exit-code’.
Nov 08 16:14:54 bez-domena-izi.com systemd[1]: Failed to start Storage Node Updater service.

You shouldnt run under root this is your first mistake.

from under the user storj-storagenode also does not work

No you need to create the user or you can use the default user which is the user you have when you installed ubuntu. But should never use root. Best practice is never running anything under the root user, It can create issues of its own. Its also mostly likely you dont have the files in the right place.

1 Like

Hello @11FaTuSh11, can you confirm that you created a storj-storagenode user as in the instructions? Also, please provide more line items from your storagenode log. What is the output of journalctl -n 30 -u storagenode?

Also, there’s no immediate harm running your login session as root and starting the systemd service as root, but it’s recommended that the actual service runs as a dedicated non-root user such as storj-storagenode as suggested in the unit files. Please confirm that your systemd units use this user and also ensure ownership is correct for your storage config directory (i.e. /mnt/storagenode) and the storj binary directory (i.e. /opt/storagenode).

I have reinstalled Ubuntu now
And I will try to repeat everything from the beginning, if I fail. Will you help me? if i give root access

For sure, I’d be willing to help you out whatever way works best. Best of luck with the reinstall and msg if you run into any issues.

need your help. add me to telegram () or discord ()

storj-storagenode@bez-domena-izi:~$ /opt/storagenode/bin/storagenode setup --config-dir “/mnt/storagenode/config” --identity-dir “/mnt/storagenode/identity”
-bash: /opt/storagenode/bin/storagenode: No such file or directory

You can use any dir that you wanna use just create the dir first then run the command again. If your running a VM you dont need to use /mnt/storagenode like in the example.

i created mkdir -p /mnt/storagenode/config

This folder is only used if you have a hard drive that is mounted to this folder.

I may be able to hop on to either of those later on today. In the meantime, can you confirm where you installed the binaries?

You’ll need the amd64 binaries in your VM. In my example, I installed the binaries at /opt/storagenode/bin and needed to create that directory.

history command user ROOT

mkdir -p /mnt/storagenode/identity
3 Nov 08 18:42:22 adduser storj-storagenode
4 Nov 08 18:43:09 apt install unzip
5 Nov 08 18:44:17 chown -R storj-storagenode:storj-storagenode /mnt
6 Nov 08 18:44:34 wget https://github.com/storj/storj/releases/download/v1.15.3/storagenode_linux_arm.zip
7 Nov 08 18:45:48 ls
8 Nov 08 18:46:10 wget https://github.com/storj/storj/releases/download/v1.15.3/storagenode-updater_linux_arm.zip
9 Nov 08 18:46:40 unzip storagenode_linux_arm.zip
10 Nov 08 18:46:47 unzip storagenode-updater_linux_arm.zip
11 Nov 08 18:46:53 chmod +x storagenode
12 Nov 08 18:46:59 chmod +x storagenode-updater
13 Nov 08 18:47:06 mkdir -p /opt/storagenode/bin
14 Nov 08 18:47:18 chown -R storj-storagenode:storj-storagenode /opt
15 Nov 08 18:47:54 touch /etc/systemd/system/storagenode.service
16 Nov 08 18:48:05 touch /etc/systemd/system/storagenode-updater.service
17 Nov 08 18:48:23 chown -R storj-storagenode:storj-storagenode /etc/systemd/system/storagenode-updater.service /etc/systemd/system/storagenode.service
18 Nov 08 18:49:24 systemctl daemon-reload
19 Nov 08 19:02:32 cd mnt / storagenode
20 Nov 08 19:02:39 cd /mnt
21 Nov 08 19:02:45 cd storagenode
22 Nov 08 19:20:18 history

history command user storj-storagenode

1 Nov 08 18:48:34 vi /etc/systemd/system/storagenode.service
2 Nov 08 18:49:00 vi /etc/systemd/system/storagenode-updater.service
3 Nov 08 18:50:26 /opt/storagenode/bin/storagenode setup --config-dir “/mnt/storagenode/config” --identity-dir “/mnt/storagenode/identity”
4 Nov 08 19:13:15 ls
5 Nov 08 19:19:54 history

Unlike my Odroid that the guide was based on, I’m 99.9% sure your VPS is amd64. Please download and unzip the following binaries:

You’ll need to first mv storagenode storagenode-updater /opt/storagenode/bin and then chown -R storj-storagenode:storj-storagenode /opt. That’s why your binaries are not being found in /opt/storagenode/bin.

Can’t do live help tonight as it turns out, so I’m opting for a unit test approach after each of your failing commands. Let’s see if you can get the storagenode setup command after (1) getting the correct binary architecture for your system (i.e. amd64) and (2) moving the binaries to /opt/storagenode/bin after downloading.

@fmoledina Do you mind if I make your post a wiki?
Please, update the section regarding arm/amd64 architecture when we downloading a binary