更新时间:2026-07-28 GMT+08:00
分享

同城双中心计划内倒换switchover流程异常

问题现象

  • 现象一:

    主降备出现流程失败,查看日志primary_demote超时失败。

  • 现象二:

    备升主出现等待集群状态恢复为normal状态超时,集群状态Unavailable,存在分片无主DN。

  • 现象三:

    容灾倒换出现失败。

  • 现象四:

    主备倒换过程中,有故障节点未参与容灾倒换。

  • 现象五:

    计划内switchover主降备成功,但在降备过程中,主集群的主DN或CN进程发生退出。

原因分析

  • 现象一原因:

    查看失败节点日志,主要是checkpoint时,需要刷新的脏页较多,超过primary_demote的等待时间。

  • 现象二原因:

    日志回放所需时间超过了switchover升主流程等待时间(300秒),导致集群无法在300秒内恢复为normal或degraded状态,switchover升主流程失败。

  • 现象三原因:

    倒换失败原因较多,这里补充下简单定位手段快速定位定界

    1. 从最新的OM日志(最新的$GAUSSLOG/om/gs_om*日志)中关键字查询,判断是否切换失败,以及存在回滚。
    2. 根据查询的Error信息中的详细报错信息,或者$PGHOST目录的步骤文件do_dorado_switch.dat,可定位到具体快速倒换中的哪一步出现问题。
    3. 根据上一步定位出的失败原因,去对应的集群节点查看OM_Agent日志或者gs_log日志,获取到具体的失败原因。
  • 现象四原因:

    因服务器宕机,网络中断等原因导致节点未参与主备倒换。

  • 现象五原因:

    在对应进程日志中搜索关键字“abort switchover”。若存在该关键字,表示因降备超时导致进程主动退出,属于正常现象,待进程被CM重新拉起即可。若未找到,则需要进一步排查日志确定原因。

处理方法

  • 现象一处理方法:
  1. 等待主DN降为备DN成功。
  2. 重入switchover主降备流程。
  • 现象二处理方法:
  1. 等待集群恢复normal或者degraded状态后。
  2. 重新执行switchover命令,进行重试。

倒换流程故障处理步骤:

  1. 通过cm_ctl工具确认集群是否完成倒换或者回滚,集群状态是否正常,异常节点可使用节点修复功能。

    cm_ctl query -Cvp
    主集群normal态示例:
    [  CMServer State   ]
    
    node              instance state
    ----------------------------------
    1  <IP>  1        Primary
    2  <IP>  2        Standby
    3  <IP>  3        Standby
    
    [    ETCD State     ]
    
    node              instance state
    ----------------------------------------
    1  <IP>  7001     StateFollower
    2  <IP>  7002     StateLeader
    3  <IP>  7003     StateFollower
    
    [   Cluster State   ]
    
    cluster_state   : Normal
    redistributing  : No
    balanced        : Yes
    current_az      : AZ_ALL
    
    [ Coordinator State ]
    
    node              instance        state
    ----------------------------------
    1  <IP>  5001 <PORT>       Normal
    2  <IP>  5002 <PORT>       Normal
    3  <IP>  5003 <PORT>       Normal
    
    [ Central Coordinator State ]
    
    node              instance state
    ----------------------------------
    1  <IP>  5001     Normal
    
    [     GTM State     ]
    
    node              instance state                    sync_state
    ------------------------------------------------------------------
    1  <IP>  1001     P Primary Connection ok  Sync
    2  <IP>  1002     S Standby Connection ok  Sync
    3  <IP>  1003     S Standby Connection ok  Sync
    
    [  Datanode State   ]
    
    node              instance        state            | node              instance        state            | node              instance state
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------
    1  <IP>  6001 <PORT>       P Primary Normal | 2  <IP>  6002 <PORT>       S Standby Normal | 3  <IP>  6003 <PORT>       S Standby Normal
    2  <IP>  6004 <PORT>       P Primary Normal | 3  <IP>  6005 <PORT>       S Standby Normal | 1  <IP>  6006 <PORT>       S Standby Normal
    3  <IP>  6007 <PORT>       P Primary Normal | 1  <IP>  6008 <PORT>       S Standby Normal | 2  <IP>  6009 <PORT>       S Standby Normal
    

    灾备集群normal态示例:

    [  CMServer State   ]
    
    node              instance state
    ----------------------------------
    1  <IP>  1        Primary
    2  <IP>  2        Standby
    3  <IP>  3        Standby
    
    [    ETCD State     ]
    
    node              instance state
    ----------------------------------------
    1  <IP>  7001     StateFollower
    2  <IP>  7002     StateLeader
    3  <IP>  7003     StateFollower
    
    [   Cluster State   ]
    
    cluster_state   : Normal
    redistributing  : No
    balanced        : Yes
    current_az      : AZ_ALL
    
    [ Coordinator State ]
    
    node              instance        state
    ----------------------------------
    1  <IP>  5001 <PORT>       Normal
    2  <IP>  5002 <PORT>       Normal
    3  <IP>  5003 <PORT>       Normal
    
    [ Central Coordinator State ]
    
    node              instance state
    ----------------------------------
    1  <IP>  5001     Normal
    
    [     GTM State     ]
    
    node              instance state                    sync_state
    ------------------------------------------------------------------
    1  <IP>  1001     P Primary Connection ok  Sync
    2  <IP>  1002     S Standby Connection ok  Sync
    3  <IP>  1003     S Standby Connection ok  Sync
    
    [  Datanode State   ]
    
    node              instance        state            | node              instance        state            | node              instance state
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------
    1  <IP>  6001 <PORT>       P Standby Normal | 2  <IP>  6002 <PORT>       S Standby Normal | 3  <IP>  6003 <PORT>       S Standby Normal
    2  <IP>  6004 <PORT>       P Standby Normal | 3  <IP>  6005 <PORT>       S Standby Normal | 1  <IP>  6006 <PORT>       S Standby Normal
    3  <IP>  6007 <PORT>       P Standby Normal | 1  <IP>  6008 <PORT>       S Standby Normal | 2  <IP>  6009 <PORT>       S Standby Normal

  2. 倒换失败集群参数,使用gs_om工具进行查询。

    gs_om -t dr_post_check -c [switchover|failover|query|restore] -m [primary|disaster_standby] --dr_type dorado_cluster
    • 主集群相关参数:
      • cmserver参数backup_open=0,dn_arbitrate_mode=quorum,cm_hadr_process_type=none。
      • cmagent参数agent_backup_open=0,enable_auto_start=1,cm_hadr_process_type=none。
      • etcd参数/xxxx/CMServer/backup_open=0。
      • CN参数cluster_run_mode=cluster_primary,hadr_process_type=none,auto_csn_barrier=1,default_transaction_read_only=off。
      • DN参数cluster_run_mode=cluster_primary,hadr_process_type=none,default_transaction_read_only=off。
    • 灾备集群相关参数:
      • cmserver参数backup_open=1,dn_arbitrate_mode=quorum,cm_hadr_process_type=none。
      • cmagent参数agent_backup_open=1,enable_auto_start=1,cm_hadr_process_type=none。
      • etcd参数/xxxx/CMServer/backup_open=1。
      • CN参数cluster_run_mode=cluster_standby,hadr_process_type=none,auto_csn_barrier=0,default_transaction_read_only=off。
      • DN参数cluster_run_mode=cluster_standby,hadr_process_type=none,default_transaction_read_only=off。

  3. 后置接口若发现有未参与倒换、参数配置错误的实例,出现双灾备集群状态的极端场景,需人工介入修复。

    • 两种情况可导致集群无主集群可用:

      1.主降备流程在写下Reduce standby success之前,数据库主集群降备失败,进入回滚流程,回滚失败。

      2.灾备集群升主流程失败。

      使用gs_om工具对集群进行修复,快速修复主集群对外提供服务。
      echo "password" | gs_om -t dr_cluster_manual_recovery -m primary --dr_type dorado_cluster [--time-out=SECS]

  4. 故障节点经过硬件维修、上电等操作,重新加入集群。

    该节点加入集群后,集群状态有可能显示为Normal,该节点上集群状态也有可能显示Normal,但该节点上集群的部分配置参数不正确,仍需要完成如下修复流程。

    • 通过后置检查接口查询未参与容灾倒换的集群。
      gs_om -t dr_post_check -c switchover -m primary|disaster_standby --dr_type dorado_cluster
    • 使用cm_ctl stop停掉未参与容灾倒换的coordinator、datanode以及cm_server实例。
      cm_ctl stop -n NODEID -D DATADIR

相关文档