Keeping nodes up to date takes time, especially if you have several nodes and are dealing with them all one-by-one.
The scripts referred to in this document are located on my Github at:
They are designed to automate and streamline processes allowing one to manage larger groups of nodes in an easier and more time-efficient manner.
These tools have been created for the use of myself and a few others. If you plan to use them, please take some time to read through the scripts and understand them.
Also, please do not be afraid of any jargon. The process of using the scripts will be shown below clearly (hopefully).
WHAT THE SCRIPTS DO
This script streamlines the process of setting up SSH key-based authentication. VPS IP addresses are read from the "ip_addresses" text file that you will setup below. Managing multiple nodes is MUCH easier when using SSH keys to access each VPS. We need SSH key-based authentication set up in order to use the actual "updating" script we're going to use.
This script sequentially updates ONLY THE OPERATING SYSTEM on EVERY node that has its IP address in the "ip_addresses" text file that you will setup below. After updating the OS, it then deactivates the node, reboots the VPS and finally reactivates the node. It then moves on to the next VPS and performs the same procedure. SSH key-based authentication needs to be already setup in order for this script to be useful.
ITEMS TO NOTE
- You will need a computer (running Ubuntu 20.04) that these scripts will be installed on (eg. laptop, desktop, virtual machine, VPS). If you are already using the Plugin/StorX Multinode Tools as well, then these scripts can all be installed on the same computer.
- If you install them on a VPS, please ensure that the VPS host allows outgoing ssh (ie that outgoing connections on port 22 are allowed). Some VPS providers block outgoing ssh initially and you have to then specifically unblock it in their control panel.
- The computer you setup for these updates should be one YOU control and only YOU have access to. Using SSH key-based authentication means that this administration computer can connect to your nodes whenever it needs to without needing you to manually enter the password for the node VPS. This is by design and is how the scripts manage to run multiple commands to update each node whilst remaining unattended. As you can see, this computer must not be a random public computer. It must be your computer that you control with your own passwords.
Logon to (or access the terminal on) the computer you will be using for administering your XDC nodes. You will need to be at the command prompt in the terminal in order to perform the following steps.
Update the system and install base packages. (Note: You need to run a sudo command before cloning the script repository or you will find that the multi-command process will exit early before cloning the git repo to your local drive. Doesn't really matter which command you sudo. The most useful sudo command to run is a quick update of the OS and ensuring the base packages you will need are installed. You can do this by running the command shown here):
sudo apt update -y && sudo apt upgrade -y && sudo apt install -y git ssh && sudo apt autoremove -y
- Clone the scripts repository (Note: Preserves any preexisting ip_addresses file in local git repo):
cd $HOME mv XDC_Multinode_Tools/ip_addresses . > /dev/null 2>&1 sudo rm -r XDC_Multinode_Tools > /dev/null 2>&1 git clone https://github.com/s4njk4n/XDC_Multinode_Tools.git cd XDC_Multinode_Tools mv ~/ip_addresses . > /dev/null 2>&1 chmod +x *.sh
- Make sure to press ENTER after pasting the above code into the terminal
CUSTOMISE THE "ip_addresses" FILE
- Open the "ip_addresses" file in nano:
On EACH LINE enter the IP address of only ONE of the nodes you wish to be accessed by the update scripts. There should be NO SPACES before the ip address on any line. (The first character of each line should be the first digit of the ip address you are putting on that line). Press ENTER at the end of each line after you finishing entering the last digit of the IP address. The exception to this is that when you have entered your FINAL IP address you will NOT press ENTER to create a new line at the end of the file.
Once all the node IP addresses have been entered, we need to exit nano and save the file:
Press "CTRL+X" Press "y" Press "ENTER"
SETUP SSH KEY-BASED AUTHENTICATION
(Note: You must have setup the "ip_addresses" file in the above section first)
If you have already generated SSH keys earlier (if you're also using and have already installed the Plugin/StorX Multinode Tools for example), please skip this key-generation step and proceed directly to the next section below with the heading "Register SSH Keys On Nodes"
- Create your SSH keys that will be used for authentication:
- You will then be asked several questions to generate the key. Just keep pressing ENTER to accept the default responses. When finished, you'll arrive back at your normal command prompt.
REGISTER SSH-KEYS ON NODES
- Run the set_XDC_SSH_auth.sh script:
cd ~/XDC_Multinode_Tools && ./set_XDC_SSH_auth.sh
For each node you will also receive a request to enter the password (for the node indicated by the ip address shown in the prompt). Put in your password for that node and press ENTER.
By doing the above steps the script will sequentially access each node and copy your SSH credentials to it.
TO UPDATE ONLY THE OPERATING SYSTEM AND THEN REBOOT ALL YOUR VPS's
First you need to know roughly how long it takes to reboot the node you want to update. The script will ask you how many seconds to allow for the node to complete rebooting (It gets rebooted as part of the update process).
Run the OS-updating script:
cd ~/XDC_Multinode_Tools && ./update_XDC_OSonly_and_reboot_auto.sh
You will be prompted to enter how long the script should wait to allow for your nodes to reboot. If you enter a time that is too short, then the update process will fail. If you enter a time that is longer than the time it takes your node VPS to reboot, this is no major problem as it will just mean that the update process will just take a little longer. The time you enter should just be the number of seconds to wait.
For example, to wait 60sec, one would just type 60 and press ENTER. Be aware that some commercial VPS providers have reboot times that are VERY SLOOOOOOW. If you're not sure how long it takes for yours or if you want to be on the safe side then just pick something long like 300 seconds (ie. type 300 and press ENTER)
All of your VPS's that have their IP addresses listed in the "ip_addresses" file will now sequentially have their operating system updated followed by node deactivation, a system reboot and then reactivation of the node.
For some easy reading to get a better understanding of how the network and nodes work and some practical node examples, feel free to read these older Medium articles (Note: The node software directory structure and commands have slightly changed since these articles below were published but the principles remain the same):
XDC Network: How to Migrate a Full-Node from a Local Ubuntu 20.04 “One-Click Installer” to “Docker” on the Same Machine
XDC Network: How to Migrate a Full-Node from a Local Ubuntu 20.04 “One-Click Installer” to “Docker” on a Remote Ubuntu 20.04 Server
XDC Network: How to Improve the Peer-count of your Full Node