Slurm 安装部署
专栏文章
Slurm 单机环境搭建
说明
- 机器:2C4G100G
- 主机名:hostnamectl set-hostname sms
- slurm 版本:20.11.8
快速 demo
安装数据库
- 安装
yum install mariadb mariadb-server -y- 修改配置文件
/etc/my.cnf
[mysqld]
...
innodb_buffer_pool_size=1024M
innodb_log_file_size=64M
innodb_lock_wait_timeout=900- 启动服务
systemctl start mariadb.service- 数据库初始化
CREATE DATABASE `slurm_acct_db` /*!40100 DEFAULT CHARACTER SET UTF8 */;
GRANT ALL ON slurm_acct_db.* TO 'slurm'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON slurm_acct_db.* TO 'slurm'@'sms' IDENTIFIED BY 'password';
GRANT ALL ON slurm_acct_db.* TO 'slurm'@'%' IDENTIFIED BY 'password';
CREATE DATABASE `slurm_jobcomp_db` /*!40100 DEFAULT CHARACTER SET UTF8 */;
GRANT ALL ON slurm_jobcomp_db.* TO 'slurm'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON slurm_jobcomp_db.* TO 'slurm'@'sms' IDENTIFIED BY 'password';
GRANT ALL ON slurm_jobcomp_db.* TO 'slurm'@'%' IDENTIFIED BY 'password';munge
该组件所有节点都需要安装,且配置相同。
yum install -y munge
dd if=/dev/urandom bs=1 count=1024 >/etc/munge/munge.key
chmod 0400 /etc/munge/munge.key
chown munge:munge /etc/munge/munge.key
systemctl enable munge
systemctl start munge说明:
- 所有节点
/etc/munge/munge.key需要配置一致 - munge 作用参考 munge 使用介绍
slurmdbd
部署在控制节点
安装
yum install -y slurm-slurmdbd配置
- /etc/slurm/slurmdbd.conf
说明:slurm 20.11 之后的版本,可以通过 StorageHost/StorageBackupHost 参数配置主备
启动服务
systemctl enable slurmdbd
systemctl start slurmdbd
systemctl status slurmdbdslurmctld
部署在控制节点
安装
yum install -y slurm-slurmctld配置
- 文件初始化
touch /etc/slurm/gres.conf
touch /etc/slurm/slurm_node.conf
touch /etc/slurm/slurm_partition.conf
touch /etc/slurm/topology.conf- 主配置文件:
/etc/slurm/slurm.conf
说明:
- 通过指定多个
SlurmctldHost实现 HA? - AccountingStorageType 控制将作业信息收集存储到文件或者数据库:
accounting_storage/filetxt,默认记录在/var/log/slurm_jobacct.logaccounting_storage/slurmdbd
- 节点配置 /etc/slurm/slurm_node.conf
NodeName=c[1-3] CPUs=64 CoresPerSocket=16 ThreadsPerCore=2 RealMemory=772433 MemSpecLimit=51200 State=UNKNOWN指标说明:
- Sockets=
lscpu | grep "^Socket(s):" | awk '{print $2}' - CoresPerSocket=
lscpu | grep "^Core(s) per socket:" | awk -F ":" '{print $2}' - ThreadsPerCore=
lscpu | grep "^Thread(s) per core:" | awk -F ":" '{print $2}' - 若果需要 show node 显示 ip 地址,可以添加
NodeAddr字段 - 通过
CoreSpec指定给系统预留的CPU数量,默认需要给计算节点预留一个CPU,否则调度失败
- 队列配置 /etc/slurm/slurm_partition.conf
PartitionName=normal Nodes=c[1-3] Default=YES MaxTime=24:00:00 State=UP
GresTypes=gpu,bandwidth
NodeName=c[4-6] Gres=gpu:tesla:2,bandwidth:lustre:no_consume:25G
PartitionName=gpu Nodes=c[4-6] Default=YES DisableRootJobs=YES MaxTime=3-00:00:00 MinNodes=1 LLN=YES OverSubscribe=FORCE:1 PriorityJobFactor=1 PriorityTier=1000 DefMemPerCPU=1024 MaxMemPerCPU=2500 QOS=gpu_normal State=UP说明:
- PartitionName 指定 Partition 名称
- Nodes 指定节点范围
- Default 是否为默认
- MaxTime 最大作业运行时长
- State 该分区状态
- 修改后需要重启
sms节点slurmctld和计算节点slurmd进程 - 执行
squeue可以在查看到对应的Partition
-
网络拓扑配置 /etc/slurm/topology.conf
-
资源配置 /etc/slurm/gres.conf
启动服务
systemctl enable slurmctld
systemctl start slurmctld
systemctl status slurmctld验证
执行 sinfo 正常显示结果:
[root@sms ~]# sinfo
PARTITION AVAIL TIMELIMIT NODES STATE NODELIST
normal* up 1-00:00:00 1 unk sms
[root@sms ~]# squeue
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)slurmd
在计算节点安装
安装
yum install -y slurm-slurmd配置
将 sms 节点的配置文件发送到计算节点:
scp /etc/slurm/slurm.conf /etc/slurm/slurm_node.conf /etc/slurm/slurm_partition.conf /etc/slurm/topology.conf /etc/slurm/gres.conf c1:/etc/slurm启动服务
systemctl enable slurmd
systemctl start slurmdslurm-nss_slurm
在所有节点配置,防止没有分配作业的节点被用户登录。参考:https://slurm.schedmd.com/nss_slurm.html
安装
yum install -y slurm-nss_slurm配置
- 配置
nss,在/etc/slurm/slurm.conf中配置:
LaunchParameters=enable_nss_slurm重启 slurmd 服务
- 修改 PAM,作用为仅给 slurm 分配作业的机器登录认证,更多参考:Linux PAM 可插拔认证模块介绍
echo "account required pam_slurm.so" >> /etc/pam.d/sshd不需要重启服务
login 节点
登录(login / submit)节点作为用户提交和管理作业的节点,无需运行 slurmctld 或 slurmd 服务,仅需:
- 部署相同的
/etc/slurm/slurm.conf和/etc/munge/munge.key - 启动
munge认证服务 - 安装 Slurm 客户端命令工具(
sbatch、srun、squeue等)
注意:
SlurmctldHost仅用于指定运行控制进程的主备控制器(第一个为主控制节点,后续为备用控制节点),切勿将普通登录节点指定为SlurmctldHost。Job ID 均由集群的slurmctld主控制进程统一生成与维护。
- SlurmctldHost 介绍
The short, or long, hostname of the machine where Slurm control daemon is executed (i.e. the name returned by the command "hostname -s"). This hostname is optionally followed by the address, either the IP address or a name by which the address can be identified, enclosed in parentheses (e.g. SlurmctldHost=slurmctl-primary(12.34.56.78)). This value must be specified at least once. If specified more than once, the first hostname named will be where the daemon runs. If the first specified host fails, the daemon will execute on the second host. If both the first and second specified host fails, the daemon will execute on the third host.FAQ
更正 Slurm 节点状态
采用 scontrol show node 但节点状态不对,出现如:
- Low RealMemory,作业一直处于 CG (completing) 状态
- Node unexpectedly rebooted
如果节点没有作业在运行,修复命令如下:
# 方案一(推荐)
scontrol update NodeName=<node> State=DOWN Reason=abc
scontrol update nodename=<node> state=resume # 处于 down 状态无法自动恢复时执行
# 方案二
scontrol update nodename=<node> state=idle # 状态非正常时,强制重置Low CPUs 问题
采用 scontrol show node,Reason 如下:
- Low socketcorethread count, Low CPUs
sms:/var/log/slurmctld.log
[2021-07-06T23:13:49.934] error: Node c1 has low socket*core*thread count (4 < 32)
[2021-07-06T23:13:49.934] error: Node c1 has low cpu count (4 < 32)
[2021-07-06T23:13:49.934] error: _slurm_rpc_node_registration node=c1: Invalid argument解决方法:
修改 sms:/etc/slurm/slurm.conf
NodeName=c[1-4] Sockets=2 CoresPerSocket=1 ThreadsPerCore=2 State=UNKNOWN指标说明:
- Sockets=
lscpu | grep "^Socket(s):" | awk '{print $2}' - CoresPerSocket=
lscpu | grep "^Core(s) per socket:" | awk -F ":" '{print $2}' - ThreadsPerCore=
lscpu | grep "^Thread(s) per core:" | awk -F ":" '{print $2}'
重启:
systemctl restart slurmctld.service修改 c1:/etc/slurm/slurm.conf,与 sms:/etc/slurm/slurm.conf 保持一致:
NodeName=c[1-4] Sockets=2 CoresPerSocket=1 ThreadsPerCore=2 State=UNKNOWN
PartitionName=normal Nodes=c[1-4] Default=YES MaxTime=24:00:00 State=UP并重启:
systemctl restart slurmd.serviceSlurm job id has expired 问题
错误信息如下:
[test@sms ~]$ srun -N 1 -l hostname
srun: error: Slurm job 12 has expired
srun: Check SLURM_JOB_ID environment variable. Expired or invalid job 12解决方法:
退出 shell,然后重新进入。
SSH 问题
[test@sms ~]$ ssh c11 pwd
Access denied: user test (uid=1000) has no active jobs on this node.
Authentication failed.- 解决方法:
属于正常现象,通过在 /etc/pam.d/sshd 中添加 pam_slurm.so 实现拒绝非运行任务的 ssh 登录。通过 salloc/srun 分配节点 job 即可登录。
[test@sms ~]$ salloc -N 1 -w c11
salloc: Granted job allocation 16
[test1@sms ~]$ ssh c11
[test1@c11 ~]$
# 或
[test@sms ~]$ srun -N 2 -l sleep 100 # 然后在登录即可- 原理
安装 slurm-pam_slurm-ohpc 时,实际执行:
# 类似 `cp /opt/ohpc/admin/images/centos7.7/usr/lib64/security/pam_slurm.so /usr/lib64/security/`,实际 slurm-pam_slurm-ohpc 提供 `/usr/lib64/security/pam_slurm.so` 文件,并在 `/etc/pam.d/sshd` 中添加配置
echo "account required pam_slurm.so" >> /etc/pam.d/sshd- /var/log/slurmctld.log 日志错误问题
error: Node c2 appears to have a different slurm.conf than the slurmctld. This could cause issues with communication and functionality. Please review both files and make sure they are the same. If this is expected ignore, and set DebugFlags=NO_CONF_HASH in your slurm.conf.
使用命令systemctl restart slurmd时,slurmd进程并没有杀掉,需要手动杀掉该进程:
pdsh -w c[1-3] pkill slurmd建议通过 reload 重启 slurmd 进程
pdsh -w c[1-3] systemctl reload slurmdMPI 依赖问题
$ module load lammps/2020.10
$ lmp
[c11:22047] pmix_mca_base_component_repository_open: unable to open mca_pnet_opa: libpsm2.so.2: cannot open shared object file: No such file or directory (ignored)
[c11:22047] mca_base_component_repository_open: unable to open mca_oob_ud: libosmcomp.so.3: cannot open shared object file: No such file or directory (ignored)
[c11:22046] pmix_mca_base_component_repository_open: unable to open mca_pnet_opa: libpsm2.so.2: cannot open shared object file: No such file or directory (ignored)
[c11:22046] mca_base_component_repository_open: unable to open mca_oob_ud: libosmcomp.so.3: cannot open shared object file: No such file or directory (ignored)
[c11:22046] mca_base_component_repository_open: unable to open mca_btl_openib: librdmacm.so.1: cannot open shared object file: No such file or directory (ignored)
[c11:22046] mca_base_component_repository_open: unable to open mca_mtl_psm: libpsm_infinipath.so.1: cannot open shared object file: No such file or directory (ignored)
[c11:22046] mca_base_component_repository_open: unable to open mca_mtl_psm2: libpsm2.so.2: cannot open shared object file: No such file or directory (ignored)
LAMMPS (29 Oct 2020)解决方式:
pdsh -w c[1-3] yum install -y infinipath-psm libpsm2 psmisc compat-opensm-libs librdmacm测试:
[test@sms ~]$ salloc -N 2 -w c11,c12
salloc: Granted job allocation 31
[test@sms ~]$ mpirun --allow-run-as-root -host c11,c12 uptimeslurm_recv_timeout at 0 of 4, recv zero bytes
slurmctld 错误日志:
Aug 14 16:33:41 sms1 slurmctld[2874575]: slurmctld: debug: slurm_recv_timeout at 0 of 4, recv zero bytes原因:
- 机器时间不一致:date
- 机器时区不同:date -R
- 硬件时钟不同步:hwclock –systohc
slurm_recv_timeout
slurmctld 错误日志:
[2021-08-14T16:56:08.985] debug: slurm_recv_timeout at 0 of 4, recv zero bytes
[2021-08-14T16:56:08.985] error: slurm_receive_msg: Zero Bytes were transmitted or received
[2021-08-14T16:56:08.985] error: Invalid RPC received 65534 while in standby mode原因:
tcping 端口检测导致,slurm REQUEST_PING message type is 1008,可通过 sdiag 命令查看。
error: slurm_auth_get_host: Lookup failed
[2021-08-15T14:47:59.804] debug2: Error connecting slurm stream socket at 172.20.0.20:6817: Connection refused
...
[2021-08-15T14:48:12.122] error: get_name_info: getnameinfo() failed: Name or service not known
[2021-08-15T14:48:12.122] error: slurm_auth_get_host: Lookup failed for 172.20.1.20
[2021-08-15T14:48:12.122] debug3: _set_hostname: Using auth hostname for alloc_node: 172.20.1.20见:munge 使用介绍 faq
ldap 主从同步导致的新用户执行作业失败问题
新增用户无法执行作业,错误日志:
Batch job submission failed: Invalid account or account/partition combination specifiedslurmctl 错误日志如下:
user add couldn't get a uid for user xxx- 解决方法
ldap主从 同步时间间隔问题,默认连接nslcd主,若主出现故障,将会出现一直链接被备情况,建议使用 ldap主主 方案,并通过vip提供服务。
专栏文章
- Slurm 开发
- Slurm rpmbuild
- Slurm 相关术语
- Slurm QoS 使用
- Slurm Job
- Slurm Partition 使用
- Slurm REST API 使用
- Slurm scontrol 命令
- Slurm sacct/sacctmgr 命令
- Slurm 命令使用说明
- Slurm sreport 命令
- Slurm FaQ
- Slurm 安装部署(当前)
最近更新
最新评论