miércoles, 1 de septiembre de 2021

How to change the dataguard role in a control file

In this article I will show you how to change the dataguard role in the controlfile for a database. We will start with a database in PRIMARY dataguard role, then I will change the dataguard role to PHYSICAL STANDBY and finally I will convert it back to PRIMARY.

Current dataguard role in the controlfile:

SQL> select database_role from v$database;

DATABASE_ROLE
----------------
PRIMARY

The first step in order to convert the dataguard role in the controlfile is making a backup of it.

Taking a backup of controlfile:

RMAN> backup current controlfile;


Checking if the control file backup was created successfully:


RMAN>list backup of controlfile;

List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5       Full    17.92M     DISK        00:00:01     01-SEP-21
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20210901T003645
        Piece Name: /u01/app/oracle/product/19.0.0/db_base/homes/OraDB21Home1/dbs/0517tc4t_5_1_1
  Control File Included: Ckp SCN: 2808105      Ckp time: 1-SEP-21

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6       Full    17.95M     DISK        00:00:00     01-SEP-21
        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20210901T003647
        Piece Name: /u01/app/oracle/product/19.0.0/db_base/homes/OraDB21Home1/dbs/c-1643369207-20210901-02
  Control File Included: Ckp SCN: 2808105      Ckp time: 01-SEP-21


Changing the dataguard role in the controlfile from PRIMARY to PHYSICAL STANDBY:


RMAN> shutdown immediate;

database dismounted
Oracle instance shut down

RMAN> startup nomount;

connected to target database (not started)
Oracle instance started

Total System Global Area    2885680056 bytes

Fixed Size                     9690040 bytes
Variable Size                637534208 bytes
Database Buffers            2231369728 bytes
Redo Buffers                   7086080 bytes


RMAN>  RESTORE STANDBY CONTROLFILE FROM '0517tc4t_5_1_1';

Starting restore at 01-SEP-21
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/ORCL/control01.ctl
output file name=/u01/app/oracle/oradata/ORCL/control02.ctl
Finished restore at 01-SEP-21

RMAN> alter database mount;

released channel: ORA_DISK_1
Statement processed

RMAN> select database_role from v$database;

DATABASE_ROLE
----------------
PHYSICAL STANDBY

RMAN>



Changing the dataguard role in the controlfile from PHYSICAL STANDBY to PRIMARY:

RMAN> shutdown immediate;

database dismounted
Oracle instance shut down

RMAN> startup nomount;

connected to target database (not started)
Oracle instance started

Total System Global Area    2885680056 bytes

Fixed Size                     9690040 bytes
Variable Size                637534208 bytes
Database Buffers            2231369728 bytes
Redo Buffers                   7086080 bytes

RMAN>  RESTORE PRIMARY CONTROLFILE  FROM '0517tc4t_5_1_1';

Starting restore at 01-SEP-21
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/ORCL/control01.ctl
output file name=/u01/app/oracle/oradata/ORCL/control02.ctl
Finished restore at 01-SEP-21

RMAN> alter database mount;

released channel: ORA_DISK_1
Statement processed

RMAN>  select database_role from v$database;

DATABASE_ROLE
----------------
PRIMARY

RMAN>

No hay comentarios:

Publicar un comentario

Oracle ACE Director Award - Deiby Gómez

Thanks #OracleACE Program for this awesome certificate recognizing the work I have done in the community for the last year. Looking forwa...