更新时间:2022-07-29 GMT+08:00

资源管理函数

资源管理模块相关函数介绍。

  • gs_wlm_readjust_user_space(oid)

    描述:用户永久存储空间校准函数。入参为用户oid,入参为0的情况下,会校准所有用户的永久存储空间。

    返回值类型:text

    示例:

    select gs_wlm_readjust_user_space(0);
    gs_wlm_readjust_user_space
    ----------------------------
    Exec Success
    (1 row)
  • pgxc_wlm_readjust_schema_space()

    描述:Schema永久存储空间校准函数。

    返回值类型:text

    示例:

    select pgxc_wlm_readjust_schema_space();
    pgxc_wlm_readjust_schema_space
    --------------------------------
    Exec Success
    (1 row)
  • pgxc_wlm_get_schema_space(cstring)

    描述:在CN上查询某个逻辑集群下各实例的Schema空间信息,入参为逻辑集群名称。

    返回值类型:record

    函数返回字段如下:

    名称

    类型

    描述

    schemaname

    text

    模式名

    schemaid

    oid

    模式OID

    databasename

    text

    数据库名

    databaseid

    oid

    数据库OID

    nodename

    text

    实例名称

    nodegroup

    text

    节点组名称

    usedspace

    bigint

    已使用的空间大小

    permspace

    bigint

    空间上限值

    示例:

     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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    select * from pgxc_wlm_get_schema_space('group1');
         schemaname     | schemaid | databasename | databaseid |   nodename   |  nodegroup   | usedspace | permspace
    --------------------+----------+--------------+------------+--------------+--------------+-----------+-----------
     pg_catalog         |       11 | test1        |      16384 | datanode1    | installation |   9469952 |        -1
     public             |     2200 | gaussdb     |      15253 | datanode1    | installation |  25280512 |        -1
     pg_toast           |       99 | test1        |      16384 | datanode1    | installation |   1859584 |        -1
     cstore             |      100 | test1        |      16384 | datanode1    | installation |         0 |        -1
     data_redis         |    18106 | gaussdb     |      15253 | datanode1    | installation |    655360 |        -1
     data_redis         |    18116 | test1        |      16384 | datanode1    | installation |         0 |        -1
     public             |     2200 | test1        |      16384 | datanode1    | installation |     16384 |        -1
     dbms_om            |     3987 | gaussdb     |      15253 | datanode1    | installation |         0 |        -1
     dbms_job           |     3988 | gaussdb     |      15253 | datanode1    | installation |         0 |        -1
     dbms_om            |     3987 | test1        |      16384 | datanode1    | installation |         0 |        -1
     dbms_job           |     3988 | test1        |      16384 | datanode1    | installation |         0 |        -1
     sys                |    11693 | gaussdb     |      15253 | datanode1    | installation |         0 |        -1
     sys                |    11693 | test1        |      16384 | datanode1    | installation |         0 |        -1
     utl_file           |    14644 | gaussdb     |      15253 | datanode1    | installation |         0 |        -1
     utl_raw            |    14669 | gaussdb     |      15253 | datanode1    | installation |         0 |        -1
     dbms_sql           |    14674 | gaussdb     |      15253 | datanode1    | installation |         0 |        -1
     dbms_output        |    14662 | gaussdb     |      15253 | datanode1    | installation |         0 |        -1
     dbms_random        |    14666 | gaussdb     |      15253 | datanode1    | installation |         0 |        -1
     dbms_lob           |    14701 | gaussdb     |      15253 | datanode1    | installation |         0 |        -1
     information_schema |    14300 | gaussdb     |      15253 | datanode1    | installation |    294912 |        -1
     information_schema |    14300 | test1        |      16384 | datanode1    | installation |    294912 |        -1
     utl_file           |    14644 | test1        |      16384 | datanode1    | installation |         0 |        -1
     dbms_output        |    14662 | test1        |      16384 | datanode1    | installation |         0 |        -1
     dbms_random        |    14666 | test1        |      16384 | datanode1    | installation |         0 |        -1
     utl_raw            |    14669 | test1        |      16384 | datanode1    | installation |         0 |        -1
     dbms_sql           |    14674 | test1        |      16384 | datanode1    | installation |         0 |        -1
     dbms_lob           |    14701 | test1        |      16384 | datanode1    | installation |         0 |        -1
     pg_catalog         |       11 | gaussdb     |      15253 | datanode1    | installation |  13049856 |        -1
     redisuser          |    16387 | gaussdb     |      15253 | datanode1    | installation |    630784 |        -1
     pg_toast           |       99 | gaussdb     |      15253 | datanode1    | installation |   3080192 |        -1
     cstore             |      100 | gaussdb     |      15253 | datanode1    | installation |   2408448 |        -1
     pg_catalog         |       11 | test1        |      16384 | datanode2    | installation |   9469952 |        -1
     public             |     2200 | gaussdb     |      15253 | datanode2    | installation |  25214976 |        -1
     pg_toast           |       99 | test1        |      16384 | datanode2    | installation |   1859584 |        -1
     cstore             |      100 | test1        |      16384 | datanode2    | installation |         0 |        -1
     data_redis         |    18106 | gaussdb     |      15253 | datanode2    | installation |    655360 |        -1
     data_redis         |    18116 | test1        |      16384 | datanode2    | installation |         0 |        -1
     public             |     2200 | test1        |      16384 | datanode2    | installation |     16384 |        -1
     dbms_om            |     3987 | gaussdb     |      15253 | datanode2    | installation |         0 |        -1
     dbms_job           |     3988 | gaussdb     |      15253 | datanode2    | installation |         0 |        -1
     dbms_om            |     3987 | test1        |      16384 | datanode2    | installation |         0 |        -1
     dbms_job           |     3988 | test1        |      16384 | datanode2    | installation |         0 |        -1
    
  • pgxc_wlm_analyze_schema_space(cstring)

    描述:在CN上查询某个逻辑集群下集群整体的Schema空间信息,入参为逻辑集群名称。

    返回值类型:record

    函数返回字段如下:

    名称

    类型

    描述

    schemaname

    text

    模式名

    databasename

    text

    数据库名

    nodegroup

    text

    节点组名称

    total_value

    bigint

    该模式的集群空间总值

    avg_value

    bigint

    该模式的各实例空间平均值

    skew_percent

    integer

    倾斜率

    extend_info

    text

    提供信息包括:单实例空间最大值、单实例空间最小值以及最大最小空间所在的实例名

    示例:

     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
    35
    select * from pgxc_wlm_analyze_schema_space('group1');
         schemaname     | databasename |  nodegroup   | total_value | avg_value | skew_percent |                  extend_info
    --------------------+--------------+--------------+-------------+-----------+--------------+-----------------------------------------------
     pg_catalog         | test1        | installation |    56819712 |   9469952 |            0 | min:9469952 datanode1,max:9469952 datanode1
     public             | gaussdb     | installation |   150495232 |  25082538 |            0 | min:24903680 datanode6,max:25280512 datanode1
     pg_toast           | test1        | installation |    11157504 |   1859584 |            0 | min:1859584 datanode1,max:1859584 datanode1
     cstore             | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     data_redis         | gaussdb     | installation |     1966080 |    327680 |           50 | min:0 datanode4,max:655360 datanode1
     data_redis         | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     public             | test1        | installation |       98304 |     16384 |            0 | min:16384 datanode1,max:16384 datanode1
     dbms_om            | gaussdb     | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_job           | gaussdb     | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_om            | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_job           | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     sys                | gaussdb     | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     sys                | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     utl_file           | gaussdb     | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     utl_raw            | gaussdb     | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_sql           | gaussdb     | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_output        | gaussdb     | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_random        | gaussdb     | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_lob           | gaussdb     | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     information_schema | gaussdb     | installation |     1769472 |    294912 |            0 | min:294912 datanode1,max:294912 datanode1
     information_schema | test1        | installation |     1769472 |    294912 |            0 | min:294912 datanode1,max:294912 datanode1
     utl_file           | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_output        | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_random        | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     utl_raw            | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_sql           | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     dbms_lob           | test1        | installation |           0 |         0 |            0 | min:0 datanode1,max:0 datanode1
     pg_catalog         | gaussdb     | installation |    75431936 |  12571989 |            3 | min:12124160 datanode4,max:13049856 datanode1
     redisuser          | gaussdb     | installation |     1884160 |    314026 |           50 | min:16384 datanode4,max:630784 datanode1
     pg_toast           | gaussdb     | installation |    17154048 |   2859008 |            7 | min:2637824 datanode4,max:3080192 datanode1
     cstore             | gaussdb     | installation |    15294464 |   2549077 |            5 | min:2408448 datanode1,max:2703360 datanode6
    (31 rows)
    
  • gs_wlm_set_queryband_action(cstring,cstring,int4)

    描述:设置query_band关联行为和次序。

    返回值类型:boolean

    函数入参字段如下:

    名称

    类型

    描述

    qband

    cstring

    query_band键值对,长度上限为63个字符。

    action

    cstring

    query_band关联行为。

    order

    int4

    query_band搜索次序,缺省参数,默认为-1。

    示例:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    select * from gs_wlm_set_queryband_action('a=1','respool=p1');
     gs_wlm_set_queryband_action
    -----------------------------
     t
    (1 row)
    select * from gs_wlm_set_queryband_action('a=3','respool=p1;priority=rush',1);
     gs_wlm_set_queryband_action
    -----------------------------
     t
    (1 row)
    
  • gs_wlm_set_queryband_order(cstring,int4)

    描述:设置query_band次序。

    返回值类型:boolean

    函数入参字段如下:

    名称

    类型

    描述

    qband

    cstring

    query_band键值对

    order

    int4

    query_band搜索次序,缺省参数,默认为-1

    示例:

    1
    2
    3
    4
    5
    select * from gs_wlm_set_queryband_order('a=1',2);
     gs_wlm_set_queryband_action
    -----------------------------
     t
    (1 row)
    
  • gs_wlm_get_queryband_action(cstring)

    描述:查询query_band关联行为和次序。

    返回值类型:record

    函数返回字段如下:

    名称

    类型

    描述

    qband

    cstring

    query_band键值对

    respool_id

    Oid

    query band关联资源池OID

    respool

    text

    query band关联资源池名

    priority

    text

    query band关联队队列内优先级

    qborder

    int4

    query_band搜索次序

    示例:

    1
    2
    3
    4
    5
    select * from gs_wlm_get_queryband_action('a=1');
    qband | respool_id | respool | priority | qborder
    -------+------------+---------+----------+---------
     a=1   |      16388 | p1      | Medium   |      -1
    (1 row)
    
  • gs_cgroup_reload_conf()

    描述:在当前实例上进行cgroup配置文件在线加载。

    返回值类型:record

    函数返回字段如下:

    名称

    类型

    描述

    node_name

    text

    实例名称

    node_host

    text

    实例所在节点的IP地址

    result

    text

    cgroup在线加载是否成功

    示例:

    1
    2
    3
    4
    select * from gs_cgroup_reload_conf();
     node_name |   node_host    | result
    -----------+----------------+---------
     cn_5001   | 192.168.178.35 | success
    
  • pgxc_cgroup_reload_conf()

    描述:在系统所有实例上进行cgroup配置文件在线加载。

    返回值类型:record

    函数返回字段如下:

    名称

    类型

    描述

    node_name

    text

    实例名称

    node_host

    text

    实例所在节点的IP地址

    result

    text

    cgroup在线加载是否成功

    示例:

     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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    select * from pgxc_cgroup_reload_conf();
      node_name   |    node_host    | result
    --------------+-----------------+---------
     dn_6025_6026 | 192.168.178.177 | success
     dn_6049_6050 | 192.168.179.79  | success
     dn_6051_6052 | 192.168.179.79  | success
     dn_6055_6056 | 192.168.179.79  | success
     dn_6067_6068 | 192.168.181.57  | success
     dn_6023_6024 | 192.168.178.39  | success
     dn_6009_6010 | 192.168.181.21  | success
     dn_6011_6012 | 192.168.181.21  | success
     dn_6015_6016 | 192.168.181.21  | success
     dn_6029_6030 | 192.168.178.177 | success
     dn_6031_6032 | 192.168.178.177 | success
     dn_6045_6046 | 192.168.179.45  | success
     cn_5001      | 192.168.178.35  | success
     cn_5003      | 192.168.178.39  | success
     dn_6061_6062 | 192.168.181.179 | success
     cn_5006      | 192.168.179.45  | success
     cn_5004      | 192.168.178.177 | success
     cn_5002      | 192.168.181.21  | success
     cn_5005      | 192.168.178.187 | success
     dn_6019_6020 | 192.168.178.39  | success
     dn_6007_6008 | 192.168.178.35  | success
     dn_6071_6072 | 192.168.181.57  | success
     dn_6003_6004 | 192.168.178.35  | success
     dn_6013_6014 | 192.168.181.21  | success
     dn_6035_6036 | 192.168.178.187 | success
     dn_6037_6038 | 192.168.178.187 | success
     dn_6001_6002 | 192.168.178.35  | success
     dn_6063_6064 | 192.168.181.179 | success
     dn_6005_6006 | 192.168.178.35  | success
     dn_6057_6058 | 192.168.181.179 | success
     dn_6069_6070 | 192.168.181.57  | success
     dn_6027_6028 | 192.168.178.177 | success
     dn_6059_6060 | 192.168.181.179 | success
     dn_6041_6042 | 192.168.179.45  | success
     dn_6043_6044 | 192.168.179.45  | success
     dn_6047_6048 | 192.168.179.45  | success
     dn_6033_6034 | 192.168.178.187 | success
     dn_6065_6066 | 192.168.181.57  | success
     dn_6021_6022 | 192.168.178.39  | success
     dn_6017_6018 | 192.168.178.39  | success
     dn_6039_6040 | 192.168.178.187 | success
     dn_6053_6054 | 192.168.179.79  | success
    (42 rows)
    
  • pgxc_cgroup_reload_conf(text)

    描述:在某个节点上进行cgroup配置文件在线加载。入参为节点的IP地址。

    返回值类型:record

    函数返回字段如下:

    名称

    类型

    描述

    node_name

    text

    实例名称

    node_host

    text

    实例所在节点的IP地址

    result

    text

    cgroup在线加载是否成功

    示例:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    select * from pgxc_cgroup_reload_conf('192.168.178.35');
      node_name   |   node_host    | result
    --------------+----------------+---------
     cn_5001      | 192.168.178.35 | success
     dn_6007_6008 | 192.168.178.35 | success
     dn_6003_6004 | 192.168.178.35 | success
     dn_6001_6002 | 192.168.178.35 | success
     dn_6005_6006 | 192.168.178.35 | success
    (5 rows)
    
  • pg_wlm_jump_queue(pid int)

    描述:调整任务到CN队列的最前端。

    返回值类型:boolean

    备注:如果成功,函数返回true,否则返回false。

  • gs_wlm_switch_cgroup(pid int, cgroup text)

    描述:调整作业的优先级到新控制组。

    返回值类型:boolean

    备注:如果成功,函数返回true,否则返回false。

  • gs_wlm_node_recover(boolean isForce)

    描述:动态资源管理模式下,对CCN管控计数和作业信息进行更新恢复。该函数仅支持管理员执行,通常用于CN实例故障重启后的实例恢复,由集群管理组件(CM)调用,不建议用户直接调用。具体功能如下:

    • CN执行:通知CCN清理该CN执行的作业信息和作业对应的管控计数信息。
    • CCN执行:重置管控计数信息,并从CN上获取最新的慢车道作业信息。

    返回值类型:bool

  • gs_wlm_node_clean(cstring nodename)

    描述:动态资源管理模式下,对CCN上入参指定的CN执行的作业信息和对应的管控计数信息进行清理。该函数仅支持管理员执行,通常用于CN实例故障重启后的实例恢复,由集群管理组件(CM)调用,正常情况下不建议用户直接调用。

    返回值类型:bool