Neste artigo, vamos explorar a conversão de um Standby para Snapshot Database, usando o utilitário Data DGMGRL (Data Broker).
Analisando condição atual do ambiente:
[oracle@fornix1 ~]$ dgmgrl sys/CORTEX
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Fri Jun 4 04:00:17 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 - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 61 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: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 0 seconds ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Average Apply Rate: 8.00 KByte/s
Real Time Query: OFF
Instance(s):
CORTEXDR
Database Status:
SUCCESS
Podemos parar o processo de Redo Apply no Standby:
[oracle@fornix2 ~]$ dgmgrl sys/CORTEXDR
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Fri Jun 4 04:05:34 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> EDIT DATABASE CORTEXDR SET STATE=APPLY-OFF;
Succeeded.
DGMGRL> SHOW DATABASE CORTEXDR;
Database - cortexdr
Role: PHYSICAL STANDBY
Intended State: APPLY-OFF
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 0 seconds (computed 1 second ago)
Average Apply Rate: (unknown)
Real Time Query: OFF
Instance(s):
CORTEXDR
Database Status:
SUCCESS
Como nosso banco Standby está em MOUNT, podemos disparar o comando de conversão para Snapshot:
DGMGRL> CONVERT DATABASE 'cortexdr' TO SNAPSHOT STANDBY;
Converting database "cortexdr" to a Snapshot Standby database, please wait...
Database "cortexdr" converted successfully
Validando nova condição do banco:
[oracle@fornix2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Jun 4 04:08:10 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> SELECT DATABASE_ROLE, OPEN_MODE, FLASHBACK_ON FROM V$DATABASE;
DATABASE_ROLE OPEN_MODE FLASHBACK_ON
---------------- -------------------- ------------------
SNAPSHOT STANDBY READ WRITE YES
Realizando operações de DDL e DML no Snapshot Database:
SQL> CREATE TABLE SOE.TESTE2 (DESCRICAO VARCHAR2(50));
Table created.
SQL> INSERT INTO SOE.TESTE2 (DESCRICAO) VALUES ('SNAP DATABASE');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT * FROM SOE.TESTE2;
DESCRICAO
--------------------------------------------------
SNAP DATABASE
Podemos observar que os Redos provenientes do Primary ainda são endereçados para o Standby, mas não são aplicados:
[oracle@fornix1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Jun 4 04:11:20 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> ALTER SYSTEM SWITCH LOGFILE ;
System altered.
SQL> SELECT THREAD#, MAX(SEQUENCE#) FROM V$LOG GROUP BY THREAD# ;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 77
[oracle@fornix2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Jun 4 04:11:57 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> SELECT PROCESS,STATUS,SEQUENCE# FROM V$MANAGED_STANDBY;
PROCESS STATUS SEQUENCE#
--------- ------------ ----------
DGRD ALLOCATED 0
ARCH CONNECTED 0
DGRD ALLOCATED 0
ARCH CONNECTED 0
ARCH CLOSING 75
ARCH CLOSING 76
DGRD ALLOCATED 0
RFS IDLE 0
RFS IDLE 77
RFS IDLE 0
10 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.