Tuesday, February 7, 2012

Step by step Switchover in 10g data guard / How to perform switcover in 10g Data Guard




Pri db_unique_name    =    'PRMY'
DG db_unique_name    =    'STBY'
Configuration(any name) =    'DG_STBY'
sys password        =    'sys'
Pri conn stg        =    'PRMY'

Please Ensure following parameters are set correctly on primary and standby
1. Ensure SPFILE is used
SQL> sho parameter spfile

2. Verify dmon process is running and broker parameters viz. DG_BROKER_START is set to TRUE and DG_BROKER_CONFIG_FILEn are set correctly
SQL> sho parameter broker
$ps -ef|grep dmon|grep -v grep

3. Check if LOCAL_LISTENER is set(This is needed only if you are non-default port other than 1521)
DGMGRL> show instance 'PRMYR' 'LocalListenerAddress';


4. Broker configuration is enabled and state of all members as intended is ONLINE
DGMGRL> show configuration

5. remote_login_passwordfile is set to 'EXCLUSIVE'
SQL> sho parameter remote_login_passwordfile

6. Verify PRMY and STBY tnspingable from both primary as well as standby and can connect to each other.

Now perform actual switchover now.



Broker config before switchover:
[oracle@linux2 dg_file]$ dgmgrl
DGMGRL for Linux: Version 10.2.0.4.0 - Production

Copyright (c) 2000, 2005, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/sys
Connected.
DGMGRL> show configuration

Configuration
  Name:                DG_PRMY
  Enabled:             YES
  Protection Mode:     MaxPerformance
  Fast-Start Failover: DISABLED
  Databases:
    PRMY - Primary database
    STBY - Physical standby database

Current status for "DG_PRMY":
SUCCESS



Switchover Now:
DGMGRL> switchover to 'STBY';
Performing switchover NOW, please wait...
Operation requires shutdown of instance "PRMY" on database "PRMY"
Shutting down instance "PRMY"...
ORA-01017: invalid username/password; logon denied

You are no longer connected to ORACLE
Please connect again.
Unable to shut down instance "PRMY"
You must shut down instance "PRMY" manually
Operation requires shutdown of instance "STBY" on database "STBY"
You must shut down instance "STBY" manually
Operation requires startup of instance "PRMY" on database "PRMY"
You must start instance "PRMY" manually
Operation requires startup of instance "STBY" on database "STBY"
You must start instance "STBY" manually
Switchover succeeded, new primary is "STBY"
DGMGRL>

DGMGRL> exit


Broker config post switchover:
DGMGRL>  show configuration;

Configuration
  Name:                DG_PRMY
  Enabled:             YES
  Protection Mode:     MaxPerformance
  Fast-Start Failover: DISABLED
  Databases:
    PRMY - Physical standby database
    STBY - Primary database

Current status for "DG_PRMY":
Warning: ORA-16607: one or more databases have failed


DGMGRL>


[oracle@linux1 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.4.0 - Production on Sat Feb 4 13:10:57 2012

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select open_mode, Database_role, DB_unique_name from v$database;

OPEN_MODE  DATABASE_ROLE    DB_UNIQUE_NAME
---------- ---------------- ------------------------------
MOUNTED    PHYSICAL STANDBY PRMY

SQL>


[oracle@linux2 ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.4.0 - Production on Sat Feb 4 13:11:32 2012

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select open_mode, Database_role, DB_unique_name from v$database;

OPEN_MODE  DATABASE_ROLE    DB_UNIQUE_NAME
---------- ---------------- ------------------------------
MOUNTED    PRIMARY          STBY

SQL>
SQL>
SQL> alter database open;

Database altered.

SQL>  select open_mode, Database_role, DB_unique_name from v$database;

OPEN_MODE  DATABASE_ROLE    DB_UNIQUE_NAME
---------- ---------------- ------------------------------
READ WRITE PRIMARY          STBY


SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /
/
/
System altered.

SQL>
System altered.

SQL>



SQL> select 'PRIMARY SEQ IS ' ||sequence# ||chr(10), 'PRIMARY FIRST_TIME IS ' || to_char(first_time,'mm/dd/yy hh24:mi:ss')
 from v$log_history
 where sequence#=(select max(sequence#) from v$log_history);  2    3

'PRIMARYSEQIS'||SEQUENCE#||CHR(10)
--------------------------------------------------------
'PRIMARYFIRST_TIMEIS'||TO_CHAR(FIRST_TI
---------------------------------------
PRIMARY SEQ IS 240
PRIMARY FIRST_TIME IS 02/04/12 13:08:38


SQL>




SQL> select 'STANDBY SEQ IS ' ||sequence# ||chr(10), 'STANDBY FIRST_TIME IS ' || to_char(first_time,'mm/dd/yy hh24:mi:ss')
 from v$log_history
 where sequence#=(select max(sequence#) from v$log_history);
  2    3
'STANDBYSEQIS'||SEQUENCE#||CHR(10)
--------------------------------------------------------
'STANDBYFIRST_TIMEIS'||TO_CHAR(FIRST_TI
---------------------------------------
STANDBY SEQ IS 240
STANDBY FIRST_TIME IS 02/04/12 13:08:38


SQL>
SQL>  alter database recover managed standby database disconnect from session;



Database altered.

SQL> SQL> SQL>
SQL>
SQL> select 'PRIMARY SEQ IS ' ||sequence# ||chr(10), 'PRIMARY FIRST_TIME IS ' || to_char(first_time,'mm/dd/yy hh24:mi:ss')
 from v$log_history
 where sequence#=(select max(sequence#) from v$log_history);  2    3

'PRIMARYSEQIS'||SEQUENCE#||CHR(10)
--------------------------------------------------------
'PRIMARYFIRST_TIMEIS'||TO_CHAR(FIRST_TI
---------------------------------------
PRIMARY SEQ IS 240
PRIMARY FIRST_TIME IS 02/04/12 13:08:38


SQL>





Note : Make sure to start the standby and new primary database manually and check their status also , using database_role from v$database on both new primary & standby

Reduce No of log_archive_max_processes on both primary and standby database so that DB shut down takes minimum time




No comments:

Post a Comment