如何用一条SQL 语句 查看业务租户内部所有leader副本的位置

【 使用环境 】生产环境 or 测试环境
【 OB or 其他组件 】
【 使用版本 】4.2.1.6
【问题描述】清晰明确描述问题
【复现路径】问题出现前后相关操作
【附件及日志】推荐使用OceanBase敏捷诊断工具obdiag收集诊断信息,详情参见链接(右键跳转查看):

【SOP系列 22 】——故障诊断第一步(自助诊断和诊断信息收集)

Q1:如何用一条SQL 语句 查看业务租户内部所有leader副本的位置

所有leader是指什么,所有表的leader吗?

在普通租户下,可以通过查询 oceanbase.dba_ob_table_locations 获得各个租户中所有表的各分区位置信息。
select database_name, table_name, table_id, table_type, zone, svr_ip, role from oceanbase.dba_ob_table_locations where table_name = ‘t1’;
在系统租户下,可以通过查询 oceanbase.cdb_ob_table_locations 获得各个租户中所有表的各分区位置信息。
select * from oceanbase.cdb_ob_table_locations where table_name = ‘t1’;

1 个赞

如果是表的leader的话可以参考下面的语句

select * from oceanbase.DBA_OB_TABLE_LOCATIONS where ROLE='LEADER'  and table_name='xxx'

是的,业务租户下的所有leader的副本

q2: dba_ob_table_locations 如何同表组关联,查询表组的 所有leader 的副本

q2: dba_ob_table_locations 如何同表组关联,查询表组的 所有leader 的副本

DBA_OB_TABLEGROUP_TABLES
关联下这个视图

楼下已经给出回复,关联DBA_OB_TABLEGROUP_TABLES即可。

q3: 当我执行如下SQL: 报告如下错误,可有更加高效的SQL?
SELECT
T1.table_name,
T1.tablegroup_name,
T2.role,
T2.zone
FROM
DBA_OB_TABLEGROUP_TABLES T1
JOIN
DBA_OB_TABLE_LOCATIONS T2
ON
T1.table_name = T2.table_name

ErrorCode = 4012, SQLState = HY000, Details = Timeout, query has reached the maximum query timeout: 10000000(us), maybe you can adjust the session variable ob_query_timeout or query_timeout hint, and try again.

q3: 当我执行如下SQL: 报告如下错误,可有更加高效的SQL?
SELECT
T1.table_name,
T1.tablegroup_name,
T2.role,
T2.zone
FROM
DBA_OB_TABLEGROUP_TABLES T1
JOIN
DBA_OB_TABLE_LOCATIONS T2
ON
T1.table_name = T2.table_name

ErrorCode = 4012, SQLState = HY000, Details = Timeout, query has reached the maximum query timeout: 10000000(us), maybe you can adjust the session variable ob_query_timeout or query_timeout hint, and try again.

业务租户ID 加上 看看 效率怎么样 ??

SELECT
T1.table_name,
T1.tablegroup_name,
T2.role,
T2.zone
FROM
DBA_OB_TABLEGROUP_TABLES T1
JOIN
DBA_OB_TABLE_LOCATIONS T2
ON
T1.table_name = T2.table_name
WHERE
T1.tablegroup_name = ‘oceanbase’;

–依然报错
ErrorCode = 4012, SQLState = HY000, Details = Timeout, query has reached the maximum query timeout: 10000000(us), maybe you can adjust the session variable ob_query_timeout or query_timeout hint, and try again.