前言
继续整理分享OceanBase的常用脚本,下面脚本适用用OB2.x和3.x版本。
租户资源&集群信息(OB3.X MySQL)
【租户资源】
#查看租户
select * from oceanbase.__all_tenant;
#查看资源单元配置
SELECT * FROM oceanbase.__all_unit_config;
#查看资源池
SELECT * FROM oceanbase.__all_resource_pool;
#查看服务器可用资源
SELECT a.zone, concat(a.svr_ip,’:’,a.svr_port) observer, cpu_total, (cpu_total-cpu_max_assigned) cpu_free, round(mem_total/1024/1024/1024) mem_total_gb,round((mem_total-mem_max_assigned)/1024/1024/1024) mem_free_gb, b.status FROM oceanbase.__all_virtual_server_stat a JOIN oceanbase.__all_server b ON (a.svr_ip=b.svr_ip AND a.svr_port=b.svr_port) ORDER BY a.zone, a.svr_ip;
#已分配资源池情况
select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu, round(t2.max_memory/1024/1024/1024) max_mem_gb, round(t2.min_memory/1024/1024/1024) min_mem_gb, t3.unit_id, t3.zone, concat(t3.svr_ip,’:’,t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id) join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`) left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id) order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id;
#查看集群资源由各个节点的聚合情况
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 oceanbase.__all_virtual_server_stat order by zone, svr_ip;
【集群信息】
#查看版本
show variables like ‘version_comment’;
#查看集群ID和集群名
show parameters like ‘%cluster%’;
#查看OB集群状态
select svr_ip,svr_port, id,zone,inner_port,status,usec_to_time(stop_time), usec_to_time(start_service_time),usec_to_time(last_offline_time) from oceanbase.__all_server;
#查看集群信息
SELECT * FROM oceanbase.v$ob_cluster;
#查看节点服务是否正常
SELECT a.zone, concat(a.svr_ip,’:’, a.svr_port) observer, cpu_total, (cpu_total-cpu_assigned) cpu_free, round(mem_total/1024/1024/1024) mem_total_gb, round((mem_total-mem_assigned)/1024/1024/1024) mem_free_gb, usec_to_time(b.last_offline_time) last_offline_time, usec_to_time(b.start_service_time) start_service_time, b.status, usec_to_time(b.stop_time) stop_time, b.build_version FROM oceanbase.__all_virtual_server_stat a join oceanbase.__all_server b on (a.svr_ip=b.svr_ip and a.svr_port=b.svr_port) ORDER BY a.zone, a.svr_ip;
后记
如果您发现有错误的地方,还请留言指出,感谢
想了解更多干货,可通过下方扫码关注
详情咨询
可扫码添加上智启元官方客服微信👇