测试环境:1-1-1 OceanBase 企业版3.2.4.4
查看集群详细信息
SELECT
zone,
concat(svr_ip, ':', svr_port) observer,
cpu_capacity,
cpu_total,
cpu_assigned,
cpu_assigned_percent,
mem_capacity,
mem_total,
mem_assigned,
mem_assigned_percent,
unit_Num,
round(`load`, 2) `load`,
round(cpu_weight, 2) cpu_weight,
round(memory_weight, 2) mem_weight,
leader_count
FROM __all_virtual_server_stat
ORDER BY zone,svr_ip;
查看租户的 Context 和 Modudle 内存
SELECT
tenant_id,
svr_ip,
ctx_id,
ctx_name,
mod_name,
count,
round(HOLD / 1024 / 1024, 2) hold_mb,
round(used / 1024 / 1024, 2) used_mb
FROM
oceanbase.__all_virtual_memory_info
WHERE
tenant_id = 1
ORDER BY used DESC
LIMIT 10;
查看租户 memstore 内存使用情况
V3 版本用视图 gvmemstore V4 该视图变成了gvob_memstore
SELECT
tenant_id,
ip ,
round(active / 1024 / 1024, 2) active_mb,
round(total / 1024 / 1024, 2) total_mb,
round(freeze_trigger / 1024 / 1024, 2 ) freeze_trg_mb,
round(mem_limit / 1024 / 1024, 2) mem_limit_mb,
freeze_cnt
FROM
oceanbase.gv$memstore m
WHERE
m.tenant_id = 1
ORDER BY ip ;
查看表在 MemStore 中内存占用
V3 版本用视图 gv$memstore_info
V4 该视图变成了gv$ob_memstore_info
SELECT
ip,
t.table_name,
usec_to_time(base_version) base_version_time,
round(used / 1024 / 1024, 1) AS used_mb,
hash_items,
btree_items,
is_active
FROM
gv$memstore_info m
JOIN gv$table t ON
(m.tenant_id = t.tenant_id
AND m.table_id = t.table_id)
WHERE
t.tenant_id = 1
AND t.database_name IN ('test')
ORDER BY
m.ip,
m.base_version DESC ;
每个表的分区在的转储和合并历史
SELECT
m.svr_ip,
t.table_name,
TYPE,
ACTION,
usec_to_time(version) version,
start_time,
end_time ,
macro_block_count blocks
FROM
gv$merge_info m
JOIN gv$table t ON
(m.tenant_id = t.tenant_id
AND m.table_id = t.table_id)
WHERE
m.tenant_id = 1
AND t.table_name IN ('test_table')
AND t.database_name = 'test'
ORDER BY
t.table_name,
start_time DESC ;
SELECT
usec_to_time(request_time) req_time,
tenant_name,
svr_ip,
user_name,
db_name,
ret_code,
trace_id
FROM
gv$sql_audit
WHERE
tenant_id = 1
AND user_name = 'root'
AND ret_code IN (-4030,-4013)
ORDER BY
request_id DESC
LIMIT 10
;
OB 的内存 Context 中,除了 MemStore 外,KVCache、PlanCache、WorkArea 等内存都可以通过视图查看
SELECT
tenant_id,
svr_ip,
cache_name,
priority,
round(cache_size / 1024 / 1024, 2) cache_mb,
round(cache_store_size / 1024 / 1024, 2) cache_store_mb,
round(cache_map_size / 1024 / 1024, 2) cache_map_mb,
kv_cnt,
hit_ratio
FROM
oceanbase.__all_virtual_kvcache_info
WHERE
tenant_id = 1
ORDER BY total_hit_cnt DESC ;
SELECT
tenant_id,
svr_ip,
sql_num,
round(mem_used / 1024 / 1024, 2) mem_used_mb,
round(mem_hold / 1024 / 1024, 2) mem_hold_mb,
round(mem_limit / 1024 / 1024, 2) mem_limit_mb
FROM
oceanbase.gv$plan_cache_stat
WHERE
tenant_id = 1
ORDER BY
mem_used DESC
;
本文章参考自 OBCE V3 培训试验:内存管理分享 (qq.com) 文章写的很好故在自己的集群上做了测试。