Difference between revisions of "Slurm Install"

From CMU ITSC Network
 
(5 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
!Hostname
 
!Hostname
 
!ip address
 
!ip address
 +
!Type
 
|-
 
|-
 
|slurm-test-01
 
|slurm-test-01
 
|10.98.6.51
 
|10.98.6.51
 +
|Headnode & Compute
 
|-
 
|-
 
|slurm-test-02
 
|slurm-test-02
 
|10.98.6.52
 
|10.98.6.52
 +
|Compute node
 
|-
 
|-
 
|slurm-test-03
 
|slurm-test-03
 
|10.98.6.53
 
|10.98.6.53
 +
|Compute node
 
|}
 
|}
 
แนะนำให้ Login ด้วย Root ในการติดตั้ง เพราะบางคำสั่งจะติด Permission
 
แนะนำให้ Login ด้วย Root ในการติดตั้ง เพราะบางคำสั่งจะติด Permission
  
เปลี่ยน Hostname และเพิ่ม Hosts<syntaxhighlight lang="linux-config">
+
เปลี่ยน Hostname แต่ละเครื่อง<syntaxhighlight lang="linux-config">
 
hostnamectl set-hostname slurm-test-01
 
hostnamectl set-hostname slurm-test-01
  
</syntaxhighlight>เพิ่ม ip ลงในบรรทัดสุดท้าย<syntaxhighlight lang="linux-config">
+
</syntaxhighlight>เพิ่ม Hosts โดยเพิ่ม ip ลงในบรรทัดสุดท้ายของไฟล์ Hosts<syntaxhighlight lang="linux-config">
 
vi /etc/hosts
 
vi /etc/hosts
 
..
 
..
Line 194: Line 198:
 
vi slurm.conf
 
vi slurm.conf
 
เปลี่ยนคอนฟิกบางอย่างในหมวด #COMPUTE NODES ในส่วนของ Nodename เป็น
 
เปลี่ยนคอนฟิกบางอย่างในหมวด #COMPUTE NODES ในส่วนของ Nodename เป็น
NodeName=slurm-01 NodeAddr=10.98.6.51 CPUs=2 State=UNKNOWN
+
NodeName=slurm-test-01 NodeAddr=10.98.6.51 CPUs=2 State=UNKNOWN
NodeName=slurm-02 NodeAddr=10.98.6.52 CPUs=2 State=UNKNOWN
+
NodeName=slurm-test-02 NodeAddr=10.98.6.52 CPUs=2 State=UNKNOWN
NodeName=slurm-03 NodeAddr=10.98.6.53 CPUs=2 State=UNKNOWN
+
NodeName=slurm-test-03 NodeAddr=10.98.6.53 CPUs=2 State=UNKNOWN
 
</syntaxhighlight>จากนั้น Copy slurm.conf ไปยง Node อื่น ๆ<syntaxhighlight lang="linux-config">
 
</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.52:/etc/slurm/slurm.conf
Line 233: Line 237:
 
firewall-cmd --reload
 
firewall-cmd --reload
 
</syntaxhighlight>เรื่มการใช้งาน Slurm โดยเครื่องที่เป็น Headnode<syntaxhighlight lang="linux-config">
 
</syntaxhighlight>เรื่มการใช้งาน Slurm โดยเครื่องที่เป็น Headnode<syntaxhighlight lang="linux-config">
systemctl enable slurmctld.service
+
systemctl enable slurmctld
systemctl start slurmctld.service
+
systemctl start slurmctld
systemctl status slurmctld.service
+
systemctl status slurmctld
</syntaxhighlight>เครื่องที่เป็น Compute<syntaxhighlight lang="linux-config">
+
</syntaxhighlight>เครื่องที่เป็น Compute (ในกรณีนี้จะใช้เครื่อง Headnode มา Compute ด้วย จึงต้องเปิด Service slurmd)<syntaxhighlight lang="linux-config">
systemctl enable slurmd.service
+
systemctl enable slurmd
systemctl start slurmd.service
+
systemctl start slurmd
systemctl status slurmd.service
+
systemctl status slurmd
 
</syntaxhighlight>ดูสถานะของเครื่องใน Cluster โดยใช้<syntaxhighlight lang="linux-config">
 
</syntaxhighlight>ดูสถานะของเครื่องใน Cluster โดยใช้<syntaxhighlight lang="linux-config">
 
sinfo
 
sinfo
Line 255: Line 259:
 
ntpdate ntp.cmu.ac.th
 
ntpdate ntp.cmu.ac.th
 
systemctl start ntpd
 
systemctl start ntpd
 +
</syntaxhighlight>ติดตั้ง Module Libary<syntaxhighlight lang="linux-config">
 +
yum install openmpi-devel
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
== อ้างอิง ==
 +
[https://medium.com/@bankz.sukonvijit/%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87-slurm-%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B9%80%E0%B8%94%E0%B9%87%E0%B8%81%E0%B8%88%E0%B8%9A%E0%B9%83%E0%B8%AB%E0%B8%A1%E0%B9%88-ce4dd2885a55 ติดตั้ง Slurm แบบเด็กจบใหม่]
 +
 +
[https://www.slothparadise.com/how-to-install-slurm-on-centos-7-cluster/ How to Install Slurm on CentOS 7 Cluster]
 +
 +
[https://github.com/Artlands/Install-Slurm Artlands/Install-Slurm]
 +
 +
[https://www.howtoforge.com/nfs-server-and-client-on-centos-7 NFS Server and Client Installation on CentOS 7]
 +
 +
[https://bitsanddragons.wordpress.com/2016/09/29/software-modules-on-centos-7/ Software modules on CentOS 7]
 +
 +
[https://sites.google.com/site/rangsiman1993/comp-env/program-install/install-openmpi Installation of OpenMPI by Rangsiman Ketkaew]

Latest revision as of 11:14, 29 November 2021

การติดตั้ง

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

Hostname ip address Type
slurm-test-01 10.98.6.51 Headnode & Compute
slurm-test-02 10.98.6.52 Compute node
slurm-test-03 10.98.6.53 Compute node

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

เปลี่ยน Hostname แต่ละเครื่อง

hostnamectl set-hostname slurm-test-01

เพิ่ม Hosts โดยเพิ่ม ip ลงในบรรทัดสุดท้ายของไฟล์ Hosts

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 700 /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 ทำงานได้ปกติ


ติดตั้ง 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)
  • ro / rw
    • ro : allow clients read only access to the share.
    • rw : allow clients read write access to the share.
  • sync / async
    • sync : NFS server replies to request only after changes made by previous request are written to disk.
    • async : specifies that the server does not have to wait.
  • wdelay / no_wdelay
    • wdelay : NFS server delays committing write requests when it suspects another write request is imminent.
    • no_wdelay : use this option to disable to the delay. no_wdelay option can only be enabled if default sync option is enabled.
  • no_all_squash / all_squash
    • no_all_squash : does not change the mapping of remote users.
    • all_squash : to squash all remote users including root.
  • root_squash / no_root_squash
    • root_squash : prevent root users connected remotely from having root access. Effectively squashing remote root privileges.
    • no_root_squash : disable root squashing.
exportfs -r
  • exportfs -v: Displays a list of shares files and export options on a server.
  • exportfs -a: Exports all directories listed in /etc/exports.
  • exportfs -u: UnExport one or more directories.
  • exportfs -r: ReExport all directories after modifying /etc/exports.
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

ติดตั้ง 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

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-test-01 NodeAddr=10.98.6.51 CPUs=2 State=UNKNOWN
NodeName=slurm-test-02 NodeAddr=10.98.6.52 CPUs=2 State=UNKNOWN
NodeName=slurm-test-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
systemctl start slurmctld
systemctl status slurmctld

เครื่องที่เป็น Compute (ในกรณีนี้จะใช้เครื่อง Headnode มา Compute ด้วย จึงต้องเปิด Service slurmd)

systemctl enable slurmd
systemctl start slurmd
systemctl status slurmd

ดูสถานะของเครื่องใน 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

ติดตั้ง Module Libary

yum install openmpi-devel

อ้างอิง

ติดตั้ง Slurm แบบเด็กจบใหม่

How to Install Slurm on CentOS 7 Cluster

Artlands/Install-Slurm

NFS Server and Client Installation on CentOS 7

Software modules on CentOS 7

Installation of OpenMPI by Rangsiman Ketkaew