Install a Node - Separate the Installation Process - General - Algorand

Install a Node - Separate the Installation Process

post by algodeveloper on Jan 20, 2023

Need clarification, as I tried to install a node and have been waiting days for the node block to initialize up to latest block on TestNet. Then after 10 days for some unknown reason the systemctl service for algorand somehow resets itself, restarts itself, and changes the service file back to use -d /var/lib/algorand.

Now I have all of the set of algorand node files in 2 directories.

  1. /var/lib/algorand
  2. /var/lib/algorand/node/

I used the Red Hat distribution centos env section and edited the system service file (Probably wrong way) for -d to be /var/lib/algorand/node/testnetdata and set ALGORAND_DATA env var.

sudo -u algorand -E -s
cd /var/lib/algorand/

add to end of file
vi .bashrc

export ALGORAND_DATA="${HOME}/node/testnetdata"
export PATH="${HOME}/node:${PATH}"

All I want is for this to be easy to read and easy to do.

  1. To make it easier for everyone. Can you please split up this documentation link to be 5 separate webpages.
    • webpage 1. Requirements to install a node - Hardware
    • webpage 2. Installation with a package manager for Debian based distributions
    • webpage 3. Installation with a package manager for Red Hat based distributions
    • webpage 4. Installing on Linux using wget (these not verified, but should work)
    • webpage 5. Installation with the updater script for Mac

Then each webpage has the same sections but specific to the env:

I’m fine with /usr/bin having algod and goal.

su -l algodev
cd /home/algodev/
/usr/bin/sudo -u algorand -E -s goal node status -w 6000 -d /var/lib/algorand/node/testnetdata
wget https://algorand-catchpoints.s3.us-east-2.amazonaws.com/channel/betanet/latest.catchpoint
wget https://algorand-catchpoints.s3.us-east-2.amazonaws.com/channel/testnet/latest.catchpoint
wget https://algorand-catchpoints.s3.us-east-2.amazonaws.com/channel/mainnet/latest.catchpoint
vi latest.catchpoint
sudo -u algorand -E -s goal node catchup <CATCHPOINT_TOKEN> -d /var/lib/algorand/node/testnetdata

Since systemctl is running node as a service, can I even use goal node catchup?

Another question I have, is if I installed with Red Hat package manager, how do I do an update when using systemctl? anything like yum update. When using the systemctl service approach, should I never use update.sh script? This copies all files, same as an install, but to cwd. I like the update script as that’s how I first started to use algorand and running node with goal commands.

Another question I have is about the algorand@.service.template (which isn’t included, or I can’t find it when installing using Red Hat package manager), can we add this as part of Red Hat package manager install? Can the notes in the template file be explicit? Instead of asterisk can it be algorand and so I’m not giving access to any service to the algo user, just algorand service to algo user.

Another question is, can we suppress the amount of writes to the node log file during an initialization? Just a guess, but once this log file gets to be really big it slows the initialization down much so. Just an idea. My assumption is using a catchup can’t be done before an initialization is complete.

To allow the update script (which runs as the algo user) to manipulate the algorand systemd service, the following lines need to be added to /etc/sudoers (using visudo):

algo ALL=(ALL) NOPASSWD: /usr/bin/systemctl start *
algo ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop *
algo ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart *
algo ALL=(ALL) NOPASSWD: /usr/bin/systemctl status *

I would be happy spending my time reviewing these new separate Install a Node webpages, answering every possible question and providing feedback… than getting stuck over and over guessing on what I did wrong and how to figure out how to do it right.

post by algodeveloper on Jan 22, 2023

After further looking into, I am understanding the systemctl flow. The comments about the update script should be a separate topic as my original intentions are to use the systemctl service algorand with Red Hat based distribution which already installs the service for you.

The update script is for installing on Linux using wget which doesn’t preinstall the service.

So back to further looking into systemctl flow, the Template unit algorand@.service is the file to edit and then copy to algorand.service. The systemctl manager may refresh at any time the Instance unit (algorand.service file) so make sure changes are done in the Template unit.

Template unit is /lib/systemd/system/algorand@.service

Instance unit is /lib/systemd/system/algorand.service

After changes to Template unit, I hardcoded the -d /var/lib/algorand/node/testnetdata, just do a copy algorand@.service algorand.service as root in /lib/systemd/system/

ls -l /lib/systemd/system/algorand*

-rw-r–r–. 1 root root 458 Jan 22 17:32 /lib/systemd/system/algorand.service -rw-r–r–. 1 root root 1276 Jan 22 17:29 /lib/systemd/system/algorand@.service

ls -l /usr/lib/systemd/system/algorand*

-rw-r–r–. 1 root root 458 Jan 22 17:32 /usr/lib/systemd/system/algorand.service -rw-r–r–. 1 root root 1276 Jan 22 17:29 /usr/lib/systemd/system/algorand@.service

The one question I still have after reading the link below is since algorand@.service uses the %I, which is %i: This references the instance name, and algorand@.service doesn’t have an instance name, i.e., algorand@-var-lib-algorand-node-testnetdata.service, (instance name is escaped -var-lib-algorand-node-testnetdata) I assume the user, algorand user’s $HOME path is assumed and so defaults to start in the /var/lib/algorand dir. That was my mistake. I changed the instance unit file, systemctl did a refresh of some sort, and reloaded Template units to Instance units and then ran using -d /var/lib/algorand/ dir.

Below is how I plan to change service in Template unit file for TestNet to MainNet.

[Service]
ExecStart=/usr/bin/algod -d /var/lib/algorand/node/testnetdata
# ExecStart=/usr/bin/algod -d /var/lib/algorand/node/mainnetdata
# ExecStart=/usr/bin/algod -d %I

Still need to look into - if goal commands for catchup can work when using systemctl start algorand

sudo -u algorand -E -s goal node catchup <CATCHPOINT_TOKEN> -d /var/lib/algorand/node/testnetdata

As I know I can do a sudo -u algorand -E -s goal node status -d /var/lib/algorand/node/testnetdata as a different user and it works.