[Feature]: 能否提供TABLEDUMP功能
Describe your use case
提供TABLEDUMP功能
Describe the solution you'd like
在TABLEDUMP中,将表的建表脚本,表数据分布情况(在不同OBSERVER上的分片数量,数据容量),是否存在倾斜,是否存在空洞等做详细的DUMP
Describe alternatives you've considered
No response
Additional context
No response
obdiag gather scene 是按照yaml方式编排的信息采集场景,obdiag gather scene list 可以列出支持的套餐。 参考文档:https://open.oceanbase.com/blog/9965179152
TABLEDUMP 这个功能可以非常小成本的在obdiag中实现,添加一个yaml(相当于增加了一个场景),比如:
obdiag gather scene run --scene=observer.table_dumper--env "{db_connect='-hxx -Pxx -uxx -pxx -Dxx', table_name='xx'}"
表的建表脚本,表数据分布情况(在不同OBSERVER上的分片数量,数据容量),是否存在倾斜,是否存在空洞等通过定义好的yaml文件按照sql来查询就行。
1
4月7号沟通:按照基础场景来定义
移动到2.2.0迭代
-- ob >= 4.0 查询table_id
select /*+read_consistency(weak) QUERY_TIMEOUT(60000000) */
t.table_id from oceanbase.__all_virtual_table t where t.tenant_id = ? and t.database_id = ? and table_name = ? limit 1;
-- ob < 4.0 查询表数据大小,行数
select /*+read_consistency(weak) QUERY_TIMEOUT(60000000) */
m.svr_ip,
m.role,
m.data_size total_data_size,
m.row_count as total_rows_count
from oceanbase.__all_virtual_meta_table m, oceanbase.__all_virtual_table t
where m.table_id = t.table_id and m.tenant_id = ? and m.table_id = ? and t.table_name = ? order by total_rows_count desc limit 1
-- ob >= 4.0 查询表数据大小
select /*+read_consistency(weak) QUERY_TIMEOUT(60000000) */
t1.svr_ip,
t1.role,
ifnull(t2.data_size,0) as total_data_size
from (select tenant_id, database_name, role, table_id, tablet_id
from oceanbase.cdb_ob_table_locations) t1 left join
(select tenant_id, tablet_id,
data_size from oceanbase.cdb_ob_tablet_replicas)
t2 on t1.tenant_id = t2.tenant_id and
t1.tablet_id = t2.tablet_id where t1.tenant_id = ? and t1.table_id = ? order by total_data_size desc limit 1;
-- ob >= 4.0 查询表数行数
select /*+read_consistency(weak) QUERY_TIMEOUT(60000000) */
ifnull(num_rows,0) from cdb_tables where con_id = ? and owner = ? and table_name = ? order by num_rows desc limit 1;
database_id查看: ob >=4.0版本
SELECT con_id as tenant_id, object_id as database_id, object_name as database_name FROM oceanbase.cdb_objects where OBJECT_TYPE = 'DATABASE' and con_id = ?
ob<4.0版本
select tenant_id,database_id,database_name from gv$database where tenant_name = ? and database_name = ?
PR #311