租户管理
查看租户基础信息
SELECT
tenant_id,
tenant_name,
tenant_type,
primary_zone,
locality,
compatibility_mode,
status,
0 AS locked,
in_recyclebin,
timestampdiff(
second,
create_time,
now()
) AS exist_seconds
FROM
dba_ob_tenants
WHERE
tenant_type IN ('SYS', 'USER');
查询 Unit 规格列表
SELECT
unit_config_id,
name,
max_cpu,
min_cpu,
round(memory_size / 1024 / 1024 / 1024) max_memory_size_gb,
round(memory_size / 1024 / 1024 / 1024) min_memory_size_gb,
round(log_disk_size / 1024 / 1024 / 1024) log_disk_size_gb,
max_iops,
min_iops,
iops_weight
FROM
dba_ob_unit_configs
ORDER BY
unit_config_id;
查询资源池列表
SELECT
/* MONITOR_AGENT */
p.tenant_id,
u.svr_ip,
uc.name,
uc.max_cpu,
uc.min_cpu,
round(uc.memory_size / 1024 / 1024 / 1024) AS max_memory_gb,
round(uc.log_disk_size / 1024 / 1024 / 1024) AS log_disk_size_gb,
uc.max_iops,
uc.min_iops
FROM
dba_ob_resource_pools p,
dba_ob_unit_configs uc,
dba_ob_units u
WHERE
p.unit_config_id = uc.unit_config_id
AND u.resource_pool_id = p.resource_pool_id
ORDER BY
p.tenant_id,
u.svr_ip,
uc.name;
查询 Unit 列表
root@sys
登陆查询,
SELECT
tenant_id,
svr_ip,
svr_port,
unit_id,
status,
create_time,
modify_time,
zone,
unit_config_id,
max_cpu,
min_cpu,
round(memory_size / 1024 / 1024 / 1024) memory_size_gb,
round(log_disk_size / 1024 / 1024 / 1024) log_disk_size_gb,
max_iops,
min_iops
FROM
dba_ob_units
ORDER BY
tenant_id,
svr_ip,
svr_port,
unit_id;
查看租户已使用磁盘资源
SELECT
t1.unit_id,
t1.svr_ip,
t1.svr_port,
t3.tenant_id,
t3.tenant_name,
round(t1.log_disk_size / 1024 / 1024 / 1024) AS log_disk_size_gb,
round(t1.log_disk_in_use / 1024 / 1024 / 1024) AS log_disk_in_use_gb,
round(t1.data_disk_in_use / 1024 / 1024 / 1024) AS data_disk_in_use_gb
FROM
(
SELECT
unit_id,
svr_ip,
svr_port,
SUM(log_disk_size) AS log_disk_size,
SUM(log_disk_in_use) AS log_disk_in_use,
SUM(data_disk_in_use) AS data_disk_in_use
FROM
gv$ob_units
GROUP BY
unit_id,
svr_ip,
svr_port
) t1
JOIN dba_ob_units t2 ON t1.unit_id = t2.unit_id
AND t1.svr_ip = t2.svr_ip
AND t1.svr_port = t2.svr_port
JOIN (
SELECT
tenant_id,
tenant_name
FROM
dba_ob_tenants
WHERE
tenant_type IN ('SYS', 'USER')
) t3 ON t2.tenant_id = t3.tenant_id
ORDER BY
t3.tenant_id,
t1.svr_ip,
t1.svr_port,
t1.unit_id;
查看租户数据量
root@sys
登陆查询,
SELECT
tenant_id,
svr_ip,
svr_port,
round(SUM(data_size) / 1024 / 1024) data_size_mb,
round(SUM(required_size) / 1024 / 1024) required_size_mb
FROM
cdb_ob_tablet_replicas
WHERE
tenant_id = 1002
GROUP BY
tenant_id,
svr_ip,
svr_port
ORDER BY
tenant_id,
svr_ip,
svr_port;
用户租户下,执行如下 SQL,
SELECT
svr_ip,
svr_port,
round(SUM(data_size) / 1024 / 1024) data_size_mb,
round(SUM(required_size) / 1024 / 1024) required_size_mb
FROM
dba_ob_tablet_replicas
GROUP BY
svr_ip,
svr_port
ORDER BY
svr_ip,
svr_port;