Install Slurm Rest API Ubuntu 22.04

Install Slurm Rest API:

The Slurm Rest API provides an endpoint to allow for submitting jobs, listing running jobs and other Slurm commands.

Installing the API server consists of the following components:

  • Database - I installed mysql.
  • slurmdbd - Slurm Database Daemon.
  • slurmrestd - Interface to Slurm via REST API.

Configure slurm JWT support:

Slurm JWT Documentaion

dd if=/dev/random of=/var/spool/slurm/statesave/jwt_hs256.key bs=32 count=1
chown slurm:slurm /var/spool/slurm/statesave/jwt_hs256.key
chmod 0600 /var/spool/slurm/statesave/jwt_hs256.key
chown slurm:slurm /var/spool/slurm/statesave
chmod 0755 /var/spool/slurm/statesave

Update both the slurm.conf and slurmdbd.conf and add:

AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/spool/slurm/statesave/jwt_hs256.key

To create a user token:

scontrol token username=$USER lifespan=$LIFESPAN

Install and configure mysql:

sudo apt install mysql-server

As root:

mysql
grant all on slurm_acct_db.* TO 'slurm'@'localhost' identified by 'some_pass' with grant option;

Install and configure slurmdbd:

sudo apt install slurmdbd

Create the /etc/slurm/slurmdbd.conf file, this is a copy of the one I used:

cat /etc/slurm/slurmdbd.conf 
AuthType=auth/munge
AuthInfo=/var/run/munge/munge.socket.2
AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/spool/slurm/statesave/jwt_hs256.key
DbdHost=localhost
DebugLevel=debug5
StorageHost=localhost
StorageLoc=slurm_acct_db
StoragePass=SLURM-USER-MYSQL-PASSWORD
StorageType=accounting_storage/mysql
StoragePort=3306
StorageUser=slurm
LogFile=/opt/slurm/log/slurmdbd.log
PidFile=/tmp/slurmdbd.pid
SlurmUser=slurm

Update the /etc/slurm/slurm.conf file and add:

AccountingStorageHost=localhost

Note: Do not enter the Slurm mysql password"

#AccountingStoragePass=   
AccountingStorageType=accounting_storage/slurmdbd
AccountingStorageUser=slurm

Start the Slurm database daemon:

systemctl start slurmdbd

Install the Slurm rest API:

sudo apt install slurmrest

The Rest daemon has to run as a non-privedged user so a user has to be created:

sudo adduser slurmrest

Edit the slurmrest service and add the slurmrest user:

sudo vi /usr/lib/systemd/system/slurmrestd.service

Update the following:

# an unpriviledged user to run as.
User=slurmrest
Group=slurmrest
Environment="SLURM_JWT=daemon"

Start the Rest service:

sudo systemctl start slurmrestd

Restart the Slurm controller service:

sudo systemctl daemon-reload
sudo systemctl restart slurmctld

Copy the /etc/slurm/slurm.conf to all of the compute nodes and restart slurmd


You'll only receive email when they publish something new.

More from Ken G
All posts