暂无图片
暂无图片
3
暂无图片
暂无图片
暂无图片

MogDB主备switchover

原创 董宏伟 云和恩墨 2023-06-18
383

可选方案介绍

功能点 ptkc gs_ctl gs_om
查询数据库状态 支持集群/实例 仅支持本地实例 支持集群/实例
启动数据库 支持集群/实例 仅支持本地实例 支持集群/实例
关闭数据库 支持集群/实例 仅支持本地实例 支持集群/实例
重启数据库 支持集群/实例 仅支持本地实例 支持集群/实例
重建数据库 支持本地/远程 仅支持本地实例 支持本地/远程
指定上游节点重建数据库 支持 支持 不支持
failover 支持本地/远程 仅支持本地实例 不支持
switchover 支持本地/远程 仅支持本地实例 不支持
查看数据库参数 支持本地/远程 不支持 不支持
查看HBA内容 支持本地/远程 不支持 不支持

gs_ctl切换步骤

omm登录数据库任意节点,执行如下命令,查看主备情况

[omm@mogdb01 ~]$ gs_om -t status --detail 
[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

    node   node_ip         port      instance                state
----------------------------------------------------------------------------------
1  mogdb01 192.168.31.60   26000      6001 /opt/mogdb/data   P Primary Normal
2  mogdb02 192.168.31.61   26000      6002 /opt/mogdb/data   S Standby Normal
[omm@mogdb01 ~]$ 
复制

omm登录准备切换为主节点的备节点,执行如下命令

[omm@mogdb02 ~]$ gs_ctl switchover -D /opt/mogdb/data
[2023-06-18 21:27:06.781][3309][][gs_ctl]: gs_ctl switchover ,datadir is /opt/mogdb/data 
[2023-06-18 21:27:06.781][3309][][gs_ctl]: switchover term (1)
[2023-06-18 21:27:06.785][3309][][gs_ctl]: waiting for server to switchover........
[2023-06-18 21:27:11.819][3309][][gs_ctl]: done
[2023-06-18 21:27:11.819][3309][][gs_ctl]: switchover completed (/opt/mogdb/data)
[omm@mogdb02 ~]$ 

复制

/opt/mogdb/data为备数据库节点的数据目录。

如下为切换过程原主库输出日志

2023-06-18 21:27:06.741 omm [unknown] 192.168.31.61(51178) 47071487923968 0[0:0#0] 0 [BACKEND] LOG:  received fast switchover request from standby
2023-06-18 21:27:06.742 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  mogdb: fsync file "/opt/mogdb/data/gaussdb.state.temp" success
2023-06-18 21:27:06.742 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  update gaussdb state file: db state(DEMOTING_STATE), server mode(Primary)
2023-06-18 21:27:06.742 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  received fast demote request
2023-06-18 21:27:06.742 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  wlm collect worker process shutting down.
2023-06-18 21:27:06.742 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  aborting any active transactions
2023-06-18 21:27:06.742 [unknown] [unknown] localhost 47070718789376 0[0:0#0] 0 [BACKEND] LOG:  invalidate buffer bgwriter thread shut down
2023-06-18 21:27:06.742 omm postgres localhost(???) 47071356663552 0[0:0#0] 0 [BACKEND] ERROR:  terminate because cancel interrupts
2023-06-18 21:27:06.746 [unknown] [unknown] localhost 47071108941568 0[0:0#0] 0 [BACKEND] LOG:  global stats shutting down
2023-06-18 21:27:06.746 [unknown] [unknown] localhost 47071388174080 0[0:0#0] 0 [UNDO] LOG:  [ShutDownRecycle:424]UndoRecycler: shutting down
2023-06-18 21:27:06.748 omm postgres localhost 47071058597632 0[0:0#0] 0 [BACKEND] LOG:  job scheduler is shutting down
2023-06-18 21:27:06.748 [unknown] [unknown] localhost 47071075378944 0[0:0#0] 0 [BACKEND] LOG:  autovacuum launcher shutting down
2023-06-18 21:27:06.748 [unknown] [unknown] localhost 47071092160256 0[0:0#0] 0 [BACKEND] LOG:  undo launcher shutting down
2023-06-18 21:27:06.762 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [REDO] LOG:  page workers all exit or not open parallel redo
2023-06-18 21:27:06.762 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  all build walsenders exited
2023-06-18 21:27:06.772 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  database first startup and recovery finish,so do checkpointer
2023-06-18 21:27:06.772 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  shutting down
2023-06-18 21:27:06.791 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  will do full checkpoint, need flush 0 pages.
2023-06-18 21:27:06.791 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  checkpoint starting: shutdown immediate
2023-06-18 21:27:06.792 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [SLRU] LOG:  remove old segments(<0) under pg_csnlog
2023-06-18 21:27:06.792 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  truncate CSN log oldestXact 20256, next xid 20270
2023-06-18 21:27:07.169 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [DBL_WRT] LOG:  [batch flush] DW truncate end: file_head[dwn 1, start 843], total_pages 0
2023-06-18 21:27:07.180 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  keep all the xlog segments, because current segno = 10, less than wal_keep_segments = 1024
2023-06-18 21:27:07.180 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  slotname: dn_6002, dummy: 0, restartlsn: 0/B756770
2023-06-18 21:27:07.186 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  CreateCheckPoint PrintCkpXctlControlFile: [checkPoint] oldCkpLoc:0/AF1ED48, oldRedo:0/AF1ECC8, newCkpLoc:0/B756770, newRedo:0/B756770, preCkpLoc:0/A6FF1F0
2023-06-18 21:27:07.186 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  will update control file (create checkpoint), shutdown:1
2023-06-18 21:27:07.186 [unknown] [unknown] localhost 47070854588160 0[0:0#0] 0 [INCRE_CKPT] LOG:  waiting all the pagewriter sub threads to exit
2023-06-18 21:27:07.186 [unknown] [unknown] localhost 47070837806848 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter thread shut down, id is 2
2023-06-18 21:27:07.186 [unknown] [unknown] localhost 47070871369472 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter thread shut down, id is 1
2023-06-18 21:27:07.187 [unknown] [unknown] localhost 47070765385472 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter thread shut down, id is 3
2023-06-18 21:27:07.189 [unknown] [unknown] localhost 47070821025536 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter thread shut down, id is 4
2023-06-18 21:27:07.189  [postmaster][reaper][47066107080384] WARNING: Did not found reaper thread id 47070837806848 in backend list, with 0 thread still alive,last thread role 0, may has leak occurs
2023-06-18 21:27:07.191  [postmaster][reaper][47066107080384] WARNING: Did not found reaper thread id 47070765385472 in backend list, with 0 thread still alive,last thread role 0, may has leak occurs
2023-06-18 21:27:07.191 [unknown] [unknown] localhost 47070854588160 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter thread shut down, id is 0
2023-06-18 21:27:07.192  [postmaster][reaper][47066107080384] WARNING: Did not found reaper thread id 47070821025536 in backend list, with 0 thread still alive,last thread role 0, may has leak occurs
2023-06-18 21:27:07.192 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  attempting to remove WAL segments older than log file 000000010000000000000000
2023-06-18 21:27:07.192 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  checkpoint complete: wrote 0 buffers (0.0%); 0 transaction log file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.335 s, total=0.419 s; sync files=0, longest=0.000 s, average=0.000 s
2023-06-18 21:27:07.192  [postmaster][reaper][47066107080384] WARNING: Did not found reaper thread id 47070871369472 in backend list, with 0 thread still alive,last thread role 0, may has leak occurs
2023-06-18 21:27:07.194  [postmaster][reaper][47066107080384] WARNING: Did not found reaper thread id 47070854588160 in backend list, with 0 thread still alive,last thread role 0, may has leak occurs
2023-06-18 21:27:07.194 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [DBL_WRT] LOG:  Double write exit
2023-06-18 21:27:07.194 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [DBL_WRT] LOG:  Double write exit
2023-06-18 21:27:07.195 [unknown] [unknown] localhost 47071471142656 0[0:0#0] 0 [BACKEND] LOG:  database system is shut down
2023-06-18 21:27:07.195  [postmaster][reaper][47066107080384] LOG: checkpoint thread exit and nowait for sharestorage
2023-06-18 21:27:07.195 omm [unknown] 192.168.31.61(51178) 47071487923968 0[0:0#0] 0 [BACKEND] LOG:  The WAL sender in primary is ready to do the switchover.
2023-06-18 21:27:07.195 omm [unknown] 192.168.31.61(51178) 47071487923968 0[0:0#0] 0 [BACKEND] LOG:  the latest WAL insert at 0/B756810
2023-06-18 21:27:07.195 omm [unknown] 192.168.31.61(51178) 47071487923968 0[0:0#0] 0 [BACKEND] LOG:  the latest WAL complete at 0/B756810
2023-06-18 21:27:07.195 omm [unknown] 192.168.31.61(51178) 47071487923968 0[0:0#0] 0 [BACKEND] LOG:  sending switchover response message.
2023-06-18 21:27:07.195 omm [unknown] 192.168.31.61(51178) 47071487923968 0[0:0#0] 0 [BACKEND] LOG:  The WAL sender in primary has done the switchover waiting for the standby's promotion.
2023-06-18 21:27:07.195 omm [unknown] 192.168.31.61(51178) 47071487923968 0[0:0#0] 0 [BACKEND] LOG:  standby ready_to_stop: walSndCaughtUp:1, pgpending:0, sentPtr:b756810, flust:b756810
2023-06-18 21:27:07.209 omm [unknown] 192.168.31.61(51178) 47071487923968 0[0:0#0] 0 [BACKEND] LOG:  synchronous master is now standalone
2023-06-18 21:27:07.209 omm [unknown] 192.168.31.61(51178) 47071487923968 0[0:0#0] 0 [BACKEND] LOG:  walsender thread shut down
2023-06-18 21:27:07.219 [unknown] [unknown] localhost 47070947378944 0[0:0#0] 0 [BACKEND] LOG:  auditor thread exit, id : 0
2023-06-18 21:27:07.220 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  All obsArch and obsBarrier exit.
2023-06-18 21:27:07.220 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  All obsArch and obsBarrier exit.
2023-06-18 21:27:07.288 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  Stop the heartbeat server.
2023-06-18 21:27:07.288 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  heartbeat thread shut down
2023-06-18 21:27:07.289 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  All obsArch and obsBarrier exit.
2023-06-18 21:27:07.289 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  All Audit threads exit.
2023-06-18 21:27:07.289 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  All obsArch and obsBarrier exit.
2023-06-18 21:27:07.289 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  all server processes terminated; reinitializing
2023-06-18 21:27:07.316 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  FiniNuma allocIndex: 0.
2023-06-18 21:27:07.316 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.
2023-06-18 21:27:07.316 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] WARNING:  Failed to initialize the memory protect for g_instance.attr.attr_storage.cstore_buffers (16 Mbytes) or shared memory (3487 Mbytes) is larger.
2023-06-18 21:27:07.380 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [CACHE] LOG:  set data cache  size(12582912)
2023-06-18 21:27:07.380 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [CACHE] LOG:  set metadata cache  size(4194304)
2023-06-18 21:27:07.418 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [SEGMENT_PAGE] LOG:  Segment-page constants: DF_MAP_SIZE: 8156, DF_MAP_BIT_CNT: 65248, DF_MAP_GROUP_EXTENTS: 4175872, IPBLOCK_SIZE: 8168, EXTENTS_PER_IPBLOCK: 1021, IPBLOCK_GROUP_SIZE: 4090, BMT_HEADER_LEVEL0_TOTAL_PAGES: 8323072, BktMapEntryNumberPerBlock: 2038, BktMapBlockNumber: 25, BktBitMaxMapCnt: 512
2023-06-18 21:27:07.420 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  archive recovery started
2023-06-18 21:27:07.422 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [mpfl_ulink_file]: unlink global/max_page_flush_lsn sucessfully! ret:4294967295
2023-06-18 21:27:07.422 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  StartupXLOG: biggest_lsn_in_page is set to FFFFFFFF/FFFFFFFF, enable_update_max_page_flush_lsn:0
2023-06-18 21:27:07.422 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  database system timeline: 8
2023-06-18 21:27:07.422 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  database system was shut down at 2023-06-18 21:27:07 CST
2023-06-18 21:27:07.422 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  entering standby mode
2023-06-18 21:27:07.423 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  Double Write init
2023-06-18 21:27:07.423 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  Found a valid batch meta file info: dw_file_num [1], dw_file_size [256] MB, dw_version [92568]
2023-06-18 21:27:07.424 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  Found a valid batch meta file info: dw_file_num [1], dw_file_size [256] MB, dw_version [92568]
2023-06-18 21:27:07.427 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  Found a valid batch file header: id 0, file_head[dwn 1, start 843]
2023-06-18 21:27:07.428 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  Found a valid single file header: id 0, file_head[dwn 41, start 0]
2023-06-18 21:27:07.429 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  Found a valid single file header: id 0, file_head[dwn 41, start 0]
2023-06-18 21:27:07.433 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  DW recovery state: "Empty", file start page[dwn 1, start 843], now access page 0, current [page_id 843, dwn 1, checksum verify res is 1, page_num orig 0, page_num fixed 0]
2023-06-18 21:27:07.433 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  DW recovery state: "Finish", file start page[dwn 1, start 843], now access page 0, current [page_id 843, dwn 1, checksum verify res is 1, page_num orig 0, page_num fixed 0]
2023-06-18 21:27:07.433 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  [single flush] recovery, [first version] dw page is new, break this recovery: buf_tag[rel 0/0/0 blk 0 fork 0], compress: 0
2023-06-18 21:27:07.433 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  [second version] DW single flush file valid item num is 0.
2023-06-18 21:27:07.434 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  DW single flush file recovery finish.
2023-06-18 21:27:07.434 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  DW single flush finish recovery, reset the file head[dwn 42, start 0].
2023-06-18 21:27:07.435 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [DBL_WRT] LOG:  DW single flush finish recovery [second version], reset the file head[dwn 42, start 0].
2023-06-18 21:27:07.463 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  redo record is at 0/B756770; shutdown TRUE
2023-06-18 21:27:07.464 [MOT] <TID:06044/00000> <SID:00002/00000> [INFO]     <GC>                 GC PARAMS: isGcEnabled = true, limboSizeLimit = 524288, limboSizeLimitHigh = 8388608, rcuFreeCount = 8192
2023-06-18 21:27:07.464 [MOT] <TID:06044/00000> <SID:00002/00000> [INFO]     <Recovery>           Starting MOT recovery
2023-06-18 21:27:07.464 [MOT] <TID:06044/00000> <SID:00002/00000> [INFO]     <FDW>                Registered current thread for proc-exit callback for thread 0x2acf94ba0700
2023-06-18 21:27:07.464 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  GTM-Free Mode: start local next csn from checkpoint 2408, next xid 20270
2023-06-18 21:27:07.464 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  Startup: write global oldestXidInUndo 0 from checkpoint 0
2023-06-18 21:27:07.464 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  startup csnlog without extend at xid:20269, pageno:19
2023-06-18 21:27:07.464 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  ===Not in the streaming DR switchover===
2023-06-18 21:27:07.464 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  StartupXLOG PrintCkpXctlControlFile: [checkPoint] oldCkpLoc:0/B756770, oldRedo:0/B756770, newCkpLoc:0/B756770, newRedo:0/B756770, preCkpLoc:0/AF1ED48
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  redo minRecoveryPoint at 0/B756770; backupStartPoint at 0/0; backupEndRequired FALSE
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  consistent recovery state reached at 0/B756810
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats: the basic statistic during redo are as follows : redo_start_ptr:00000000/0B756770, redo_start_time:740410027423013, min_recovery_point:00000000/0B756770, read_ptr:00000000/0B756770, last_replayed_read_Ptr:00000000/00000000, speed:0 KB/s
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_READ_XLOG: the event io statistic during redo are as follows : total_duration:6, counter:1
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_READ_DATA: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_WRITE_DATA: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_PROCESS_PENDING: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_APPLY: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_unlink_stats_file: unlink redo.state sucessfully!, ret:-1
2023-06-18 21:27:07.468 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  send signal to be hot standby at 0/B756810
2023-06-18 21:27:07.472 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  mogdb: fsync file "/opt/mogdb/data/gaussdb.state.temp" success
2023-06-18 21:27:07.472 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  update gaussdb state file: db state(NORMAL_STATE), server mode(Standby)
2023-06-18 21:27:07.472 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  database system is ready to accept read only connections
2023-06-18 21:27:07.473 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  sigusr1_handler create WalWriterAuxiliary(47070927914752) after local recovery is done.                 pmState:3, ServerMode:3
2023-06-18 21:27:07.473 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  audit_process_cxt_init enter
2023-06-18 21:27:07.473 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  audit_process_cxt_init pipe init successfully for pipe : 0 file descriptor: 33
2023-06-18 21:27:07.475 [unknown] [unknown] localhost 47070765385472 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter started, thread id is 0
2023-06-18 21:27:07.481 [unknown] [unknown] localhost 47070718789376 0[0:0#0] 0 [BACKEND] LOG:  invalidate buffer bgwriter started
2023-06-18 21:27:07.484 [unknown] [unknown] localhost 47070947378944 0[0:0#0] 0 [BACKEND] LOG:  checkpointer started, CheckPointTimeout is 60
2023-06-18 21:27:07.484 [unknown] [unknown] localhost 47070947378944 0[0:0#0] 0 [BACKEND] LOG:  synchronous master is now standalone
2023-06-18 21:27:07.486 [unknown] [unknown] localhost 47070854588160 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter started, thread id is 1
2023-06-18 21:27:07.489 [unknown] [unknown] localhost 47070837806848 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter started, thread id is 2
2023-06-18 21:27:07.489 [unknown] [unknown] localhost 47070821025536 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter started, thread id is 3
2023-06-18 21:27:07.489 [unknown] [unknown] localhost 47070871369472 0[0:0#0] 0 [INCRE_CKPT] LOG:  pagewriter started, thread id is 4
2023-06-18 21:27:07.496 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  pgaudit_indextbl_init_new success
2023-06-18 21:27:07.497 [unknown] [unknown] localhost 47070927914752 0[0:0#0] 0 [BACKEND] LOG:  walwriterauxiliary started
2023-06-18 21:27:07.502 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  auditor process 0 started, pid=47071058597632
2023-06-18 21:27:07.505 [unknown] [unknown] localhost 47071075378944 0[0:0#0] 0 [BACKEND] LOG:  heartbeat thread started
2023-06-18 21:27:08.473 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  XLogPageRead IsRecoveryDone is set true,ReadRecPtr:0/B756770, EndRecPtr:0/B756810
2023-06-18 21:27:08.473 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats: the basic statistic during redo are as follows : redo_start_ptr:00000000/0B756770, redo_start_time:740410027423013, min_recovery_point:00000000/0B756770, read_ptr:00000000/0B756770, last_replayed_read_Ptr:00000000/00000000, speed:0 KB/s
2023-06-18 21:27:08.473 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_READ_XLOG: the event io statistic during redo are as follows : total_duration:64, counter:11
2023-06-18 21:27:08.473 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_READ_DATA: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:08.473 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_WRITE_DATA: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:08.473 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_PROCESS_PENDING: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:08.473 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_APPLY: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:08.474 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  mogdb: fsync file "/opt/mogdb/data/gaussdb.state.temp" success
2023-06-18 21:27:08.474 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  set lsn after recovery done in gaussdb state file
2023-06-18 21:27:08.524 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  request xlog stream at 0/B756810.
2023-06-18 21:27:08.524 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  startup shut down walreceiver.
2023-06-18 21:27:08.524 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  wal receiver try to connect to host=192.168.31.61 port=26001 localhost=192.168.31.60 localport=26001 index 1 .
2023-06-18 21:27:08.526 [unknown] [unknown] localhost 47071108941568 0[0:0#0] 0 [BACKEND] LOG:  walreceiver thread started
2023-06-18 21:27:08.526 [unknown] [unknown] localhost 47071108941568 0[0:0#0] 0 [BACKEND] LOG:  Connecting to remote server :host=192.168.31.61 port=26001 localhost=192.168.31.60 localport=26001 dbname=replication replication=true fallback_application_name=dn_6001 connect_timeout=2
2023-06-18 21:27:08.527 [unknown] [unknown] localhost 47071092160256 0[0:0#0] 0 [BACKEND] LOG:  walrcvwriter thread started
2023-06-18 21:27:08.532 [unknown] [unknown] localhost 47071108941568 0[0:0#0] 0 [BACKEND] LOG:  Connected to remote server :host=192.168.31.61 port=26001 localhost=192.168.31.60 localport=26001 success.
2023-06-18 21:27:08.532 [unknown] [unknown] localhost 47071108941568 0[0:0#0] 0 [BACKEND] LOG:  remote term[1], local term[1]
2023-06-18 21:27:08.533 [unknown] [unknown] localhost 47071108941568 0[0:0#0] 0 [BACKEND] LOG:  local request lsn/crc [0/B756770, 3125139468]
WARNING:  replication slot "dn_6001" already exists
2023-06-18 21:27:08.539 [unknown] [unknown] localhost 47071108941568 0[0:0#0] 0 [BACKEND] LOG:  streaming replication successfully connected to primary, the connection is host=192.168.31.61 port=26001 localhost=192.168.31.60 localport=26001, start from 0/B000000 
2023-06-18 21:27:08.539 [unknown] [unknown] localhost 47071108941568 0[0:0#0] 0 [BACKEND] LOG:  start replication at start point 0/B000000
2023-06-18 21:27:08.539 [unknown] [unknown] localhost 47071108941568 0[0:0#0] 0 [BACKEND] LOG:  set knl_g_set_redo_finish_status to false when connecting to the primary
2023-06-18 21:27:08.540 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  mogdb: fsync file "/opt/mogdb/data/gaussdb.state.temp" success
2023-06-18 21:27:08.540 [unknown] [unknown] localhost 47066107080384 0[0:0#0] 0 [BACKEND] LOG:  update gaussdb state file: build reason(Normal), db state(Normal), server mode(Standby), current connect index(1)
2023-06-18 21:27:08.611 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  redo starts at 0/B756810
2023-06-18 21:27:08.611 [unknown] [unknown] localhost 47071041816320 0[0:0#0] 0 [BACKEND] LOG:  set knl_g_set_redo_finish_status to false when starting redo
2023-06-18 21:27:09.549 [unknown] [unknown] localhost 47071075378944 0[0:0#0] 0 [BACKEND] LOG:  Connected to heartbeat primary :host=192.168.31.61 port=26005 localhost=192.168.31.60 localport=26005 connect_timeout=2 success.
2023-06-18 21:27:09.549 [unknown] [unknown] localhost 47071075378944 0[0:0#0] 0 [BACKEND] LOG:  Add listen socket [fd=104] OK , evnets[1].
复制

如下为切换过程原备库输出日志

2023-06-18 21:27:06.785 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  to do switchover
2023-06-18 21:27:06.786 [unknown] [unknown] localhost 47440792389376 0[0:0#0] 0 [BACKEND] LOG:  send fast switchover request to primary
2023-06-18 21:27:06.788 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  mogdb: fsync file "/opt/mogdb/data/gaussdb.state.temp" success
2023-06-18 21:27:06.788 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  set gaussdb state file: db state(WAITING_STATE), server mode(Standby)
2023-06-18 21:27:07.241 [unknown] [unknown] localhost 47440792389376 0[0:0#0] 0 [BACKEND] LOG:  received switchover response message from primary
2023-06-18 21:27:07.241 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  received switchover notification
2023-06-18 21:27:07.241 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  startup shut down walreceiver.
2023-06-18 21:27:07.241 [unknown] [unknown] localhost 47440792389376 0[0:0#0] 0 [BACKEND] FATAL:  terminating walreceiver process due to administrator command
2023-06-18 21:27:07.241 [unknown] [unknown] localhost 47440792389376 0[0:0#0] 0 [BACKEND] LOG:  waiting walrcvwriter: 47440656992000 terminate
2023-06-18 21:27:07.241 [unknown] [unknown] localhost 47440656992000 0[0:0#0] 0 [BACKEND] LOG:  walrcvwriter thread shut down
2023-06-18 21:27:07.251 [unknown] [unknown] localhost 47440792389376 0[0:0#0] 0 [BACKEND] LOG:  set local_redo_finish_status to false in WalRcvDie
2023-06-18 21:27:07.254 [unknown] [unknown] localhost 47440792389376 0[0:0#0] 0 [BACKEND] LOG:  walreceiver thread shut down
2023-06-18 21:27:07.254 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  startup shut down datareceiver.
2023-06-18 21:27:07.255 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  mogdb: fsync file "/opt/mogdb/data/gaussdb.state.temp" success
2023-06-18 21:27:07.255 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  set gaussdb state file: db state(PROMOTING_STATE), server mode(Standby)
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  read record failed when promoting, current lsn (0/B756830), received lsn(0/B756810),sources[1], failedSources[3], readSource[2], readFile[-1], readId[0],readSeg[11], readOff[7692288], readLen[8192]
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  read xlog page failed at 0/B756810
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  set knl_g_set_redo_finish_status to true when redo done
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  redo done at 0/B756770, end at 0/B756810
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  [PR]: Recoverying elapsed: 28776743 us, redoTotalBytes:8616328,EndRecPtr:192243728, redoStartPtr:183627400,speed:0 MB/s, totalTime:28776743
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_unlink_stats_file: unlink redo.state sucessfully!, ret:-1
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats: the basic statistic during redo are as follows : redo_start_ptr:00000000/0AF1EE88, redo_start_time:740409998157668, min_recovery_point:00000000/0B756770, read_ptr:00000000/0B756770, last_replayed_read_Ptr:00000000/0B756810, speed:0 KB/s
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_READ_XLOG: the event io statistic during redo are as follows : total_duration:8881, counter:1553
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_READ_DATA: the event io statistic during redo are as follows : total_duration:2685, counter:230
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_WRITE_DATA: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_PROCESS_PENDING: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  [REDO_STATS]redo_dump_all_stats WAIT_APPLY: the event io statistic during redo are as follows : total_duration:0, counter:0
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  last completed transaction was at log time 2023-06-18 21:26:50.878158+08
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  startup shut down walreceiver.
2023-06-18 21:27:08.260 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  startup shut down datareceiver.
2023-06-18 21:27:08.263 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  archive recovery complete
2023-06-18 21:27:08.276 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  btree_xlog_cleanup is over, it takes time:0 microseconds
2023-06-18 21:27:08.276 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [REDO] LOG:  UBTreeXlogCleanup is over, it takes time:0 microseconds
2023-06-18 21:27:08.276 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] LOG:  CreateRestartPoint PrintCkpXctlControlFile: [checkPoint] oldCkpLoc:0/AF1EDE8, oldRedo:0/AF1EDE8, newCkpLoc:0/B756770, newRedo:0/B756770, preCkpLoc:0/AF1EDE8
2023-06-18 21:27:08.276 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] LOG:  restartpoint starting: immediate force
2023-06-18 21:27:08.276 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] LOG:  CreateRestartPoint, need flush 0 pages.
2023-06-18 21:27:08.280 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  redo done, nextXid: 20993, startupMaxXid: 20993, recentLocalXmin: 20270, recentGlobalXmin: 20270, PendingPreparedXacts: 0, NextCommitSeqNo: 2408, cutoff_csn_min: 0.
2023-06-18 21:27:08.281 [MOT] <TID:02981/00000> <SID:00001/00000> [INFO]     <Recovery>           MOT recovery completed
2023-06-18 21:27:08.281 [MOT] <TID:02981/-----> <SID:-----/-----> [WARNING]  <FDW>                Ignoring request to delete session context: already deleted
2023-06-18 21:27:08.281 [MOT] <TID:02981/-----> <SID:-----/-----> [WARNING]  <System>             Ignoring attempt to cleanup current thread with invalid thread identifier: 65535
2023-06-18 21:27:08.282  [postmaster][reaper][47435764051648] LOG: startupprocess exit
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  Archive slot change to active when DBstatus Promoting
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47440628090624 0[0:0#0] 0 [BACKEND] LOG:  Stop the heartbeat server.
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47440628090624 0[0:0#0] 0 [BACKEND] LOG:  Disconnect the heartbeat client.
2023-06-18 21:27:08.282 [unknown] [unknown] localhost 47440628090624 0[0:0#0] 0 [BACKEND] LOG:  heartbeat thread shut down
2023-06-18 21:27:08.290 [unknown] [unknown] localhost 47435764051648 0[0:0#0] 0 [BACKEND] LOG:  mogdb: fsync file "/opt/mogdb/data/gaussdb.state.temp" success
2023-06-18 21:27:08.290  [postmaster][reaper][47435764051648] LOG: update gaussdb state file: db state(NORMAL_STATE), server mode(Primary)
2023-06-18 21:27:08.290  [postmaster][reaper][47435764051648] LOG: database system is ready to accept connections
2023-06-18 21:27:08.294 [unknown] [unknown] localhost 47440792389376 0[0:0#0] 0 [BACKEND] LOG:  autovacuum launcher started
2023-06-18 21:27:08.302 [unknown] [unknown] localhost 47440941352704 0[0:0#0] 0 [BACKEND] LOG:  global stats collector started
2023-06-18 21:27:08.307 [unknown] [unknown] localhost 47440756676352 0[0:0#0] 0 [BACKEND] LOG:  walwriter started
2023-06-18 21:27:08.308 [unknown] [unknown] localhost 47441119741696 0[0:0#0] 0 [BACKEND] LOG:  snapshot thread is started
2023-06-18 21:27:08.308 omm postgres localhost 47441281353472 0[0:0#0] 0 [BACKEND] LOG:  statement flush thread start
2023-06-18 21:27:08.311 [unknown] [unknown] localhost 47440628090624 0[0:0#0] 0 [BACKEND] LOG:  heartbeat thread started
2023-06-18 21:27:08.312 omm postgres localhost 47441163847424 0[0:0#0] 0 [BACKEND] LOG:  ASP thread start
2023-06-18 21:27:08.314 omm postgres localhost(???) 47441460856576 0[0:0#0] 0 [BACKEND] LOG:  process wlm thread starting up.
2023-06-18 21:27:08.315 omm postgres localhost(???) 47441460856576 0[0:0#0] 0 [BACKEND] LOG:  build user data finished
2023-06-18 21:27:08.315 omm postgres localhost(???) 47441507063552 0[0:0#0] 0 [BACKEND] LOG:  WLMarbiter thread is starting up.
2023-06-18 21:27:08.316 [unknown] [unknown] localhost 47440809170688 0[0:0#0] 0 [BACKEND] LOG:  undo launcher started
2023-06-18 21:27:08.316 [unknown] [unknown] localhost 47440656992000 0[0:0#0] 0 [BACKEND] LOG:  job scheduler started
2023-06-18 21:27:08.316 omm postgres localhost(???) 47441490282240 0[0:0#0] 0 [BACKEND] LOG:  WLMmonitor thread is starting up.
2023-06-18 21:27:08.317 [unknown] [unknown] localhost 47441523844864 0[0:0#0] 0 [UNDO] LOG:  [UndoRecycleMain:482]undo recycle started.
2023-06-18 21:27:08.336 omm postgres localhost 47441119741696 0[0:0#0] 2251799813685558 [BACKEND] LOG:  Failed to snapshot global_memory_node_detail, cause: unsupported view for memory protection feature is disabled.
2023-06-18 21:27:08.379 omm postgres localhost 47441119741696 0[0:0#0] 2251799813685558 [BACKEND] LOG:  create snapshot tables succeed
2023-06-18 21:27:08.388 omm postgres localhost 47441119741696 0[0:0#0] 2251799813685558 [BACKEND] LOG:  WDR snapshot start
2023-06-18 21:27:08.480 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [DBL_WRT] LOG:  [batch flush] DW truncate end: file_head[dwn 1, start 1105], total_pages 0
2023-06-18 21:27:08.489 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] LOG:  keep all the xlog segments, because current segno = 11, less than wal_keep_segments = 1024
2023-06-18 21:27:08.489 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] LOG:  slotname: dn_6001, dummy: 0, restartlsn: 0/AF1EDE8
2023-06-18 21:27:08.489 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] LOG:  keep xlog segments after 1, current wal size 2199023254528(Bytes), curInsert 0, quorumMinRequired 183627240, minToolsRequired 0
2023-06-18 21:27:08.489 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] LOG:  attempting to remove WAL segments older than log file 000000010000000000000000
2023-06-18 21:27:08.489 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] LOG:  restartpoint complete: wrote 0 buffers (0.0%); 0 transaction log file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.201 s, total=0.212 s; sync files=0, longest=0.000 s, average=0.000 s
2023-06-18 21:27:08.489 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] LOG:  recovery restart point at 0/B756770
2023-06-18 21:27:08.489 [unknown] [unknown] localhost 47440739895040 0[0:0#0] 0 [BACKEND] DETAIL:  last completed transaction was at log time 2023-06-18 21:26:50.878158+08
2023-06-18 21:27:08.576 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  walsender thread started
2023-06-18 21:27:08.577 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  received wal replication command: IDENTIFY_VERSION
2023-06-18 21:27:08.578 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  received wal replication command: IDENTIFY_MODE
2023-06-18 21:27:08.578 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  received wal replication command: IDENTIFY_SYSTEM
2023-06-18 21:27:08.578 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  received wal replication command: IDENTIFY_CONSISTENCE 0/B756770
2023-06-18 21:27:08.583 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  remote request lsn/crc: [0/B756770, 3125139468] local max lsn/crc: [0/B8234C0, 2105028979]
2023-06-18 21:27:08.583 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  received wal replication command: IDENTIFY_CHANNEL 26001
2023-06-18 21:27:08.583 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  current repl of walsender is 1.
2023-06-18 21:27:08.584 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  received wal replication command: CREATE_REPLICATION_SLOT "dn_6001" PHYSICAL 0/B000000
2023-06-18 21:27:08.584 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] WARNING:  replication slot "dn_6001" already exists
2023-06-18 21:27:08.584 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  received wal replication command: START_REPLICATION SLOT "dn_6001" 0/B000000
2023-06-18 21:27:08.584 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  standalone synchronous master now have synchronous standby
2023-06-18 21:27:08.644 omm [unknown] 192.168.31.60(37704) 47441557407488 0[0:0#0] 0 [BACKEND] LOG:  standby "dn_6001" is now a synchronous standby with group and priority: 0 1
2023-06-18 21:27:09.594 [unknown] [unknown] localhost 47440628090624 0[0:0#0] 0 [BACKEND] LOG:  Accept new connection, socket [fd=195], evnets[1].
2023-06-18 21:27:09.615 [unknown] [unknown] localhost 47440628090624 0[0:0#0] 0 [BACKEND] LOG:  Adding connection successed, remote ip: 192.168.31.60, remote heartbeat port:26005.
2023-06-18 21:27:10.100 omm postgres localhost 47441119741696 0[0:0#0] 2251799813685558 [BACKEND] WARNING:  GUC parameter 'enable_instr_rt_percentile' is off
2023-06-18 21:27:10.100 omm postgres localhost 47441119741696 0[0:0#0] 2251799813685558 [BACKEND] CONTEXT:  PL/pgSQL function dbe_perf.get_statement_responsetime_percentile() line 11 at FOR over EXECUTE statement
        SQL statement "INSERT INTO snapshot.snap_statement_responsetime_percentile(snapshot_id, "snap_p80" , "snap_p95" ) select 118, "p80" , "p95"  from dbe_perf.statement_responsetime_percentile"
2023-06-18 21:27:10.207 omm postgres localhost 47441119741696 0[0:0#0] 2251799813685558 [BACKEND] LOG:  WDR snapshot end
2023-06-18 21:27:10.825 [unknown] [unknown] localhost 47441574188800 0[0:0#0] 0 [AUTOVAC] LOG:  report autovac startup on database 24610 to stats collector
2023-06-18 21:27:10.826 [unknown] [unknown] localhost 47441574188800 0[0:0#0] 0 [BACKEND] LOG:  start autovacuum on database "testdb3"
复制

switchover成功后,执行如下命令记录当前主备机器信息

[omm@mogdb02 ~]$ gs_om -t refreshconf                         
Generating dynamic configuration file for all nodes.
Successfully generated dynamic configuration file.
[omm@mogdb02 ~]$ 
复制

以上操作会动态更新下面配置文件,0为主,1为备

[root@mogdb01 ~]#  cat /opt/mogdb/app/bin/cluster_dnrole_config
mogdb01=1
mogdb02=0
[root@mogdb01 ~]#
复制

gs_om检查状态首字母缩写状态显示不变,因为P/S是OM的特殊保留安装时的角色

[omm@mogdb01 ~]$ gs_om -t status --detail
[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

    node   node_ip         port      instance                state
----------------------------------------------------------------------------------
1  mogdb01 192.168.31.60   26000      6001 /opt/mogdb/data   P Standby Normal
2  mogdb02 192.168.31.61   26000      6002 /opt/mogdb/data   S Primary Normal
[omm@mogdb01 ~]$ 

[omm@mogdb01 ~]$ ptkc status 
[   Cluster State   ]
cluster_name                            : mogdb_cluster1
cluster_state                           : Normal
database_version                        : MogDB 3.0.4 (build cc068866)

[  Datanode State   ]
   cluster_name  |  id  |      ip       | port  | user | nodename | db_role | state  | upstream  
-----------------+------+---------------+-------+------+----------+---------+--------+-----------
  mogdb_cluster1 | 6001 | 192.168.31.60 | 26000 | omm  | dn_6001  | standby | Normal | -         
                 | 6002 | 192.168.31.61 | 26000 | omm  | dn_6002  | primary | Normal | -         
[omm@mogdb01 ~]$ 
复制

ptk切换步骤

检查当前主备情况

[omm@mogdb01 ~]$ ptkc status             
[   Cluster State   ]
cluster_name                            : mogdb_cluster1
cluster_state                           : Normal
database_version                        : MogDB 3.0.4 (build cc068866)

[  Datanode State   ]
   cluster_name  |  id  |      ip       | port  | user | nodename | db_role | state  | upstream  
-----------------+------+---------------+-------+------+----------+---------+--------+-----------
  mogdb_cluster1 | 6001 | 192.168.31.60 | 26000 | omm  | dn_6001  | standby | Normal | -         
                 | 6002 | 192.168.31.61 | 26000 | omm  | dn_6002  | primary | Normal | -         
[omm@mogdb01 ~]$ 
复制

执行switchover

-H Specify the instance IP to switchover,指定备库IP

[omm@mogdb01 ~]$ ptkc switchover -H 192.168.31.60
INFO[2023-06-18T22:07:49.368] start switchover, please wait a few moments ... 
INFO[2023-06-18T22:07:54.417] switchover output:
[2023-06-18 22:07:49.379][16908][][gs_ctl]: gs_ctl switchover ,datadir is /opt/mogdb/data 
[2023-06-18 22:07:49.380][16908][][gs_ctl]: switchover term (1)
[2023-06-18 22:07:49.383][16908][][gs_ctl]: waiting for server to switchover........
[2023-06-18 22:07:54.416][16908][][gs_ctl]: done
[2023-06-18 22:07:54.416][16908][][gs_ctl]: switchover completed (/opt/mogdb/data) 
INFO[2023-06-18T22:07:54.417] switchover successfully                      
[omm@mogdb01 ~]$ 
复制

切换后状态检查

[omm@mogdb01 ~]$ ptkc status 
[   Cluster State   ]
cluster_name                            : mogdb_cluster1
cluster_state                           : Normal
database_version                        : MogDB 3.0.4 (build cc068866)

[  Datanode State   ]
   cluster_name  |  id  |      ip       | port  | user | nodename | db_role | state  | upstream  
-----------------+------+---------------+-------+------+----------+---------+--------+-----------
  mogdb_cluster1 | 6001 | 192.168.31.60 | 26000 | omm  | dn_6001  | primary | Normal | -         
                 | 6002 | 192.168.31.61 | 26000 | omm  | dn_6002  | standby | Normal | -         
[omm@mogdb01 ~]$ 
复制

总结

推荐使用PTK进行MogDB主备switchover。


订阅号:DongDB手记
墨天轮:https://www.modb.pro/u/231198

最后修改时间:2023-06-25 15:50:14
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
2人已赞赏
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论

暂无图片
获得了5次点赞
暂无图片
内容获得1次评论
暂无图片
获得了31次收藏
目录
  • 可选方案介绍
  • gs_ctl切换步骤
    • omm登录数据库任意节点,执行如下命令,查看主备情况
    • omm登录准备切换为主节点的备节点,执行如下命令
    • switchover成功后,执行如下命令记录当前主备机器信息
  • ptk切换步骤
    • 检查当前主备情况
    • 执行switchover
    • 切换后状态检查
  • 总结