本文介绍GBase 8a 数据库集群在开启资源管理后,如果通过元数据查看当前的资源管理配置情况。
如下如没有特殊说明,资源管理的元数据表都在gbase数据库下。
与创建资源管理想法,本文采用反向的顺序,先从当前运行状况查找,逐步找到原始的信息。
目录导航
参考
有关资源管理的创建和使用,请参考 : GBase 8a资源管控资源管理的介绍
查看当前激活的资源管理任务 resource_config
可以通过resource_config查看资源计划激活情况。
如下ID=5767206的资源任务是处于激活状态。
gbase> select * from resource_config;
+--------------------------------------+-------------+------------------+------------------+
| config_name | config_type | config_int_value | config_str_value |
+--------------------------------------+-------------+------------------+------------------+
| active_resource_plan_id | int | 5767206 | NULL |
| gbase_resource_monit_record | int | 1 | NULL |
| gbase_resource_monit_record_interval | int | 300 | NULL |
+--------------------------------------+-------------+------------------+------------------+
3 rows in set (Elapsed: 00:00:00.00)
如果没有激活的,则显示0
gbase> select * from resource_config;
+--------------------------------------+-------------+------------------+------------------+
| config_name | config_type | config_int_value | config_str_value |
+--------------------------------------+-------------+------------------+------------------+
| active_resource_plan_id | int | 0 | NULL |
| gbase_resource_monit_record | int | 1 | NULL |
| gbase_resource_monit_record_interval | int | 300 | NULL |
+--------------------------------------+-------------+------------------+------------------+
3 rows in set (Elapsed: 00:00:00.00)
还可以通过系统配置参数:
gbase> show variables like '%active_resource_plan %';
+----------------------+----------+
| Variable_name | Value |
+----------------------+----------+
| active_resource_plan | rp_max10 |
+----------------------+----------+
1 rows in set (Elapsed: 00:00:00.00)
查看资源计划 resource_plan
如下显示编号为5767206的资源计划,其名字为rp_max10。
gbase> select * from resource_plan;
+------------------+--------------------+---------+
| resource_plan_id | resource_plan_name | comment |
+------------------+--------------------+---------+
| 5767206 | rp_max10 | NULL |
+------------------+--------------------+---------+
1 row in set (Elapsed: 00:00:00.00)
查看资源指令 resource_plan_directive
如下看到除了我们自定义的rd_max10,还有个默认的rd_default。都属于相同的资源计划5767206和资源池5767204,但其消费者组不同consumer_group_id,分别对应5767170和1。
gbase> select * from resource_plan_directive;
+------------------------------+------------------+-------------------+------------------+----------+
| resource_plan_directive_name | resource_plan_id | consumer_group_id | resource_pool_id | comments |
+------------------------------+------------------+-------------------+------------------+----------+
| rd_max10 | 5767206 | 5767170 | 5767204 | NULL |
| rd_default | 5767206 | 1 | 5767204 | NULL |
+------------------------------+------------------+-------------------+------------------+----------+
2 rows in set (Elapsed: 00:00:00.00)
查看资源池 resource_pool
如下有2个资源池,其中5767204是前面资源指令中使用中的。从属性resource_pool_type看,1是静态池,0是动态池。而parent_resource_pool_id表示宿主关系:5767204的上级静态资源池属于5767198,也就是dy_max10属于static_max10。
gbase> select * from resource_pool;
+------------------+--------------------+--------------------+-------------------------+----------+------------+---------------------+----------------+---------------+-----------------+-------------+----------------+---------------+-----------------+-----------------+
| resource_pool_id | resource_pool_name | resource_pool_type | parent_resource_pool_id | priority | max_memory | max_tmp_table_space | max_disk_space | task_parallel | max_task_number | cpu_percent | disk_write_bps | disk_read_bps | waiting_timeout | running_timeout |
+------------------+--------------------+--------------------+-------------------------+----------+------------+---------------------+----------------+---------------+-----------------+-------------+----------------+---------------+-----------------+-----------------+
| 5767198 | static_max10 | 1 | 0 | 1 | 4294967296 | 1073741824 | 107374182400 | 0 | 10 | 100 | 104857600 | 104857600 | 2592000 | 2592000 |
| 5767204 | dy_max10 | 0 | 5767198 | 1 | 1048576000 | 209715200 | 2097152000 | 0 | 2 | 100 | 104857600 | 104857600 | 2592000 | 2592000 |
+------------------+--------------------+--------------------+-------------------------+----------+------------+---------------------+----------------+---------------+-----------------+-------------+----------------+---------------+-----------------+-----------------+
2 rows in set (Elapsed: 00:00:00.00)
查看消费者组 consumer_group
注意系统默认自带一个ID=1的默认消费者组,也就是资源指令里的第二行。在这个表里是不显示的。
gbase> select * from consumer_group;
+-------------------+---------------------+-------------------+
| consumer_group_id | consumer_group_name | comment |
+-------------------+---------------------+-------------------+
| 5767170 | cg_max10 | max 10 parrel sql |
+-------------------+---------------------+-------------------+
1 row in set (Elapsed: 00:00:00.00)
查看消费者组里的用户 consumer_group_user
目前对应消费者组5767170的有1个用户,用户名是 abc。
gbase> select * from consumer_group_user;
+-------------------+-----------+
| consumer_group_id | user_name |
+-------------------+-----------+
| 5767170 | abc |
+-------------------+-----------+
1 row in set (Elapsed: 00:00:00.00)
总结
GBase 8a数据库集群,通过资源管理元数据表,为用户详细了解当前资源管理配置提供了当前详细的参数。