Fork me on GitHub

SLURM搭建

本节介绍 Slurm 实验环境的安装,包括一个控制节点和64个计算节点(控制节点同时作为计算节点)4个GPU节点, 使用pdsh和pssh来简化配置工作.

0 准备工作

0.1关闭 Firewall

1
2
systemctl stop firewalld.service
systemctl disable firewalld.service

0.2 同步时间

1
2
3
4
5
6
pssh -i -h root_all "rdate -s 192.168.10.56
#将192.168.10.56部署为NTP服务器之后,通过定时执行同步任务来保证所有节点时间一致:
pdsh -w COMPUTE-1-[1-8],GPU-1-[8,9,12,16] date
#将该命令写入定时任务:使用 -x排除主机 COMPUTE-1-47
crontab -e
*/5 * * * * pdsh -w COMPUTE-1-[1-8],GPU-1-[8,9,12,16] date

###0.3关闭SELinux

1
2
3
4
# vi /etc/sysconfig/selinux
SELINUX=disabled
# reboot
# getenforce(查看SELinux状态)

0.4创建slurm用户(可选,本文使用了root账户,这里可以不看)

先创建slurm用户来进行操作。(#表示需要sudo权限或root用户的操作) 刚创建的云主机只有root用户,一般用root用户操作有许多不便之处,需要先创建slurm用户来进行操作。(#表示需要sudo权限或root用户的操作).或者像本文一样使用root账户.这里还必须保证slurm 的uid完全一致,我们这里使用了root就不管了,如果添加账户的话,可以采用 9527的uid和gid

1
useradd -u 9527  slurm

如果已有用户冲突可以采取下列方式

1
2
3
4
#修改foo用户的uid
usermod -u 9527 slurm
#修改foo组的gid
groupmod -g 9527 slurm

最好不要另开账户了,如果开的话,参考用户管理一文进行提权.

0.4 安装依赖

在所有的节点上安装slurm依赖,slurm在创建安装包时需要 perl-ExtUtils-MakeMaker rpm-build

1
2
3
4
5
#遇到mysqlclient accounting_storage_mysql.so错误
#主要是sql的devel没有安装
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 perl-ExtUtils-MakeMaker perl-Switch rpm-build -y
#本文使用mariadb数据库记录slurm的信息,并且需要安装sql支持
yum install mariadb-server mariadb-devel -y

1 下载并制作rpm包

1
2
3
wget  https://download.schedmd.com/slurm/slurm-19.05.3.tar.bz2
rpmbuild -ta --clean slurm-19.05.3.tar.bz2
#会在 /root/rpmbuild/RPMS/x86_64生成相应的src包和二进制包

2安装配置slurm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
cd /root/rpmbuild/RPMS/x86_64
yum --nogpgcheck localinstall slurm-* -y
cd /etc/slurm/
#复制 slurm.conf.example 文件成 slurm.conf,然后编辑 本文所使用的slurm.conf和cgroup.conf见后面链接
vim /etc/slurm/slurm.conf
vim /etc/slurm/cgroup.conf

# slurm 多节点安装依赖
pscp.pssh -i -h cpu2-64_gpu4 "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 perl-ExtUtils-MakeMaker perl-Switch rpm-build -y "
# slurm 多节点安装数据库依赖
pscp.pssh -i -h cpu2-64_gpu4 "yum install mariadb-server mariadb-devel -y"
# 多节点复制slurm安装包
pscp.pssh -h cpu2-64_gpu4 -r ~/rpmbuild/RPMS/slurm19.05/ /home/xd
# 多节点执行slurm安装
pssh -i -h cpu2-64_gpu4 "cd /home/xd/slurm19.05 && yum --nogpgcheck localinstall slurm-* -y "

##多节点传输cgroup.conf和slurm.conf
pscp -h ~/pssh/cpu2-64_gpu4 /etc/slurm/*conf /etc/slurm
#之后进行多节点的测试
pssh -i -h ~/pssh/cpu2-64_gpu4 "systemctl start slurmd&&systemctl enable slurmd"

# 主控节点
systemctl start slurmctld slurmd
systemctl enable slurmctld slurmd

# 计算节点
systemctl start slurmd
systemctl enable slurmd


#多节点
pscp -h ~/pssh/cpu2-64_gpu4 /etc/slurm/*conf /etc/slurm
#之后进行多节点的测试
pssh -i -h ~/pssh/cpu2-64_gpu4 "systemctl start slurmd&&systemctl enable slurmd"

到这里所有的slurm已经搭建完毕,花费时间5天.简直天坑

在任意节点执行 sinfo 命令,你将看到类似输出,则证明服务工作正常

1
2
3
4
PARTITION AVAIL  TIMELIMIT  NODES  STATE NODELIST
Debug up infinite 4 idle COMPUTE-1-[1-4]
COMPUTE[5-64] up infinite 59 idle COMPUTE-1-[5-46,48-64]
GPU* up infinite 4 idle GPU-1-[8-9,12,16]

3 配置文件

本文所使用的slurm.confcgroup.conf

-------------本文结束感谢您的阅读-------------

本文标题:SLURM搭建

文章作者:Sheldon

发布时间:2019年12月18日 - 00:12

最后更新:2019年12月18日 - 02:12

原始链接:http://yoursite.com/2019/12/18/slurm搭建/

许可协议: 署名-非商业性使用-禁止演绎4.0 国际 转载请保留原文链接及作者。