查看unit迁移过程中副本数变化 ----------------------------------------------------------------------------------------------------------------------------
第一:
在副本迁移时候,可以查询以下SQL进行观察 (适用 2.X / 3.X)
查看副本数 select count(*) from __all_virtual_meta_table where svr_ip in ('10.22.6.80'); select count(*) from __all_virtual_rebalance_task_stat where task_type = 'MIGRATE_REPLICA' and tenant_id ='1004'; 查看副本迁移得状态 select * from __all_rootservice_job where job_status='INPROGRESS' and job_type = 'ALTER_TENANT_LOCALITY'; 查看副本迁移中得任务 select * from __all_virtual_partition_migration_status where action<>'END'; 节点卡转储: select tenant_id,ip,round(active/1024/1024) active_mb,round(total/1024/1024) total_mb,round(freeze_trg_mb),freeze_cnt,freeze_pct,mem_usage where tenant_id=1002 order by tenant_id,ip; 查看副本变化: select svr_ip, svr_port, table_id, partition_idx from __all_virtual_clog_stat where is_in_sync= 0 and is_offline = 0 and replica_type !=16; select memeber_list,table_id,partition_id,count(*) as cx from __all_virtual_meta_table group by memeber_list,table_id,partition_id having cx <> 3; select tenant_id ,refreshed_schema_version from __all_virtual_cluster_stats; 取备库clog的同步源 由于主备库的clog同步是按照分区为维度进行的,所以数据同步也需要按照分区看,在备库查看这个视图,role为STANDBY_LEADER的parent,就是拉取日志的源。 select parent,count(*) from __all_virtual_clog_stat where role='STANDBY_LEADER' group by parent; 查询副本还有多少在迁移: 有数据就表示在做。 select count(*),now from __all_virtual_meta_table where is_restore !=0 select count(*),tenant_id from __all_virtual_meta_table where is_restore !=0 group by tenant_id ---min_sys_table_scn 时间滞后,就表示同步时间晚 select tenant_id,refresh_schema_version,ddl_lag, usec_to_time(min_sys_table_scn), usec_to_time(min_user_table_scn) from __all_virtual_cluster_stats; 例如在OB日志中看到: max_ob_clog_sync_delay_seconds{replica_type="16"} 该指标表示租户的 clog 日志在全能型副本之间的同步延迟时间,当其值大于默认值 (10 秒),则触发告警。一般同步延迟时间会在 200 毫秒以内。 检查 CLOG 是否同步。 如果以下 SQL 执行结果为空,则表示 CLOG 已同步。 SELECT svr_ip, count(1) FROM __all_virtual_clog_stat WHERE is_in_sync = 0 and is_offline = 0 and replica_type != 16 GROUP BY svr_ip; select svr_ip,count(*),sum(is_need_rebuild),round(max(next_replay_ts_delta)/1000000) as max_delay,round(min(next_replay_ts_delta)/1000000) as min_delay from __all_virtual_clog_stat where is_in_sync=0 and is_offline=0 group by svr_ip; 查看单个 OBServer 上所有分区归档落后的日志总条数 obclient> SELECT sum(max_log_id-log_archive_cur_log_id) FROM __all_virtual_pg_backup_log_archive_status WHERE svr_ip="" AND svr_port=xxx; 第二:
REPLICA 该语句用来处理副本的迁移,复制,删除,副本类型转换,角色切换等行为。 1、将分区 ID 为 0%0@1100611139403777 的副本从 xxx.xx.xx.xx1 迁移至 xxx.xx.xx.xx2。 obclient> ALTER SYSTEM MOVE REPLICA PARTITION_ID '0%0@1100611139403777' SOURCE 'xxx.xx.xx.xx1:xxxx' DESTINATION 'xxx.xx.xx.xx2:xxxx'; 2、删除分区 ID 为 0%0@1100611139403777 的副本。 obclient> ALTER SYSTEM DROP REPLICA PARTITION_ID '0%0@1100611139403777' SERVER 'xxx.xx.xx.xx1:xxxx'; 3、将分区 ID 为 0%0@1100611139403777 的副本改选为 Leader 副本。 obclient> ALTER SYSTEM SWITCH REPLICA LEADER PARTITION_ID '0%0@1100611139403777' SERVER 'xxx.xx.xx.xx1:xxxx';
标签:__,副本,OceanBase,virtual,xx,clog,select,id,unit From: https://www.cnblogs.com/bayaim/p/18375524