A conversão em questão é extremamente simples, uma vez que todos os Redos enviados pelo primary estejam já no ambiente Standby. Assim, durante o processo, o GRP será usado e os Redos, aplicados.
Validando ambientes que serão usados neste artigo:
[oracle@fornix1 ~]$ dgmgrl sys/CORTEX
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Fri Jun 4 04:20:57 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "cortex"
Connected as SYSDBA.
DGMGRL> SHOW CONFIGURATION;
Configuration - cortex
Protection Mode: MaxPerformance
Members:
cortex - Primary database
cortexdr - Snapshot standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 60 seconds ago)
DGMGRL> SHOW DATABASE CORTEX;
Database - cortex
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
cortex
Database Status:
SUCCESS
DGMGRL> SHOW DATABASE CORTEXDR;
Database - cortexdr
Role: SNAPSHOT STANDBY
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 15 minutes 39 seconds (computed 1 second ago)
Instance(s):
CORTEXDR
Database Status:
SUCCESS
Montando o Snapshot Database:
[oracle@fornix2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Jun 4 04:22:27 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> SHU IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP MOUNT;
ORACLE instance started.
Total System Global Area 2583690520 bytes
Fixed Size 8899864 bytes
Variable Size 553648128 bytes
Database Buffers 2013265920 bytes
Redo Buffers 7876608 bytes
Database mounted.
Emitindo comando para a conversão:
[oracle@fornix2 ~]$ dgmgrl sys/oracle@CORTEXDR as sysdba
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Fri Jun 4 04:25:39 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "cortexDR"
Connected as SYSDBA.
DGMGRL> CONVERT DATABASE 'cortexDR' TO PHYSICAL STANDBY;
Converting database "cortexDR" to a Physical Standby database, please wait...
Operation requires a connection to database "cortex"
Connecting ...
Connected to "cortex"
Connected as SYSDBA.
Database "cortexDR" converted successfully
O alert nos reporta informações interessantes sobre o processo em si:
2021-06-04 04:25:54.706000 -03:00
alter database convert to physical standby
ALTER DATABASE CONVERT TO PHYSICAL STANDBY (CORTEXDR)
RSM0 (PID:5835): Killing 2 processes (PIDS:5766,5770) (all RFS) in order to disallow current and future RFS connections. Requested by OS process 5835
Process termination requested for pid 5766 [source = rdbms], [info = 2] [request issued by pid: 5835, uid: 54321]
Process termination requested for pid 5770 [source = rdbms], [info = 2] [request issued by pid: 5835, uid: 54321]
2021-06-04 04:25:57.083000 -03:00
Flashback Restore Start
2021-06-04 04:25:58.266000 -03:00
Flashback Restore Complete
Drop guaranteed restore point
Guaranteed restore point dropped
RSM0 (PID:5835): Database role cleared from SNAPSHOT STANDBY [kcvs.c:8837]
Clearing standby activation ID 584229166 (0x22d2a12e)
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;
RSM0 (PID:5835): Database role changed from PRIMARY to PHYSICAL STANDBY [kcvs.c:8842]
RSM0 (PID:5835): Waiting for all non-current ORLs to be archived
RSM0 (PID:5835): All non-current ORLs have been archived
RSM0 (PID:5835): Clearing online redo logfile 1 +DG_FRA/CORTEXDR/ONLINELOG/group_1.261.1066479861
RSM0 (PID:5835): Clearing online redo logfile 2 +DG_FRA/CORTEXDR/ONLINELOG/group_2.262.1066479871
Clearing online log 1 of thread 1 sequence number 1
Clearing online log 2 of thread 1 sequence number 2
2021-06-04 04:26:18.290000 -03:00
RSM0 (PID:5835): Clearing online redo logfile 1 complete
RSM0 (PID:5835): Clearing online redo logfile 2 complete
RSM0 (PID:5835): RT: Role transition work is not done
RSM0 (PID:5835): Redo network throttle feature is disabled at mount time
Physical Standby Database mounted.
In-memory operation on ADG is currently only supported on Engineered systems and PaaS.
inmemory_adg_enabled is turned off automatically.
Please contact our support team for EXADATA solutions
CONVERT TO PHYSICAL STANDBY: Complete - Database mounted as physical standby
Completed: alter database convert to physical standby
Validação condição do ambiente:
DGMGRL> SHOW CONFIGURATION;
Configuration - cortex
Protection Mode: MaxPerformance
Members:
cortex - Primary database
cortexdr - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 60 seconds ago)
No primary, gerando um novo Redo e checando a sua sequence:
SQL> SELECT DB_UNIQUE_NAME,DATABASE_ROLE,OPEN_MODE FROM V$DATABASE;
DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE
------------------------------ ---------------- --------------------
cortex PRIMARY READ WRITE
SQL> ALTER SYSTEM SWITCH LOGFILE ;
System altered.
SQL> SELECT THREAD#, MAX(SEQUENCE#) FROM V$LOG GROUP BY THREAD# ;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 80
No standby, já é possível ver o reflexo da conversão:
SQL> SELECT PROCESS,STATUS,SEQUENCE# FROM V$MANAGED_STANDBY;
PROCESS STATUS SEQUENCE#
--------- ------------ ----------
ARCH CLOSING 78
DGRD ALLOCATED 0
DGRD ALLOCATED 0
ARCH CLOSING 77
ARCH CONNECTED 0
ARCH CLOSING 79
MRP0 APPLYING_LOG 80
RFS IDLE 0
RFS IDLE 80
9 rows selected.
Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laboratório pessoal para fins de aprendizado.