19c DataGuard的switchover

RDBMS 19.19
主备库信息:
原主库: TEST
原备库: TESTDG
切换后
主库:  TESTDG
备库:  TEST

切换步骤:
1 在原主库上执行verify,以确认是否可以切换
2 在原主库上执行切换
3 打开新的主库,使用命令alter database open;
4 打开新的备库,使用命令startup mount,或startup
5 应用MRP


-- 原主库上执行,确认是否可以进行切换

ALTER DATABASE SWITCHOVER TO TESTDG VERIFY;


SYS@test SQL> ALTER DATABASE SWITCHOVER TO TESTDG VERIFY;

Database altered.

SYS@test SQL>

主库 alert log

2023-06-15T03:08:20.292153-04:00
ALTER DATABASE SWITCHOVER TO TESTDG VERIFY
2023-06-15T03:08:20.631191-04:00
SWITCHOVER VERIFY: Send VERIFY request to switchover target TESTDG
SWITCHOVER VERIFY COMPLETE: READY FOR SWITCHOVER
Completed: ALTER DATABASE SWITCHOVER TO TESTDG VERIFY

备库alert log

2023-06-15T03:08:20.578828-04:00
 rfs (PID:22215): krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is Foreground (PID:2114)
2023-06-15T03:08:20.676892-04:00
SWITCHOVER VERIFY BEGIN
SWITCHOVER VERIFY COMPLETE

-- 在原主库上执行切换

ALTER DATABASE SWITCHOVER TO TESTDG;

SYS@test SQL> ALTER DATABASE SWITCHOVER TO TESTDG;

Database altered.

SYS@test SQL>

主库 alert log

2023-06-15T03:12:34.987110-04:00
ALTER DATABASE SWITCHOVER TO TESTDG
2023-06-15T03:12:34.987170-04:00
NET  (PID:2114): The Time Management Interface (TMI) is being enabled for role transition
NET  (PID:2114): information.  This will result in messages beingoutput to the alert log
NET  (PID:2114): file with the prefix 'TMI: '.  This is being enabled to make the timing of
NET  (PID:2114): the various stages of the role transition available for diagnostic purposes.
NET  (PID:2114): This output will end when the role transition is complete.
TMI: dbsdrv switchover to target BEGIN 2023-06-15 03:12:34.987863
NET  (PID:2114): Starting switchover [Process ID: 2114]
TMI: kcv_switchover_to_target convert to physical BEGIN 2023-06-15 03:12:35.278549
2023-06-15T03:12:35.279329-04:00
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY [Process Id: 2114] (test)
NET  (PID:2114): Waiting for target standby to receive all redo
2023-06-15T03:12:35.281752-04:00
NET  (PID:2114): Waiting for all non-current ORLs to be archived
2023-06-15T03:12:35.281848-04:00
NET  (PID:2114): All non-current ORLs have been archived
2023-06-15T03:12:35.281901-04:00
NET  (PID:2114): Waiting for all FAL entries to be archived
2023-06-15T03:12:35.287741-04:00
NET  (PID:2114): All FAL entries have been archived
2023-06-15T03:12:35.287912-04:00
NET  (PID:2114): Waiting for LAD:2 to become synchronized
2023-06-15T03:12:36.289708-04:00
NET  (PID:2114): Active, synchronized Physical Standby switchover target has been identified
NET  (PID:2114): Preventing updates and queries at the Primary
NET  (PID:2114): Generating and shipping final logs to target standby
Switchover End-Of-Redo Log thread 1 sequence 34 has been fixed
Switchover: Primary highest seen SCN set to 0x00000000002cd9fa
NET  (PID:2114): Noswitch archival of T-1.S-34
NET  (PID:2114): End-Of-Redo Branch archival of T-1.S-34
NET  (PID:2114): LGWR is scheduled to archive to LAD:2 after log switch
NET  (PID:2114): Archiving is disabled due to current logfile archival
Primary will check for some target standby to have received all redo
NET  (PID:2114): Waiting for target standby to apply all redo
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/test/test/trace/test_ora_2114.trc
NET  (PID:2114): Converting the primary database to a new standby database
Clearing standby activation ID 2437135807 (0x9143bdbf)
The primary database controlfile was created using the
'MAXLOGFILES 16' clause.
There is space for up to 13 standby redo logfiles
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 209715200;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 209715200;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 209715200;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 209715200;
Archivelog for thread 1 sequence 34 required for standby recovery
Offline data file 5 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 6 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 8 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 9 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 10 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 11 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 12 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Switchover: Primary controlfile converted to standby controlfile succesfully.
Switchover: Complete - Database shutdown required
TMI: kcv_switchover_to_target convert to physical END 2023-06-15 03:12:36.646971
NET  (PID:2114): Sending request(convert to primary database) to switchover target TESTDG
2023-06-15T03:12:48.058852-04:00
NET  (PID:2114): Switchover complete. Database shutdown required
USER (ospid: 2114): terminating the instance
2023-06-15T03:12:49.340490-04:00
Instance terminated by USER, pid = 2114
TMI: dbsdrv switchover to target END 2023-06-15 03:12:49.340837
Completed: ALTER DATABASE SWITCHOVER TO TESTDG
Shutting down ORACLE instance (abort) (OS id: 2114)
Shutdown is initiated by sqlplus@19cdg01 (TNS V1-V3).
License high water mark = 16
2023-06-15T03:12:49.511157-04:00
Instance shutdown complete (OS id: 2114)

备库alert log

2023-06-15T03:12:35.224756-04:00
 rfs (PID:22433): krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is Foreground (PID:2114)
2023-06-15T03:12:35.349129-04:00
 rfs (PID:22438): krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is Foreground (PID:2116)
2023-06-15T03:12:36.399068-04:00
 rfs (PID:22441): krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is Foreground (PID:2114)
2023-06-15T03:12:36.428560-04:00
 rfs (PID:22441): Selected LNO:11 for T-1.S-34 dbid 2437152191 branch 1139005762
2023-06-15T03:12:36.497243-04:00
MRP0 (PID:2157): Resetting standby activation ID 2437135807 (0x9143bdbf)
2023-06-15T03:12:36.521378-04:00
Media Recovery End-Of-Redo indicator encountered
2023-06-15T03:12:36.521471-04:00
Media Recovery Continuing
MRP0 (PID:2157): Media Recovery Waiting for T-1.S-35
2023-06-15T03:12:36.766046-04:00
.... (PID:22445): The Time Management Interface (TMI) is being enabled for role transition
.... (PID:22445): information.  This will result in messages beingoutput to the alert log
.... (PID:22445): file with the prefix 'TMI: '.  This is being enabled to make the timing of
.... (PID:22445): the various stages of the role transition available for diagnostic purposes.
.... (PID:22445): This output will end when the role transition is complete.
SWITCHOVER: received request 'ALTER DATABASE COMMIT TO SWITCHOVER  TO PRIMARY' from primary database.
2023-06-15T03:12:36.768667-04:00
ALTER DATABASE SWITCHOVER TO PRIMARY (testdg)
Maximum wait for role transition is 15 minutes.
TMI: kcv_commit_to_so_to_primary wait for MRP to finish BEGIN 2023-06-15 03:12:36.777231
Switchover: Media recovery is still active
 rmi (PID:22445): Role Change: Canceling MRP - no more redo to apply
2023-06-15T03:12:36.786266-04:00
MRP0 (PID:2157): MRP0: Background Media Recovery cancelled with status 16037
2023-06-15T03:12:36.787866-04:00
Errors in file /u01/app/oracle/diag/rdbms/testdg/testdg/trace/testdg_mrp0_2157.trc:
ORA-16037: user requested cancel of managed recovery operation
MRP0 (PID:2157): Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Stopping change tracking
2023-06-15T03:12:36.909937-04:00
Errors in file /u01/app/oracle/diag/rdbms/testdg/testdg/trace/testdg_mrp0_2157.trc:
ORA-16037: user requested cancel of managed recovery operation
2023-06-15T03:12:36.910026-04:00
Background Media Recovery process shutdown (testdg)
2023-06-15T03:12:36.961492-04:00
 rmi (PID:22445): Role Change: Canceled MRP
TMI: kcv_commit_to_so_to_primary wait for MRP to finish END 2023-06-15 03:12:36.961573
TMI: kcv_commit_to_so_to_primary Switchover from physical BEGIN 2023-06-15 03:12:36.961674
 rmi (PID:22445): Killing 2 processes (PIDS:22438,2137) (all RFS) in order to disallow current and future RFS connections. Requested by OS process 22445
2023-06-15T03:12:36.964131-04:00
Process termination requested for pid 22438 [source = rdbms], [info = 2] [request issued by pid: 22445, uid: 54321]
2023-06-15T03:12:36.965919-04:00
Process termination requested for pid 2137 [source = rdbms], [info = 2] [request issued by pid: 22445, uid: 54321]
2023-06-15T03:12:37.127957-04:00
ARC1 (PID:2097): Archived Log entry 26 added for T-1.S-34 ID 0x9143bdbf LAD:1
2023-06-15T03:12:38.046750-04:00
Stopping background process MMNL
Stopping background process MMON
2023-06-15T03:12:38.199946-04:00
Stopping Emon pool
alter pluggable database all close immediate
Completed: alter pluggable database all close immediate
PDB$SEED(2):Pluggable database PDB$SEED closing
PDB$SEED(2):JIT: pid 22445 requesting stop
2023-06-15T03:12:43.502503-04:00
PDB$SEED(2):Buffer Cache flush deferred for PDB 2
Dispatchers and shared servers shutdown
CLOSE: killing server sessions.
2023-06-15T03:12:43.676322-04:00
Process termination requested for pid 2096 [source = rdbms], [info = 2] [request issued by pid: 22445, uid: 54321]
2023-06-15T03:12:43.677436-04:00
Process termination requested for pid 2026 [source = rdbms], [info = 2] [request issued by pid: 22445, uid: 54321]
2023-06-15T03:12:43.700422-04:00
Active process 2096 user 'oracle' program 'oracle@19cdg02 (TNS V1-V3)', waiting for 'SQL*Net message from client'

Active process 2096 user 'oracle' program 'oracle@19cdg02 (TNS V1-V3)', waiting for 'SQL*Net message from client'

2023-06-15T03:12:46.759192-04:00
CLOSE: all sessions shutdown successfully.
alter pluggable database all close immediate
Completed: alter pluggable database all close immediate
2023-06-15T03:12:47.765233-04:00

IM on ADG: Start of Empty Journal

IM on ADG: End of Empty Journal
Stopping Emon pool
Entire Buffer Cache invalidation started
Entire Buffer Cache invalidation completed
2023-06-15T03:12:47.917033-04:00
Restarting dead background process SVCB
Starting background process SVCB
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/testdg/testdg/trace/testdg_rmi_22445.trc
SwitchOver after complete recovery through change 2939386
 rmi (PID:22445): ORL pre-clearing operation disabled by switchover
Online log /u01/app/oracle/oradata/TESTDG/redo01.log: Thread 1 Group 1 was previously cleared
Online log /u01/app/oracle/oradata/TESTDG/redo02.log: Thread 1 Group 2 was previously cleared
Online log /u01/app/oracle/oradata/TESTDG/redo03.log: Thread 1 Group 3 was previously cleared
2023-06-15T03:12:47.993638-04:00
SVCB started with pid=15, OS id=22457
Standby became primary SCN: 2939384
 rmi (PID:22445): RT: Role transition work is not done
 rmi (PID:22445): The Time Management Interface (TMI) is being enabled for role transition
 rmi (PID:22445): information.  This will result in messages beingoutput to the alert log
 rmi (PID:22445): file with the prefix 'TMI: '.  This is being enabled to make the timing of
 rmi (PID:22445): the various stages of the role transition available for diagnostic purposes.
 rmi (PID:22445): This output will end when the role transition is complete.
 rmi (PID:22445): Redo network throttle feature is disabled at mount time
KZAUDIT: AUDIT_TRAIL initialization parameter is changed back to its original value as specified in the parameter file.
2023-06-15T03:12:48.055475-04:00
 rmi (PID:22445): Database role cleared from PHYSICAL STANDBY [kcvs.c:1114]
Switchover: Complete - Database mounted as primary
TMI: kcv_commit_to_so_to_primary Switchover from physical END 2023-06-15 03:12:48.056444
SWITCHOVER: completed request from primary database.
2023-06-15T03:12:54.239084-04:00
ARC0 (PID:2090): Becoming the 'no SRL' ARCH

-- 打开新的主库

ALTER DATABASE OPEN;

SYS@testdg SQL> conn / as sysdba
ERROR:
ORA-03113: end-of-file on communication channel
Process ID: 0
Session ID: 32 Serial number: 3745


Connected.
SYS@testdg SQL> ALTER DATABASE OPEN;

Database altered.

SYS@testdg SQL>

-- 打开新的备库

STARTUP;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

SYS@test SQL> STARTUP;
ORACLE instance started.

Total System Global Area 1241510056 bytes
Fixed Size                  9162920 bytes
Variable Size            1073741824 bytes
Database Buffers          150994944 bytes
Redo Buffers                7610368 bytes
Database mounted.
Database opened.
SYS@test SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Database altered.

SYS@test SQL>

-- 切换后的主备库信息

SYS@testdg SQL> select open_mode ,database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ WRITE           PRIMARY

SYS@testdg SQL>


SYS@test SQL> select open_mode ,database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ ONLY WITH APPLY PHYSICAL STANDBY

SYS@test SQL>

END

你可能感兴趣的:(Data,Guard,数据库,sqlserver)