3版本的ob如何单独修改表的primary zone

【 使用环境 】测试环境
【 OB or 其他组件 】3.2
【 使用版本 】
【问题描述】由于我的一台服务器故障,表的primary zone跑到zone2去了,现在zone1修好后,表的主角色依然在zone2.如何将它弄回zone1哪?

【附件】

ALTER TABLE test SET PRIMARY_ZONE='zone1;zone2';

完整语法介绍如下文档:
https://www.oceanbase.com/docs/community-observer-cn-10000000000449801

考虑是不是修zone1的故障前没有把server_permanent_offline_time调大才导致的。 修改primary zone就 alter table table_name set primary_zone = “zone1;zone2,zone3”。不过可以先试一试做一次手动合并,没准原来的zone1副本也能迁回来

首先要判断 zone1 的节点是否完全恢复。

在 SYS 租户下查询。

select zone,svr_ip ,status, block_migrate_in_time , with_partition , usec_to_time(stop_time) stop_time, usec_to_time(last_offline_time) last_offline_time,  usec_to_time(start_service_time) start_service_time 
from __all_server ;
zone svr_ip status block_migrate_in_time with_partition stop_time last_offline_time start_service_time
zone1 10.0.0.61 active 0 1 1970-01-01 08:00:00.000 1970-01-01 08:00:00.000 2023-06-20 08:26:14.944
ZONE2 10.0.0.62 active 0 1 1970-01-01 08:00:00.000 1970-01-01 08:00:00.000 2023-06-20 08:26:11.686
ZONE3 10.0.0.63 active 0 1 1970-01-01 08:00:00.000 1970-01-01 08:00:00.000 2023-06-20 08:26:36.541

start_service_time 为最近的时间就表示节点开始提供服务了。

查一下最近的事件是否还有分区在迁移和切主。

select gmt_create , module , event, name1 , value1 , name2, value2, name3, value3 , rs_svr_ip 
from `__all_rootservice_event_history` areh
WHERE 1=1 
-- AND module IN ('daily_merge','root_service')
AND module NOT IN ('schema_recycler')   
-- AND value1 LIKE '%1105009185964985%'
-- AND  name1  IN ('partition')
order by gmt_create  desc limit 50;

第三要判断表所在的租户的 primary_zone 策略。以及表是否归属表分组(表分组的primary_zone)策略,最后才是考虑 表的 primary_zone 。

select t1.tenant_name, t1.zone_list, t1.locality, t1.primary_zone, t2.database_name, tg.tablegroup_name , tg.primary_zone tg_primary_zone, t2.table_name, t2.zone_list table_zone_list, t2.primary_zone table_primary_zone
from gv$tenant t1 join gv$table t2 on (t1.tenant_id=t2.tenant_id)
left join `__all_tablegroup` tg on (t2.tablegroup_id=tg.tablegroup_id)
where t2.table_name in ('bmsql_item') and t2.database_name='tpccdb'
;
tenant_name zone_list locality primary_zone database_name tablegroup_name primary_zone table_name zone_list primary_zone
obmysql ZONE2;ZONE3;zone1 FULL{1}@ZONE2, FULL{1}@ZONE3, FULL{1}@zone1 ZONE2,zone1 tpccdb bmsql_item ZONE2;ZONE3;zone1 ZONE2,zone1