Wednesday, November 20, 2013

Configuring Active Data Guard (ADG) using Oracle Database 12c (With Container Database and Pluggable Databases) - Part-3


Switchover and Switchback using DGMGRL utility

1. Login to the Primary Database (cdb)

[oracle@dbnode]$ export ORACLE_SID=cdb
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ dgmgrl
DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production
Copyright (c) 2000, 2012, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> show database cdb;

Database - cdb

  Role:              PRIMARY
  Intended State:    TRANSPORT-ON
  Instance(s):
    cdb

  Database Error(s):
    ORA-16820: fast-start failover observer is no longer observing this database

Database Status:
ERROR

2. Start 'Observer' (from separate terminal) and check the status of 'Database'
DGMGRL> show database cdb;

Database - cdb

  Role:              PRIMARY
  Intended State:    TRANSPORT-ON
  Instance(s):
    cdb

Database Status:
SUCCESS

DGMGRL> show database cdbstby;

Database - cdbstby

  Role:              PHYSICAL STANDBY
  Intended State:    APPLY-ON
  Transport Lag:     0 seconds (computed 0 seconds ago)
  Apply Lag:         0 seconds (computed 0 seconds ago)
  Apply Rate:        0 Byte/s
  Real Time Query:   OFF
  Instance(s):
    cdbstby

Database Status:
SUCCESS

DGMGRL> show configuration;

Configuration - DGCONFIG

  Protection Mode: MaxPerformance
  Databases:
  cdb     - Primary database
    cdbstby - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status:
SUCCESS

3. Switchover to Physical Standby Database (cdbstby)
DGMGRL> switchover to cdbstby;
Performing switchover NOW, please wait...
Operation requires a connection to instance "cdbstby" on database "cdbstby"
Connecting to instance "cdbstby"...
Connected as SYSDBA.
New primary database "cdbstby" is opening...
Operation requires startup of instance "cdb" on database "cdb"
Starting instance "cdb"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "cdbstby"

DGMGRL> exit

4. Login to the New Physical Standby Database (cdb)
[oracle@dbnode]$ export ORACLE_SID=cdb
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ sqlplus /nolog

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 21:29:59 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> connect sys/oracle as sysdba
Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1386283008 bytes
Fixed Size                  2288248 bytes
Variable Size             469763464 bytes
Database Buffers          905969664 bytes
Redo Buffers                8261632 bytes
Database mounted.

SQL> alter database recover managed standby database cancel;
Database altered.

SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     47
Next log sequence to archive   0
Current log sequence           47
SQL>

4. Login to the New Primary Database (cdbstby)
[oracle@dbnode]$ export ORACLE_SID=cdbstby
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ sqlplus /nolog

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 18 21:30:25 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> connect sys/oracle@192.168.56.111:1521/cdbstby as sysdba
Connected.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     44
Next log sequence to archive   46
Current log sequence           46

5. Login to the DGMGRL for Switchback to Old Primary Database (cdb)
[oracle@dbnode]$ export ORACLE_SID=cdbstby
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ dgmgrl

DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production
Copyright (c) 2000, 2012, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> show database cdbstby;

Database - cdbstby

  Role:              PRIMARY
  Intended State:    TRANSPORT-ON
  Instance(s):
    cdbstby

Database Status:
SUCCESS

DGMGRL> show database cdb;

Database - cdb

  Role:              PHYSICAL STANDBY
  Intended State:    APPLY-ON
  Transport Lag:     0 seconds (computed 1 second ago)
  Apply Lag:         0 seconds (computed 1 second ago)
  Apply Rate:        0 Byte/s
  Real Time Query:   OFF
  Instance(s):
    cdb

Database Status:
SUCCESS

6. Login to the DGMGRL for Switchback to Old Primary Database (cdb)
DGMGRL> switchover to cdb;
Performing switchover NOW, please wait...
Operation requires a connection to instance "cdb" on database "cdb"
Connecting to instance "cdb"...
Connected as SYSDBA.
New primary database "cdb" is opening...
Operation requires startup of instance "cdbstby" on database "cdbstby"
Starting instance "cdbstby"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "cdb"
DGMGRL> exit

7. Check the status of Primary Database (cdb)
[oracle@dbnode]$ export ORACLE_SID=cdb
[oracle@dbnode]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome
[oracle@dbnode]$ dgmgrl
DGMGRL for Linux: Version 12.1.0.1.0 - 64bit Production
Copyright (c) 2000, 2012, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle
Connected as SYSDG.

DGMGRL> show database cdb;

Database - cdb

  Role:              PRIMARY
  Intended State:    TRANSPORT-ON
  Instance(s):
    cdb

Database Status:
SUCCESS

DGMGRL> show database cdbstby

Database - cdbstby

  Role:              PHYSICAL STANDBY
  Intended State:    APPLY-ON
  Transport Lag:     0 seconds (computed 0 seconds ago)
  Apply Lag:         0 seconds (computed 0 seconds ago)
  Apply Rate:        0 Byte/s
  Real Time Query:   OFF
  Instance(s):
    cdbstby

Database Status:
SUCCESS

DGMGRL>

No comments:

Post a Comment