NEXItaliano

NEX › Documentation › NEX on real machines — step by step guide

NEX on real machines — step by step guide

By Roberto Arato of aratoingegneria.it

This guide takes you from three PCs to a working NEX cluster: three nodes that run programs and keep the data, the common folder /nex with three copies of every file, and a user who can log in from any of them. If one PC breaks, nothing is lost and the others keep working.

You do not need to be an expert. Every step says what to do, why, the commands to copy, what you should see, and what to do if you see something else. Plan about two hours, most of it for installing Debian on the three PCs.

The VM images (VM images) are for trying NEX in a few minutes. This guide builds the real cluster. The reference manual, with every option, is Installation.

Contents

  1. How to read this guide
  2. What you need
  3. Install Debian on every PC
  4. On every PC: first login and network
  5. On every PC: names, clock and a newer kernel
  6. On every PC: permission for the installation
  7. On every PC: the NEX packages
  8. The first node
  9. The other two nodes
  10. Three copies of every file, and a check
  11. The test: a PC goes off
  12. A fourth PC, for computing only
  13. When you have finished
  14. If something goes wrong

0. How to read this guide

  • Commands are in grey boxes. Copy them exactly and paste them in the terminal of the PC named in the step, then press Enter. In most terminals you paste with Ctrl+Shift+V (or the right mouse button).
  • Text after # on a command line is a note for you: the computer ignores it.
  • sudo in front of a command runs it as the administrator. The first time it asks for your password (the one of your user, not of root). While you type a password nothing appears on the screen: that is normal.
  • "You should see" tells you the result of a step. If you see it, go on. If not, stop and look at §13: do not go on with a step that failed.
  • In this guide the PCs are called node-1, node-2 and node-3, with the addresses 192.168.10.11, .12 and .13. Use your own names and addresses if they are different, everywhere the same.

1. What you need

  • Three PCs, 64-bit (almost every PC of the last 15 years), each with at least 4 GB of memory and 2 cores. Old office PCs and mini PCs are fine.
  • A second disk in every PC is best: NEX keeps the cluster data there and erases everything on it. Without a second disk NEX uses a folder of the system disk, which is fine for trying. More disks can be added later, one at a time and without stopping the node: sudo nexctl storage disk-add sdc (Installation, §13), up to 16 per node.
  • A network that connects the three PCs: the same switch or router, with cables. Wi-Fi works, but it is slower and less reliable.
  • Access to the Internet from the PCs (to download Debian and NEX).
  • A USB stick of at least 2 GB for the Debian installer.
  • Another computer to prepare the USB stick (Windows, Mac or Linux).

Which disk is which. Before you begin, find out on every PC which disk is for the system and which is the second one, for example from the size. You will need it in §2 and in §7: choosing the wrong one erases data.


2. Install Debian on every PC

NEX runs on Debian 13 ("trixie"). Do this on all three PCs.

Prepare the USB stick (once, on the other computer):

  1. Download the installer from https://www.debian.org/download: the file is called debian-13.x.x-amd64-netinst.iso.
  2. Write it on the USB stick with a program that writes disk images: on Windows Rufus (https://rufus.ie) or balenaEtcher (https://etcher.balena.io), on a Mac balenaEtcher. Everything on the stick is erased.

Install (on every PC):

  1. Insert the stick and switch the PC on. To start from the stick, press the boot menu key while it starts (often F12, F11, F8 or Esc; it is written on the screen for a moment). Choose the USB stick.
  2. In the Debian menu choose Graphical install.
  3. Language, location, keyboard: your own.
  4. Hostname: node-1 on the first PC, node-2 on the second, node-3 on the third. Domain name: leave it empty.
  5. Root password: leave it empty and press Continue (twice). This way your user can become administrator with sudo, which is what this guide uses.
  6. Full name and username of your user: in this guide the user is admin. Choose a password and use the same password on all three PCs: you will need it in §8.
  7. Partitioning: choose Guided – use entire disk, then the system disk (not the second one!), then All files in one partition, then Finish partitioning and write changes to disk, and Yes.
  8. Package manager: choose a mirror in your country (the proposed one is fine). Popularity contest: as you like.
  9. Software selection: this is important. Remove the ticks from "Debian desktop environment" and from "GNOME", and leave or put the ticks on SSH server and standard system utilities. Cluster nodes do not need a desktop.
  10. Install the GRUB boot loader: Yes, on the system disk.
  11. At the end take out the stick and press Continue: the PC restarts.

You should see: a black screen asking node-1 login: (or node-2, node-3).


3. On every PC: first login and network

Log in with your user (admin) and its password.

You can work directly on the PC, or from another computer with ssh (ssh admin@ADDRESS from a terminal; on Windows from PowerShell). With ssh you can copy and paste the commands of this guide more easily. To find the address of the PC:

ip -br addr

You should see a line with UP and an address like 192.168.10.57/24: the name at the beginning of the line (here enp3s0) is your network card. Ignore the line lo.

Check the Internet:

ping -c 3 deb.debian.org

You should see three lines with bytes from and 0% packet loss.

A fixed address for every PC. The nodes find each other by address, so the address of each PC must never change. Choose one of the two ways:

  • On the router (recommended, nothing to change on the PCs). In the web page of your router look for "DHCP reservation", "static lease" or "address reservation", and give each PC a fixed address: node-1 → 192.168.10.11, node-2 → 192.168.10.12, node-3 → 192.168.10.13. Then restart the PCs (sudo reboot) and check with ip -br addr that each one has its address.

  • On the PC. Only if you cannot use the router. On node-1, replacing enp3s0 with the name of your network card and 192.168.10.1 with the address of your router:

    sudo tee /etc/network/interfaces.d/enp3s0 <<'EOF'
    auto enp3s0
    iface enp3s0 inet static
        address 192.168.10.11/24
        gateway 192.168.10.1
    EOF
    sudo sed -i '/enp3s0/d' /etc/network/interfaces    # removes the automatic (DHCP) address
    echo "nameserver 192.168.10.1" | sudo tee /etc/resolv.conf
    sudo reboot
    

    On node-2 the same with 192.168.10.12, on node-3 with 192.168.10.13. If you work with ssh, after the reboot connect to the new address.

You should see, after the reboot: ip -br addr shows the fixed address, and ping -c 3 deb.debian.org still answers.


4. On every PC: names, clock and a newer kernel

The names of the three PCs. Each PC must know the addresses of the others by name:

sudo tee -a /etc/hosts <<'EOF'
192.168.10.11 node-1
192.168.10.12 node-2
192.168.10.13 node-3
EOF

You should see, on every PC: ping -c 1 node-1, ping -c 1 node-2 and ping -c 1 node-3 all answer.

The clock. Certificates and logs need the clocks of the PCs to agree:

sudo apt install -y systemd-timesyncd
timedatectl | grep synchronized

You should see: System clock synchronized: yes (it can take a minute: if it says no, try again a little later).

A newer kernel (recommended). NEX works with the kernel of Debian 13, but with a newer one the shared folder answers sooner. Debian provides it in "backports":

echo "deb http://deb.debian.org/debian trixie-backports main" | sudo tee /etc/apt/sources.list.d/backports.list
sudo apt update
sudo apt install -y -t trixie-backports linux-image-amd64
sudo reboot

You should see, after the reboot: uname -r shows a number higher than 6.12 (for example 7.2.11+deb13-amd64).


5. On every PC: permission for the installation

When you add node-2 and node-3, the setup program connects from the new PC to the others and runs administrator commands there, without being able to ask for a password. So, for the duration of the installation, your user may use sudo without a password. You take this permission away at the end (§12).

On every PC:

echo "admin ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/nex-installazione
sudo chmod 440 /etc/sudoers.d/nex-installazione
sudo -k; sudo -n true && echo ok

(If your user is not called admin, write its name instead of admin in the first line.)

You should see: ok.


6. On every PC: the NEX packages

NEX is installed from the Arato Ingegneria package repository, which is public and signed: Debian checks that every package really comes from us.

sudo apt install -y curl gnupg
sudo curl -fsSL https://nex.aratoingegneria.it/apt/nex-archive-keyring.gpg -o /usr/share/keyrings/nex-archive-keyring.gpg
gpg --show-keys /usr/share/keyrings/nex-archive-keyring.gpg

You should see, among the lines, exactly this one (the fingerprint of our key):

      30D4902B708E39D4B8FB07FF7C0E601BD1181C30

If it is different, stop: the file is not ours. Write to info@aratoingegneria.it.

Then the repository and the packages:

sudo tee /etc/apt/sources.list.d/nex.sources <<'EOF'
Types: deb
URIs: https://nex.aratoingegneria.it/apt
Suites: trixie
Components: main
Signed-By: /usr/share/keyrings/nex-archive-keyring.gpg
EOF
sudo apt update
sudo apt install -y nex-cluster

The package is called nex-cluster. Do not install the package called nex: it is a different program of Debian. Nothing starts yet: the PC becomes a node in the next steps.

You should see: dpkg-query -W nex-cluster nexfs shows two lines, with the version (for example nex-cluster 1.0.0~beta1).


7. The first node

Only on node-1. This creates the cluster: its own certificate authority (the "key" that decides which PCs belong to it), the storage, the common folder /nex.

sudo nex-setup

The program asks a few questions. You should see, and answer:

This machine is not part of a NEX cluster yet. What do you want to do?
  1) Create a new cluster: this machine is its first node
  2) Add this machine to an existing cluster
  3) Exit
Choice [1]:

Press Enter (choice 1). Then:

  • Name of this node in the cluster [node-1]: press Enter.
  • Address of this node [1]: it shows the addresses of the PC: press Enter if the proposed one is 192.168.10.11, otherwise type the number of the right line. A note this address comes from DHCP is normal if you made it fixed on the router (§3).
  • Will this node also run programs (compute)? [Y/n] press Enter (yes).
  • Where should this node keep the cluster data? If the PC has a second, empty disk, it is proposed as choice 1 (the empty disk /dev/sdb ...): press Enter. It then asks you to type the name of the disk to confirm that it may erase it: type it (for example sdb) and press Enter. Check that the size is that of the second disk. Without a second disk choose a folder and press Enter on the proposed one.
  • A summary follows, then Proceed? [y/N]: type y and Enter.

In about ten seconds you should see:

  disk formatted (ext4) and mounted on /srv/nexfs/disco0 ... ok
  /etc/nex/node.json ... ok
  cluster certificate authority (CA) ... ok
  node certificate signed by the cluster CA ... ok
  disk encryption key (not shown) ... ok
  cluster storage: NEXFS metadata and data node, blocks in /srv/nexfs/disco0 ... ok
  cluster secrets key (not shown) ... ok
  local services ... ok
  shared filesystem /nex ... ok
  cluster users registry ... ok

Cluster created: node-1 is its first node and its admin node.

The first user of the cluster. The program then asks Create the first cluster user now? [Y/n]: press Enter, type the name (for example mario: lowercase letters and digits), then the password twice (password for cluster user mario: and again:, at least 8 characters). This user exists on all the nodes, with the same password and the same home folder /nex/home/mario.

Keep the certificate authority safe. The folder /etc/nex/ca on node-1 is the key of the cluster: it is needed to add nodes, and whoever has it can let PCs into the cluster. Copy it to a USB stick and keep it in a safe place:

sudo tar czf ~/nex-ca.tar.gz -C /etc/nex ca

(then copy nex-ca.tar.gz from your home folder to the stick, and delete it from the PC).

You should see, with these checks:

nex nodes
sudo nexfsctl health
df -h /nex
  • nex nodes: one line, node-1 ok;
  • nexfsctl health: it begins with {"status": "ok";
  • df -h /nex: the size of the common folder.

8. The other two nodes

On node-2:

sudo nex-setup
  • At Choice [1]: type 2 (Add this machine to an existing cluster).
  • Address or name of the admin node: type node-1.
  • The program checks that it can reach node-1 with ssh. The first time it cannot, and asks Create it now and copy it there (...)? [Y/n]: press Enter. It asks the password of your user on node-1 (admin@node-1's password:): type it. You should see Number of key(s) added: 1.
  • If the cluster already has other nodes (when you add node-3), it does the same for each of them: The key goes to node-2 too: type the password of admin on node-2. Type the password of your user on that PC.
  • Will this node run programs (compute)? [Y/n] press Enter (yes).
  • Will this node also keep cluster data (storage)? [y/N] type y and Enter. Careful: here the default is "no": if you only press Enter the node does not keep data, and the three copies of §9 are not possible.
  • The data disk: as on node-1 (Enter, then the name of the disk to confirm).
  • The summary, then Proceed? [y/N]: type y.

In about twenty seconds you should see:

  ...
  NEXFS: storage node (admitted by the admin node) ... ok
  local services ... ok
  peer node-2 on the other 1 nodes (in parallel) ... node-1 ok
  check ... all nodes answer
...
Node node-2 added to the cluster.

Then the same on node-3: at the end peer node-3 on the other 2 nodes (in parallel) ... node-1 ok, node-2 ok.

You should see, on node-1:

nex nodes                    # three lines, all "ok"
sudo nexfsctl health         # "status": "ok", with "meta_nodes": 3 and "data_nodes": 3

The first three nodes that keep data also keep the metadata (the names of the files and the folders) and decide together, by majority: with three, the cluster goes on even if one of them stops.


9. Three copies of every file, and a check

Three copies, one on each node. On node-1:

sudo nexfsctl copies 3

You should see a line with "copies": 3. From now on every file is kept on all three PCs. The size shown by df -h /nex already takes the copies into account: with three disks of 1 TB, about 1 TB.

The user at work. From any computer on the network (or from one of the nodes):

ssh mario@node-2                    # with the password of mario
touch ~/hello                       # a file in the home folder, on node-2
nex run --node node-3 ls -l hello   # the same file, seen from node-3
nex run --node node-1 hostname      # a command on node-1
exit

You should see: ls shows the file hello from node-3, and hostname prints node-1. The home folder is the same on every node.

(With ssh from one node to another, mario types his password again. To avoid it, he can create a key once: ssh-keygen and then cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys. Since the home folder is shared, the key works on all the nodes.)


10. The test: a PC goes off

This shows what the cluster is for. While everything is working, pull the power plug of node-3 (or hold its power button).

You should see, on node-1, after about twenty seconds:

  • nex nodes: node-3 unreachable, the others ok;
  • sudo nexfsctl health: "status": "warning", with the reasons metadata node 3 (node-3) does not answer and data node 3 (node-3) does not answer;
  • /nex keeps working on node-1 and node-2: you can read and write files, and nothing that had been saved is lost.

Switch node-3 on again. It starts by itself. You should see, within a minute or two: nex nodes with node-3 ok, and nexfsctl health back to "status": "ok". NEXFS copies to node-3 by itself what was written while it was off.


11. A fourth PC, for computing only

A PC that runs programs but keeps no data. Prepare it as in §2–§6 (with the name node-4 and its line in /etc/hosts on all the PCs), then:

sudo nex-setup

Choice 2, admin node node-1, the passwords for the keys, compute yes, storage no (Enter), summary y.

You should see: nex nodes with four nodes; on node-4 the folder /nex is there and mario logs in as on the others.

A further node that also keeps data is added the same way, answering y to the storage question: new files use it at once, the existing ones are spread over it in the background.


12. When you have finished

  • Remove the installation permission, on every PC (it is needed again only to add nodes):

    sudo rm /etc/sudoers.d/nex-installazione
    
  • The certificate authority: check that the copy of /etc/nex/ca (§7) is on the stick, in a safe place.

  • The web dashboard: from a browser, https://node-1:7443, with a cluster user.

  • Users: User guide. Services, virtual addresses and ports: Services.

  • Updates: sudo nexctl upgrade on node-1 updates the whole cluster, one node at a time, without stopping it (Installation, §16).

  • What NEX and its storage can do, and how they behave when something breaks: Limits and behaviour.


13. If something goes wrong

What you see Why What to do
ping deb.debian.org does not answer no Internet, or no DNS after the fixed address check the cable and the router; if you set the address on the PC, check the nameserver line in /etc/resolv.conf (§3)
ping node-2 says Name or service not known the names are missing in /etc/hosts redo the first part of §4 on that PC
System clock synchronized: no for a long time the PC cannot reach the time servers check the Internet; sudo systemctl restart systemd-timesyncd and try again after a minute
sudo -n true does not print ok the permission of §5 is missing or has a typo redo §5; check that the user name in the file is yours
apt update complains about the key or NO_PUBKEY the key file is missing or damaged redo the first box of §6
Unable to locate package nex-cluster the repository file is missing or has a typo redo the second box of §6, exactly
nex-setup: the ssh key could not be copied to node-1 wrong password, or ssh does not accept passwords check the password of your user on that PC; check that the SSH server is installed there (§2, step 9): sudo apt install openssh-server
sudo: a password is required while adding a node the permission of §5 is missing on the other PC do §5 on every PC
... is already in the cluster with address ... a node with that name already exists (perhaps a previous attempt) choose another name, or remove the old one on node-1: sudo nexctl agent peer-remove NAME
a node unreachable in nex nodes the PC is off, or the network does not reach it switch it on, check the cable; on that PC systemctl status nexagentd
nexfsctl health stays warning a node keeps not answering see the reasons in the output; on that node sudo journalctl -u nexagentd -u 'nexfs*' -n 50
/nex is not there (df -h /nex gives an error) the storage nodes cannot be reached sudo nexfsctl health on node-1; on the node without /nex: sudo journalctl -u nex-compute -n 50
nex-setup: no more input, stopping here. the input ended (for example with Ctrl-D) run sudo nex-setup again: what was already done is kept

To ask for help, run on node-1:

sudo nex report

It writes a file with the state of the cluster (without passwords and keys): send it to info@aratoingegneria.it with a description of what you did and what you see.