Skip to content

Storj Guide

sudoebm edited this page Jun 1, 2022 · 10 revisions

Description

This is a work in progress for STORJ documentation. Outlined here are the basic steps to get your system setup to run storj and manage the nodes.

Vocab

  • Storj Node (Node) - Set aside block of storage dedicated to storj, typically a full HDD, 2TB or larger
  • System (Server) - System that the node resides on
  • Satellite - Storj Server
  • Dashboard - Storj http interface
  • Docker - Interface for controlling Storj. Docker has "images" of software, you run things inside "containers".

Installation

Pre-requisites

Initial setup will assume a single node is being configured on a Ubuntu 20 based system.

  1. Open an exception in your firewall and router for Port 28967. This port should forward to the server hosting your node.
  2. You need to have a static IP, domain, or dynamic DNS setup. This is left as an exercise for the reader.
  3. You have an Etherium wallet.

Disk Setup

  1. We will assume that you have a 3TB disk located at /dev/sdc.
    lsblk --> Identify your storj disk (again, tutorial will treat this as /dev/sdc

    fdisk /dev/sdc, d to delete any existing partitions (ex. if /dev/sdc1 exists), then:

    g,n,w,q - Set partition table to GPT, create new partition (accept defaults), write the table to disk, quit

    mkfs.ext4 /dev/sdc1 - Will format the partition you created as EXT4, for a 3TB disk, lsblk should report it as 2.7T

    mkdir /mnt/storj_01 - The Storj node will reside here, never touch this directory, it belongs to Storj.

    mount /dev/sdc1 /mnt/storj_01 - Mount your shiny new partition to its new home

    ls -l /dev/disk/by-uuid/ - Look for your disk partition, copy its UUID (ex: 3d99a85e-64af-4915-b3fc-e4e95f5f287b)

    nano /etc/fstab - Add a new row at the bottom of this file that reads as follows (using your UUID, this is only an example):

    UUID=3d99a85e-64af-4915-b3fc-e4e95f5f287b /mnt/storj_01 ext4 defaults 0 0

If this process worked, then you have a new EXT4 disk mounted at /mnt/storj_01 and will always mount there on reboot regardless of if your swap SATA connectors or move things around. Nice. Let's setup storj.

Storj Initial Setup

This process is not exactly direct, or quick. It requires first getting an authorization token, then generating a random key. To get your token, visit: https://docs.storj.io/node/before-you-begin/auth-token. Storj can't build a website properly, so you may need to disable all blocking, pi-hole, and use chrome or edge for it to work. It may not work, you may need to contact them directly. Your mileage may vary. Let's say you got your token though, and are ready to blast off...here we go.

  1. Install Identity software

    curl -L https://github.com/storj/storj/releases/latest/download/identity_linux_amd64.zip -o identity_linux_amd64.zip && unzip -o identity_linux_amd64.zip && chmod +x identity && sudo mv identity /usr/local/bin/identity

  2. Create a new Identity (storagenode)

    identity create storagenode - ...and wait until you find a key with a difficulty of 36 (could take hours or days)

  3. Authorize the Identity

    identity authorize storagenode [email:characterstring] - Replace the square brackets with your authorization email ID

  4. Confirm the Identity is correctly setup, the following command should return back two lines, 2, and 3

    grep -c BEGIN ~/.local/share/storj/identity/storagenode/ca.cert && grep -c BEGIN ~/.local/share/storj/identity/storagenode/identity.cert

  5. Backup your ID:

    cp -R ~/.local/share/storj/identity/storagenode /your/backup/location

If this process worked, you have created an ID, registered it to Storj and authorized it on your system with your unique key.

Install Docker

  1. Setup APT:

    sudo apt-get update && sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release

  2. Install PGP Key:

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

  3. Add repository:

    echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

  4. Install docker:

    sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io

  5. Confirm it works:

    docker run hello-world

If all this works, you now have a disk ready to connect to your storj identity using docker. Lets do that.

Starting your node

The official documentation can be found here: https://docs.storj.io/node/dependencies/identity. In a nutshell, it boils down to this command, replacing square bracket information as needed (omit brackets):

docker run -d --restart unless-stopped -p 28967:28967 -p 14002:14002 -e WALLET="[Etherium Wallet]" -e EMAIL="[[email protected]]" -e ADDRESS="[DOMAIN or IP]:28967" -e BANDWIDTH="20TB" -e STORAGE="2.4TB" --mount type=bind,source="/root/.local/share/storj/identity/storagenode/",destination=/app/identity --mount type=bind,source="/mnt/storj_01",destination=/app/config --name storj_01 storjlabs/storagenode:beta

That command will create a new docker container for your Storj node. It will have a total bandwidth of 20TB, and per Storj policy, 10% of the 2.7TB is reserved, so we only allow 2.4TB of storage. The destination is our mounted disk, and the docker container is called storj_01.

You can confirm the node is running by visiting your local IP address at port 14002 in a web browser (ex: 192.168.0.100:14002). Alternatively, you can confirm online status with, docker exec -it storj_01 ./dashboard.sh, exit with ctrl+c (your node is still running).

Maintenance

There are a few things that you'll need to do as a node operator, they'll all be covered here:

  • Setting up watchtower (automatically update your docker node software)
  • Adding additional nodes (each node should be a dedicated HDD)
  • Cloning/Replacing a failing disk
  • Increasing disk size

Watchtower

Watchtower will keep an eye over your docker container and make sure you are always on the latest Storj node version. Set it up with the following command:

 `docker run -d --restart=always --name watchtower -v /var/run/docker.sock:/var/run/docker.sock storjlabs/watchtower storj_01 watchtower --stop-timeout 300s --interval 21600`

If you have multiple nodes setup on the system, see bottom of Additional Node setup.

Adding additional nodes

The ideal method is to dedicate each node to a specific HDD. Setting up RAID or JBOD is not fruitful. If one node goes down, they all go down, whereas separating each disk allows things to fail and not wipe out everything. Setting up a second node requires following all the previous steps. You must:

  1. Setup a new disk, mount, fstab entry

  2. Open a new port on your router/firewall (one higher, so if the first node is 28967, open up 28968 as well.

  3. Generate a new authorization token

  4. Create a new identity, we'll call it 'storagenode2': identity_linux_amd64 create storagenode2

  5. Authorize the identity: identity_linux_amd64 authorize storagenode2 [email:characterstring]

  6. Run the following command, note the differences in how the ports are specified, and how the node is named:

    docker run -d --restart unless-stopped -p 28968:28967 -p 14003:14002 -e WALLET="[Etherium Wallet]" -e EMAIL="[[email protected]]" -e ADDRESS="[Domain or IP]:28968" -e BANDWIDTH="20TB" -e STORAGE="2.4TB" --mount type=bind,source="/root/.local/share/storj/identity/storagenode2/",destination=/app/identity --mount type=bind,source="/mnt/storj_02",destination=/app/config --name storj_02 storjlabs/storagenode:beta

You can perform the same inspection on this node by updating the port and using the same commands or web address shown above.

  1. If you create a new node, you will want to create a new instance of watchtower:

    docker stop -t 300 watchtower && docker rm watchtower

  2. Recast watchtower to update both nodes, notice how it now lists both storj_01 and storj_02:

    docker run -d --restart=always --name watchtower -v /var/run/docker.sock:/var/run/docker.sock storjlabs/watchtower storj_01 storj_02 watchtower --stop-timeout 300s --interval 21600

To add more nodes, repeat this process.

Clone and Replace a Failing disk

This portion of the guide will describe how to clone a disk. The target disk must be equal in size or larger than the source disk. Confirm disk sizes with lsblk to identify the disk then fdisk -l /dev/sdc for instance. We will assume /dev/sdc is the old disk, and /dev/sdd is the new disk.

  1. Stop the node, disconnect it:

    docker stop -t 300 storj_01 && umount /dev/sdc1

  2. Check existing file system for errors, fix any found:

    e2fsck -f /dev/sdc1

  3. Clone the disk:

    dd if=/dev/sdc of=/dev/sdd bs=128M status=progress

  4. Check the cloned disk:

    e2fsck -f /dev/sdd1

  5. Assign a random UUID to the old disk to prevent any collisions on reboot (since they were cloned, they now have the same UUID, we need to be sure we only mount the new drive and not the old one):

    tune2fs -U random /dev/sdc1

  6. Remount the new disk:

    mount /dev/sdd1

  7. Restart the node:

    docker start storj_01

Increasing disk size

Lets say you replaced a failing disk with a larger disk and it cloned successfully. The next step would be to increase the partition size to fill the empty space on the new (larger) disk. We will accomplish that with the following (assuming the node is storj_01 and the associated partition is /dev/sdc1):

  1. Stop the node, disconnect it:

    docker stop -t 300 storj_01 && umount /dev/sdc1

  2. Check existing file system for errors, fix any found:

    e2fsck -f /dev/sdc1

  3. Grow the partition:

    growpart /dev/sdc1

  4. Resize the filesystem to match the partition:

    resize2fs /dev/node_partition

  5. Check for errors, ideally nothing broke:

    e2fsck -f /dev/node_partition

  6. Remount:

    mount /dev/sdc1

  7. Remove old docker container (it was the previous disk size):

    docker rm storj_01

  8. Recast the node --> See above process for setting up a node, only this time specify a larger size (allow 10% for waste).

  9. Confirm it is up and reports new size:

    docker exec -it storj_01 ./dashboard.sh

There is no need to recast watchtower, provided you kept the names the same (storj_01) watchtower will still see it.