跳到主要内容

license调度

概述

fsched实现了license服务器监控和当前集群license分配管理。当存在license查询脚本时,fsched会自动监控license使用的变化,实时调整作业可使用的license数,确保作业调度时能够正确分配license资源。

注意
  • 设置license调度会影响作业调度,需要由管理员谨慎操作
提示
  • 需要确保集群head节点与license服务器之间的网络连接正常
  • license查询脚本由管理员上传到集群head节点,路径及文件名固定为/etc/fastone/license_query,脚本输出格式必须符合指定格式,具体参照 >>> license查询脚本参数格式
  • 由于fsched处理license名和server名时都转化成小写,用户提交作业时license名和server名都需要用小写提交
  • 如果license查询脚本使用license服务器的客户端查询工具lmstat,需要先在head节点的/etc/hosts中添加license服务器域名

配置说明

license调度为管理员提供两个配置工具:

  1. License Allocation 管理:管理当前集群的license分配,用于限制当前集群最多能够使用的license数,用sacctmgr 的 resource 命令操作
  2. License Sync 管理:用于管理对license使用的同步

License Allocation 管理

sacctmgr 的 resource 命令管理当前集群的license分配。

获取当前集群名

scontrol show config | grep ClusterName

添加license分配

  1. 查看该license是否已存在
sacctmgr show resource name=test8 server=server3
  1. 如果不存在,可以一步添加完成:
sacctmgr add resource name=test8 server=server3 servertype=flexlm type=license count=60 cluster=fastone-1 percentallowed=70
  1. 如果已经存在:

如果该license已经存在,不能设置新的count, 如果需要修改可以使用sacctmgr modify resource命令。

3.1 查看是否有当前集群的分配:

sacctmgr show resource withclusters name=test8 server=server3 cluster=fastone-1

3.2 如果不存在当前集群的分配,可以为当前集群设置license分配的percentallowed

sacctmgr add resource name=test8 server=server3 cluster=fastone-1 percentallowed=70

3.3 如果存在当前集群的分配,不能设置,如果需要修改可以使用sacctmgr modify resource命令。

参数说明

  • name: license名称
  • cluster: fsched集群名称
  • count: license总数量,包括集群外部和集群内部可使用的总量
  • percentallowed: 当前集群允许使用的百分比
  • server: license服务器名称
  • servertype: license服务器类型
  • type: 资源名称,在本流程中应填license

修改license分配

  • 如果需要修改license分配总量:
sacctmgr modify resource name=matlab server=server2 set count=200
  • 如果需要修改为当前集群分配的percentallowed
sacctmgr modify resource name=matlab server=server2 cluster=fastone-1 set percentallowed=30

参数说明

  • name: license名称
  • server: 服务器名称
  • cluster: fsched集群名称
  • count: 新的license总数量
  • percentallowed: 新的百分比

删除license分配

  • 如果只有一个集群,或者有多个集群并且需要删除所有集群的license分配:
sacctmgr delete resource where name=matlab server=server2
  • 如果有多个集群,需要删除当前集群的license分配:
sacctmgr delete resource where name=matlab server=server2 cluster=fastone-1

参数说明

  • name: license名称
  • server: 服务器名称
  • cluster: fsched集群名称

查询license分配

  • 查询当前集群的license分配情况:
# 查询所有license分配
sacctmgr show resource withclusters cluster=fastone-1

# 按名称过滤
sacctmgr show resource withclusters cluster=fastone-1 name=nastran

# 按服务器过滤
sacctmgr show resource withclusters cluster=fastone-1 server=flex_host

# 精确查询
sacctmgr show resource withclusters cluster=fastone-1 name=matlab server=rlm_host
  • 查询所有license分配
sacctmgr show resource

参数说明

  • name: 按license名称过滤
  • server: 按服务器名称过滤
  • cluster: fsched集群名称

License Sync 管理

利用license查询脚本的输出,自动同步license使用的变化到当前集群

设置license查询脚本

license查询脚本参数格式

脚本须将license信息打印到标准输出(stdout),每行一条,格式如下:

name@server_name:consumed
字段说明
namelicense名称
server_namelicense服务器名称
consumed当前使用的license数量

示例输出:

ansys@flexlm_server:5
meba@flexlm_server:20
  • license查询脚本没有输入参数
  • 脚本示例和说明可以参照head节点上的/opt/fsched/wrappers/statesvc/license_tools/
license查询脚本部署

将脚本复制到固定查询路径/etc/fastone/license_query,以脚本license_query_flexlm.sh为例:

cp license_query_flexlm.sh /etc/fastone/license_query
chmod +x /etc/fastone/license_query

停止license同步

删除license查询脚本/etc/fastone/license_query后,自动停止同步

查看license同步状态

/opt/fsched/wrappers/statesvc/bin/stateclient lic-sync-status

显示当前license同步的状态信息,包括同步状态、最近一次更新时间和更新内容、错误信息。

配置过程示例

以下命令在集群的head节点上运行, 以只有一个集群的情况示例。

  1. 检查要管理的license是否为当前集群分配过,如果没有,为当前集群分配license

    • 查看当前集群名:
    [root@centos7-16c-1 ~]# scontrol show config | grep ClusterName
    ClusterName = fastone-2
    • 查看已分配的license:
    [root@centos7-16c-1 ~]# sacctmgr show resource
    Name Server Type Count % Allocated ServerType
    ---------- ---------- -------- ------ ----------- ----------
    • license总量可以通过lmstat输出中的Total确认:
    [root@centos7-16c-1 ~]# ./lmstat -f ansys -c 1055@10.106.1.111
    lmstat - Copyright (c) 1989-2016 Flexera Software LLC. All Rights Reserved.
    Flexible License Manager status on Fri 3/13/2026 18:39

    License server status: 1055@ansys-lic
    License file(s) on ansys-lic: /fastone/softwares/ansys/ansys/2024R1/ansys_inc/shared_files/licensing/license_files/ansyslmd.lic:

    ansys-lic: license server UP (MASTER) v11.19.4

    Vendor daemon status (on ansys-lic):

    ansyslmd: UP v11.19.4
    Feature usage info:

    Users of ansys: (Total of 100 licenses issued; Total of 0 licenses in use)

    [root@centos7-16c-1 ~]# ./lmstat -f meba -c 1055@10.106.1.153
    lmstat - Copyright (c) 1989-2016 Flexera Software LLC. All Rights Reserved.
    Flexible License Manager status on Fri 3/13/2026 18:43

    License server status: 1055@ansys-lic
    License file(s) on ansys-lic: /fastone/softwares/ansys/ansys/2024R1/ansys_inc/shared_files/licensing/license_files/ansyslmd.lic:

    ansys-lic: license server UP (MASTER) v11.19.4

    Vendor daemon status (on ansys-lic):

    ansyslmd: UP v11.19.4
    Feature usage info:

    Users of meba: (Total of 100 licenses issued; Total of 0 licenses in use)
    • 如果没有这个Name,Server组合,为当前集群分配最大可用license,服务器名使用管理员自定义的唯一和license server对应的服务器名:
    [root@centos7-16c-1 ~]# sacctmgr add resource name=ansys server=flexlm_server servertype=flexlm_server type=license count=100 cluster=fastone-2 percentallowed=100
    Adding Resource(s)
    ansys@flexlm_server
    Cluster - fastone-2 100%
    Settings
    Name = ansys
    Server = flexlm_server
    Description = ansys
    ServerType = flexlm_server
    Count = 100
    Type = License
    Would you like to commit changes? (You have 30 seconds to decide)
    (N/y): y
    [root@centos7-16c-1 ~]# sacctmgr add resource name=meba server=flexlm_server servertype=flexlm_server type=license count=100 cluster=fastone-2 percentallowed=100
    Adding Resource(s)
    meba@flexlm_server
    Cluster - fastone-2 100%
    Settings
    Name = meba
    Server = flexlm_server
    Description = meba
    ServerType = flexlm_server
    Count = 100
    Type = License
    Would you like to commit changes? (You have 30 seconds to decide)
    (N/y): y
    • 查看设置结果
    [root@centos7-16c-1 ~]# sacctmgr show resource -p
    Name|Server|Type|Count|% Allocated|ServerType|
    ansys|flexlm_server|License|100|100|flexlm_server|
    meba|flexlm_server|License|100|100|flexlm_server|
  2. 设置license同步

    • 将脚本复制到固定查询路径/etc/fastone/license_query,以脚本license_query_flexlm.sh为例:
    cp license_query_flexlm.sh /etc/fastone/license_query
    chmod +x /etc/fastone/license_query
    • 查看license同步状态:
    [root@centos7-16c-1 ~]# /opt/fsched/wrappers/statesvc/bin/stateclient lic-sync-status
    Sending requests to server localhost:20051
    Status: OK
    Last Update: 2026-03-13T11:08:24Z
    Licenses (2):
    ansys@flexlm_server: 30
    meba@flexlm_server: 20

集群使用示例

以下命令在集群中任意节点可运行

  1. 查看当前集群可使用的license

示例中的输出显示了可用的license(license_name@server_name), 其中LastConsumed显示该license的总消耗(包括集群外和集群内), Free显示当前集群的剩余可用license数。

[root@centos7-16c-1 ~]# scontrol show lic --ext
LicenseName=meba@flexlm_server
LicenseName=meba@flexlm_server
Total=100 Used=0 Free=80 Reserved=0 Remote=yes
LastConsumed=20 LastDeficit=20 LastUpdate=Unknown
LicenseName=ansys@flexlm_server
Total=100 Used=0 Free=70 Reserved=0 Remote=yes
LastConsumed=30 LastDeficit=30 LastUpdate=Unknown
  1. 提交job时指定请求的license数

以下job请求的license数超过该集群该license当前的Free数,job因为Licensespending

[root@centos7-16c-1 ~]# srun -L ansys@flexlm_server:90 sleep 600&
[1] 5586
[root@centos7-16c-1 ~]# srun: job 7 queued and waiting for resources

[root@centos7-16c-1 ~]# squeue
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
7 partition sleep root PD 0:00 1 (Licenses)

一段时间后,如果外部使用的license释放,fsched监控的license消耗量会自动更新到集群,job可以运行

[root@centos7-16c-1 ~]# squeue
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
7 partition sleep root R 0:05 1 jj-centos7-2
[root@centos7-16c-1 ~]# scontrol show lic --ext
LicenseName=meba@flexlm_server
Total=100 Used=0 Free=80 Reserved=0 Remote=yes
LastConsumed=20 LastDeficit=20 LastUpdate=Unknown
LicenseName=ansys@flexlm_server
Total=100 Used=90 Free=10 Reserved=0 Remote=yes
LastConsumed=5 LastDeficit=0 LastUpdate=Unknown