Difference between revisions of "Slurm Install"

From CMU ITSC Network
Line 171: Line 171:
  
 
==== Config Slurm ====
 
==== Config Slurm ====
 +
เข้าเว็บ http://slurm.schedmd.com/configurator.easy.html เพื่อทำการสร้าง slurm.conf
 +
 +
* ใส่ Cluster Name ตามต้องการ
 +
* ใส่ Control Machine เป็นเครื่อง Headnode
 +
* ใส่ NodeName เป็นเครื่องที่มีเช่น sluem-test-[01-03]
 +
* ใส่ CPUs ตามทรัพยากรณ์ของเครื่อง
 +
* เปลี่ยน Process Tracking เป็น pgid
 +
* จากนั้นกด submit จะได้ text config มา
 +
 +
ก็อบทั้งหมดไปยัง slurm.conf ในเครื่อง Headnode<syntaxhighlight lang="linux-config">
 +
cd /etc/slurm
 +
vi slurm.conf
 +
เปลี่ยนคอนฟิกบางอย่างในหมวด #COMPUTE NODES ในส่วนของ Nodename เป็น
 +
NodeName=slurm-01 NodeAddr=10.98.6.51 CPUs=2 State=UNKNOWN
 +
NodeName=slurm-02 NodeAddr=10.98.6.52 CPUs=2 State=UNKNOWN
 +
NodeName=slurm-03 NodeAddr=10.98.6.53 CPUs=2 State=UNKNOWN
 +
</syntaxhighlight>จากนั้น Copy slurm.conf ไปยง Node อื่น ๆ<syntaxhighlight lang="linux-config">
 +
scp slurm.conf root@10.98.6.52:/etc/slurm/slurm.conf
 +
scp slurm.conf root@10.98.6.53:/etc/slurm/slurm.conf
 +
</syntaxhighlight>สร้างโฟล์เดอร์เก็บ log ตามไฟล์คอนฟิก
 +
 +
บนเครื่อง Headnode<syntaxhighlight lang="linux-config">
 +
mkdir /var/spool/slurmctld
 +
chown slurm: /var/spool/slurmctld
 +
chmod 755 /var/spool/slurmctld
 +
touch /var/log/slurmctld.log
 +
chown slurm: /var/log/slurmctld.log
 +
touch /var/log/slurm_jobacct.log /var/log/slurm_jobcomp.log
 +
chown slurm: /var/log/slurm_jobacct.log /var/log/slurm_jobcomp.log
 +
</syntaxhighlight>บนเครื่อง Compute<syntaxhighlight lang="linux-config">
 +
mkdir /var/spool/slurmd
 +
chown slurm: /var/spool/slurmd
 +
chmod 755 /var/spool/slurmd
 +
touch /var/log/slurmd.log
 +
chown slurm: /var/log/slurmd.log
 +
</syntaxhighlight>เช็คคอนฟิกด้วยคำสั่ง<syntaxhighlight lang="linux-config">
 +
slurmd -C
 +
</syntaxhighlight>จะแสดงชื่อเครื่องของตัวเอง เช่น<syntaxhighlight lang="linux-config">
 +
NodeName=slurm-test-01 CPUs=2 Boards=1 SocketsPerBoard=2 CoresPerSocket=1 ThreadsPerCore=1 RealMemory=1819
 +
UpTime=0-00:05:58
 +
</syntaxhighlight>Firewall อาจบล็อกการติดต่อระหว่าง Node ให้ปิดการใช้งานของ Firewall ในทุก Node compute<syntaxhighlight lang="linux-config">
 +
systemctl stop firewalld
 +
systemctl disable firewalld
 +
</syntaxhighlight>เสริมถ้าเครื่อง Headnode ไม่ได้เป็น Compute ด้วย ให้เพิ่มคอนฟิก Firewall เป็น<syntaxhighlight lang="linux-config">
 +
firewall-cmd --permanent --zone=public --add-port=6817/udp
 +
firewall-cmd --permanent --zone=public --add-port=6817/tcp
 +
firewall-cmd --permanent --zone=public --add-port=6818/tcp
 +
firewall-cmd --permanent --zone=public --add-port=6818/tcp
 +
firewall-cmd --permanent --zone=public --add-port=7321/tcp
 +
firewall-cmd --permanent --zone=public --add-port=7321/tcp
 +
firewall-cmd --reload
 +
</syntaxhighlight>เรื่มการใช้งาน Slurm โดยเครื่องที่เป็น Headnode<syntaxhighlight lang="linux-config">
 +
systemctl enable slurmctld.service
 +
systemctl start slurmctld.service
 +
systemctl status slurmctld.service
 +
</syntaxhighlight>เครื่องที่เป็น Compute<syntaxhighlight lang="linux-config">
 +
systemctl enable slurmd.service
 +
systemctl start slurmd.service
 +
systemctl status slurmd.service
 +
</syntaxhighlight>ดูสถานะของเครื่องใน Cluster โดยใช้<syntaxhighlight lang="linux-config">
 +
sinfo
 +
</syntaxhighlight>เช็ค Status โดยใช้คำสั่ง<syntaxhighlight lang="linux-config">
 +
tail /var/log/slurmd.log
 +
</syntaxhighlight>คำสั่งเปลี่ยนสถานะเครื่อง เมื่อ Active แล้วสถานะยังเป็น Down และไม่มี Error เกิดขึ้น<syntaxhighlight lang="linux-config">
 +
scontrol update nodename=[ชื่อโหนดที่เป็นสถานะ down หรือ อื่น ๆ] state=idle
 +
</syntaxhighlight>
 +
 +
==== เสริมการเซ็ตเวลาของแต่ละเครื่องให้ตรงกันโดยใช้ (NTP) ====
 +
<syntaxhighlight lang="linux-config">
 +
yum install ntp
 +
chkconfig ntpd on
 +
ntpdate ntp.cmu.ac.th
 +
systemctl start ntpd
 +
</syntaxhighlight>

Revision as of 13:01, 26 November 2021

การติดตั้ง

ทรัพยากรที่ใช้ในการติดตั้ง ประกอบไปด้วยเครื่องทั้งหมด 3 เครื่องโดยให้เครื่องแรกเป็น Headnode จะลง slurmctld, slurmdbd, slurmd ส่วนเครื่องที่เหลือเป็นเครื่อง computenode ลงแค่ตัว slurmd ทั้งหมดเป็น CentOS7

Hostname ip address
slurm-test-01 10.98.6.51
slurm-test-02 10.98.6.52
slurm-test-03 10.98.6.53

แนะนำให้ Login ด้วย Root ในการติดตั้ง เพราะบางคำสั่งจะติด Permission

เปลี่ยน Hostname และเพิ่ม Hosts

hostnamectl set-hostname slurm-test-01

เพิ่ม ip ลงในบรรทัดสุดท้าย

vi /etc/hosts

..
..
10.98.6.51  slurm-test01

Restart network แล้ว Login ใหม่

sudo systemctl restart network
hostnamectl status
exit

สร้าง Global users ให้กับทุก Node

export MUNGEUSER=991
groupadd -g $MUNGEUSER munge
useradd  -m -c "MUNGE Uid 'N' Gid Emporium" -d /var/lib/munge -u $MUNGEUSER -g munge  -s /sbin/nologin munge
export SLURMUSER=992
groupadd -g $SLURMUSER slurm
useradd  -m -c "SLURM workload manager" -d /var/lib/slurm -u $SLURMUSER -g slurm  -s /bin/bash slurm

ตรวจสอบว่าสร้าง user แล้ว

cat /etc/group | grep -e munge -e slurm
และ
cat /etc/passwd | grep -e munge -e slurm

ติดตั้ง Munge

Install REPL repository

yum install epel-release -y

Install Munge

yum install munge munge-libs munge-devel -y

สร้าง Secret key จากเครื่อง Headnode

dd if=/dev/urandom bs=1 count=1024 > /etc/munge/munge.key
chown munge: /etc/munge/munge.key
chmod 400 /etc/munge/munge.key

ก็อป key ไปยังเครื่องที่เหลือ

scp /etc/munge/munge.key root@10.98.6.52:/etc/munge/munge.key
scp /etc/munge/munge.key root@10.98.6.53:/etc/munge/munge.key

SSH ไปยังทุก Node เปลี่ยน Permission แล้วเริ่ม Munge service

chown -R munge: /etc/munge/ /var/log/munge/
chmod 0700 /etc/munge/ /var/log/munge/
systemctl enable munge
systemctl start munge

ทดสอบ Munge ว่าติดต่อไปยังเครื่องอื่นได้หรือไม่ โดยเข้าจาก Headnode

munge -n
munge -n | munge
munge -n | ssh 10.98.6.52 unmunge
remunge

ถ้าไม่เจอ error แสดงว่า Munge ทำงานได้ปกติ

ติดตั้ง Slurm

ติดตั้ง service ต่าง ๆ ที่ Slurm ต้องใช้งาน

yum install openssl openssl-devel pam-devel numactl numactl-devel hwloc hwloc-devel lua lua-devel readline-devel rrdtool-devel ncurses-devel man2html libibmad libibumad -y

ติดตั้ง NFS Server เพื่อ Share folder

NFS Server (Headnode)

สร้างโฟล์เดอร์ที่ต้องการแชร์ที่ไหนก็ได้ โดยในที่นี้จะสร้างไว้ใน /var/nfsshare

yum install nfs-utils -y
systemctl start nfs-server rpcbind
systemctl enable nfs-server rpcbind
mkdir /var/nfsshare
chmod -R 755 /var/nfsshare

ตั้งค่าให้ NFS ทำงานทุกครั้งเมื่อเปิดเครื่อง

systemctl enable rpcbind
systemctl enable nfs-server
systemctl enable nfs-lock
systemctl enable nfs-idmap
systemctl start rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap

Config ไฟล์สำหรับการแชร์

vi /etc/exports
/var/nfsshare    10.98.6.0/24(rw,sync,no_root_squash,no_all_squash)
exportfs -r
systemctl restart nfs-server

เพิ่ม NFS Service เข้าไปใน Firewall

firewall-cmd --permanent --zone=public --add-service=nfs
firewall-cmd --permanent --zone=public --add-service=mountd
firewall-cmd --permanent --zone=public --add-service=rpc-bind
firewall-cmd --reload
NFS Client (Compute node)

ไปยังเครื่องที่หลือแล้วลง NFS Client

yum install nfs-utils -y

เช็คโฟล์ดอร์ที่มีแชร์จากเครื่องหลัก

showmount -e 10.98.6.51

สร้าง Folder ที่ต้องการให้เห็นไฟล์ที่แชร์มา โดยในที่นี้จะให้เป็น Path เดียวกันกับเครื่อง Headnode พร้อม Mount เข้ามา

mkdir -p /var/nfsshare
mount -t nfs 10.98.6.51:/var/nfsshare /var/nfsshare
วิธี Mount แบบถาวร

ถ้าไม่ทำการ Mount แบบถาวร เมื่อปิดเครื่องแล้วเปิดใหม่ขึ้นมาตัว Folder ที่ Mount จะหายไป ทำให้ต้อง mount ใหม่ถ้าจะใช้งาน

vi /etc/fstab
10.98.6.51:/var/nfsshare /var/nfsshare nfs defaults 0 0
วิธีการ Unmount
umount 10.98.6.51:/var/nfsshare

ติดตั้ง Slurm (ต่อ)

Download ไฟล์ติดตั้งมาไว้ที่เครื่อง Headnode ใน Path /var/nfsshare (ในที่นี้เป็นเวอร์ชัน 20.08.4)

cd /var/nfsshare
yum install wget -y
wget https://download.schedmd.com/slurm/slurm-21.08.4.tar.bz2

ลง rpmbuild

yum install rpm-build
yum install python3 readline-devel 
yum install perl pam-devel perl-ExtUtils\* 
yum install mariadb-server mariadb-devel
yum install gcc gcc-c++ make

Build ไฟล์ที่โหลดมา

rpmbuild -ta slurm-21.8.4.tar.bz2

เมื่อ Build เสร็จจะมี Folder rmbuild ขึ้นมา เข้าไปยังไฟล์ที่ได้จากการ Build

cd rpmbuild/RPMS/x86_64

ลงทุกตัวด้วยคำสั่ง

yum --nogpgcheck localinstall *

ไปยัง Shared folder ที่เครื่องอื่น ๆ เพื่อลงเหมือนกัน

Config Slurm

เข้าเว็บ http://slurm.schedmd.com/configurator.easy.html เพื่อทำการสร้าง slurm.conf

  • ใส่ Cluster Name ตามต้องการ
  • ใส่ Control Machine เป็นเครื่อง Headnode
  • ใส่ NodeName เป็นเครื่องที่มีเช่น sluem-test-[01-03]
  • ใส่ CPUs ตามทรัพยากรณ์ของเครื่อง
  • เปลี่ยน Process Tracking เป็น pgid
  • จากนั้นกด submit จะได้ text config มา

ก็อบทั้งหมดไปยัง slurm.conf ในเครื่อง Headnode

cd /etc/slurm
vi slurm.conf
เปลี่ยนคอนฟิกบางอย่างในหมวด #COMPUTE NODES ในส่วนของ Nodename เป็น
NodeName=slurm-01 NodeAddr=10.98.6.51 CPUs=2 State=UNKNOWN
NodeName=slurm-02 NodeAddr=10.98.6.52 CPUs=2 State=UNKNOWN
NodeName=slurm-03 NodeAddr=10.98.6.53 CPUs=2 State=UNKNOWN

จากนั้น Copy slurm.conf ไปยง Node อื่น ๆ

scp slurm.conf root@10.98.6.52:/etc/slurm/slurm.conf
scp slurm.conf root@10.98.6.53:/etc/slurm/slurm.conf

สร้างโฟล์เดอร์เก็บ log ตามไฟล์คอนฟิก บนเครื่อง Headnode

mkdir /var/spool/slurmctld
chown slurm: /var/spool/slurmctld
chmod 755 /var/spool/slurmctld
touch /var/log/slurmctld.log
chown slurm: /var/log/slurmctld.log
touch /var/log/slurm_jobacct.log /var/log/slurm_jobcomp.log
chown slurm: /var/log/slurm_jobacct.log /var/log/slurm_jobcomp.log

บนเครื่อง Compute

mkdir /var/spool/slurmd
chown slurm: /var/spool/slurmd
chmod 755 /var/spool/slurmd
touch /var/log/slurmd.log
chown slurm: /var/log/slurmd.log

เช็คคอนฟิกด้วยคำสั่ง

slurmd -C

จะแสดงชื่อเครื่องของตัวเอง เช่น

NodeName=slurm-test-01 CPUs=2 Boards=1 SocketsPerBoard=2 CoresPerSocket=1 ThreadsPerCore=1 RealMemory=1819
UpTime=0-00:05:58

Firewall อาจบล็อกการติดต่อระหว่าง Node ให้ปิดการใช้งานของ Firewall ในทุก Node compute

systemctl stop firewalld
systemctl disable firewalld

เสริมถ้าเครื่อง Headnode ไม่ได้เป็น Compute ด้วย ให้เพิ่มคอนฟิก Firewall เป็น

firewall-cmd --permanent --zone=public --add-port=6817/udp
firewall-cmd --permanent --zone=public --add-port=6817/tcp
firewall-cmd --permanent --zone=public --add-port=6818/tcp
firewall-cmd --permanent --zone=public --add-port=6818/tcp
firewall-cmd --permanent --zone=public --add-port=7321/tcp
firewall-cmd --permanent --zone=public --add-port=7321/tcp
firewall-cmd --reload

เรื่มการใช้งาน Slurm โดยเครื่องที่เป็น Headnode

systemctl enable slurmctld.service
systemctl start slurmctld.service
systemctl status slurmctld.service

เครื่องที่เป็น Compute

systemctl enable slurmd.service
systemctl start slurmd.service
systemctl status slurmd.service

ดูสถานะของเครื่องใน Cluster โดยใช้

sinfo

เช็ค Status โดยใช้คำสั่ง

tail /var/log/slurmd.log

คำสั่งเปลี่ยนสถานะเครื่อง เมื่อ Active แล้วสถานะยังเป็น Down และไม่มี Error เกิดขึ้น

scontrol update nodename=[ชื่อโหนดที่เป็นสถานะ down หรือ อื่น ๆ] state=idle

เสริมการเซ็ตเวลาของแต่ละเครื่องให้ตรงกันโดยใช้ (NTP)

yum install ntp
chkconfig ntpd on
ntpdate ntp.cmu.ac.th
systemctl start ntpd