摘要:本文主要著重介紹資源池資源監控以及用戶資源監控。 本文分享自華為雲社區《GaussDB(DWS)資源監控之用戶、隊列資源監控》,作者: 一隻菜菜鳥。 GaussDB(DWS)資源監控功能包含實例資源監控、記憶體資源監控、資源池資源監控、查詢監控以及用戶資源監控,本文主要著重介紹資源池資源監控以及 ...
摘要:本文主要著重介紹資源池資源監控以及用戶資源監控。
本文分享自華為雲社區《GaussDB(DWS)資源監控之用戶、隊列資源監控》,作者: 一隻菜菜鳥。
GaussDB(DWS)資源監控功能包含實例資源監控、記憶體資源監控、資源池資源監控、查詢監控以及用戶資源監控,本文主要著重介紹資源池資源監控以及用戶資源監控;
多租戶
用戶是使用資料庫系統以及執行業務的主要手段,在GaussDB(DWS)中將用戶場景分為兩種方案,分別是普通方案以及多租戶方案;為了更好的使用GaussDB(DWS)的資源分組管理,建議依托多租戶場景構造具體的使用情況;
多租戶引入了兩級用戶機制,分別為組用戶以及業務用戶;兩級用戶分別關聯不同的資源池以及存儲空間;
示例
1、創建組用戶關聯到組資源池
CREATE USER user_g RESOURCE POOL 'respool_g1' PASSWORD 'Gauss_234';
2、創建業務用戶關聯到業務資源池
CREATE USER user_1 RESOURCE POOL 'respool_g1' USER GROUP 'user_g' PASSWORD 'Gauss_234';
註:創建業務用戶時,業務資源池(resource pool)和組用戶(user group)為必選欄位;
用戶資源監控
用戶資源監控中記錄所有用戶使用資源(記憶體、CPU核數、存儲空間、臨時空間、運算元落盤以及IO)的實時使用情況,也可以通過查詢歷史表訪問用戶資源的歷史使用情況;
相關GUC參數:
相關視圖/表:
實時視圖為:pg_total_user_resource_info;
username | used_memory | total_memory | used_cpu | total_cpu | used_space | total_space | used_temp_space | total_temp_space | used_spill_space | total_spill_space | read_kbytes | write_kbytes | read_counts | write_counts | read_speed | write_speed -----------------+-------------+--------------+----------+-----------+------------+-------------+-----------------+------------------+------------------+-------------------+-------------+--------------+-------------+--------------+------------+------------- perfadm | 0 | 0 | 0 | 0 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g1_job_2 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_grp_2 | 0 | 5574 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g1_job_1_2 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_2 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_grp_1 | 0 | 5574 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_1 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_4 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g1_job_1_1 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g2_job_1 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_5 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_3 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g2_job_2 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 (13 rows)
歷史視圖為:gs_wlm_user_resource_history;
username | timestamp | used_memory | total_memory | used_cpu | total_cpu | used_space | total_space | used_temp_space | total_temp_space | used_spill_space | total_spill_space | read_kbytes | write_kbytes | read_counts | write_counts | read_speed | write_speed -------------------+-------------------------------+-------------+--------------+----------+-----------+------------+-------------+-----------------+------------------+------------------+-------------------+-------------+--------------+-------------+--------------+------------+------------- perfadm | 2022-06-29 14:26:32.063948+08 | 0 | 0 | 0 | 0 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_3 | 2022-06-29 14:26:32.063948+08 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_5 | 2022-06-29 14:26:32.063948+08 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g2_job_1 | 2022-06-29 14:26:32.063948+08 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g1_job_1_1 | 2022-06-29 14:26:32.063948+08 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_4 | 2022-06-29 14:26:32.063948+08 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_1 | 2022-06-29 14:26:32.063948+08 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_grp_1 | 2022-06-29 14:26:32.063948+08 | 0 | 5574 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_2 | 2022-06-29 14:26:32.063948+08 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g1_job_1_2 | 2022-06-29 14:26:32.063948+08 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_grp_2 | 2022-06-29 14:26:32.063948+08 | 0 | 5574 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g2_job_2 | 2022-06-29 14:26:32.063948+08 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g1_job_2 | 2022-06-29 14:26:32.063948+08 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_1 | 2022-06-29 14:26:01.987779+08 | 0 | 27876 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0 user_g2_job_2 | 2022-06-29 14:26:01.987779+08 | 0 | 1113 | 0 | 24 | 0 | -1 | 0 | -1 | 0 | -1 | 0 | 0 | 0 | 0 | 0 | 0
資源池資源監控
多租戶場景下,用戶關聯資源池執行業務,其消耗的資源彙總到其對應的資源池上,可以通過資源池資源監控視圖,實時查看其相應數值,以及歷史表記錄的資源歷史使用情況;
相關GUC參數
同用戶資源監控相關GUC參數。
相關視圖/表
資源池實時信息監控視圖:GS_RESPOOL_RUNTIME_INFO
nodegroup | rpname | ref_count | fast_run | fast_wait | slow_run | slow_wait -----------+------------------+-----------+----------+-----------+----------+----------- lc1 | respool_grp_1 | 0 | 0 | 0 | 0 | 0 lc1 | default_pool | 0 | 0 | 0 | 0 | 0 lc1 | respool_g1_job_1 | 0 | 0 | 0 | 0 | 0 lc1 | respool_g1_job_2 | 0 | 0 | 0 | 0 | 0 lc1 | respool_grp_2 | 0 | 0 | 0 | 0 | 0 lc1 | respool_g2_job_1 | 0 | 0 | 0 | 0 | 0 lc1 | respool_g2_job_2 | 0 | 0 | 0 | 0 | 0 lc1 | respool_1 | 0 | 0 | 0 | 0 | 0 lc1 | respool_2 | 0 | 0 | 0 | 0 | 0 lc2 | default_pool | 0 | 0 | 0 | 0 | 0 lc1 | respool_3 | 0 | 0 | 0 | 0 | 0 (11 rows)
資源池實時資源監控視圖:GS_RESPOOL_RESOURCE_INFO
nodegroup | rpname | cgroup | ref_count | fast_run | fast_wait | fast_limit | slow_run | slow_wait | slow_limit | used_cpu | cpu_limit | used_mem | estimate_mem | mem_limit | read_kbytes | write_kbytes | read_counts | write_counts | read_speed | write_speed -----------+------------------+---------------------+-----------+----------+-----------+------------+----------+-----------+------------+----------+-----------+----------+--------------+-----------+-------------+--------------+-------------+--------------+------------+------------- lc1 | respool_grp_1 | ClassG1 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 5574 | 0 | 0 | 0 | 0 | 0 | 0 lc1 | default_pool | DefaultClass:Medium | 0 | 0 | 0 | -1 | 0 | 0 | -1 | 0 | 24 | 0 | 0 | 27876 | 0 | 0 | 0 | 0 | 0 | 0 lc1 | respool_g1_job_1 | ClassG1:wg1_1 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 1113 | 0 | 0 | 0 | 0 | 0 | 0 lc1 | respool_g1_job_2 | ClassG1:wg1_2 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 1113 | 0 | 0 | 0 | 0 | 0 | 0 lc1 | respool_grp_2 | ClassG2 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 5574 | 0 | 0 | 0 | 0 | 0 | 0 lc1 | respool_g2_job_1 | ClassG2:wg2_1 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 1113 | 0 | 0 | 0 | 0 | 0 | 0 lc1 | respool_g2_job_2 | ClassG2:wg2_2 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 1113 | 0 | 0 | 0 | 0 | 0 | 0 lc1 | respool_1 | ClassN1:wn1 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 27876 | 0 | 0 | 0 | 0 | 0 | 0 lc1 | respool_2 | ClassN1:wn2 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 27876 | 0 | 0 | 0 | 0 | 0 | 0 lc2 | default_pool | DefaultClass:Medium | 0 | 0 | 0 | -1 | 0 | 0 | -1 | 0 | 24 | 0 | 0 | 27876 | 0 | 0 | 0 | 0 | 0 | 0 lc1 | respool_3 | ClassN2:wn3 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 27876 | 0 | 0 | 0 | 0 | 0 | 0 (11 rows)
資源池歷史資源監控表:GS_RESPOOL_RESOURCE_HISTORY
timestamp | nodegroup | rpname | cgroup | ref_count | fast_run | fast_wait | fast_limit | slow_run | slow_wait | slow_limit | used_cpu | cpu_limit | used_mem | estimate_mem | mem_limit | read_kbytes | write_kbytes | read_counts | write_counts | read_speed | write_speed -------------------------------+-----------+----------------------+---------------------+-----------+----------+-----------+------------+----------+-----------+------------+----------+-----------+----------+--------------+-----------+-------------+--------------+-------------+--------------+------------+------------- 2022-06-29 14:35:02.262234+08 | lc1 | respool_grp_1 | ClassG1 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 5574 | 0 | 0 | 0 | 0 | 0 | 0 2022-06-29 14:35:02.262234+08 | lc1 | respool_3 | ClassN2:wn3 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 27876 | 0 | 0 | 0 | 0 | 0 | 0 2022-06-29 14:35:02.262234+08 | lc2 | default_pool | DefaultClass:Medium | 0 | 0 | 0 | -1 | 0 | 0 | -1 | 0 | 24 | 0 | 0 | 27876 | 0 | 0 | 0 | 0 | 0 | 0 2022-06-29 14:35:02.262234+08 | lc1 | respool_2 | ClassN1:wn2 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 27876 | 0 | 0 | 0 | 0 | 0 | 0 2022-06-29 14:35:02.262234+08 | lc1 | respool_1 | ClassN1:wn1 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 27876 | 0 | 0 | 0 | 0 | 0 | 0 2022-06-29 14:35:02.262234+08 | lc1 | respool_g2_job_2 | ClassG2:wg2_2 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 1113 | 0 | 0 | 0 | 0 | 0 | 0 2022-06-29 14:35:02.262234+08 | lc1 | respool_g2_job_1 | ClassG2:wg2_1 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 1113 | 0 | 0 | 0 | 0 | 0 | 0 2022-06-29 14:35:02.262234+08 | lc1 | respool_grp_2 | ClassG2 | 0 | 0 | 0 | -1 | 0 | 0 | 10 | 0 | 24 | 0 | 0 | 5574 | 0 | 0 | 0 | 0 | 0 | 0 2022-06-29 14:35:02.262234+