Oracle 11g DataGuard Unfolded
This blog is not for only explaining the way you configure the oracle 11g dataguard (there are many great blogs for that with all the possible ways whether its user managed, rman, rman duplicate) my focus is on the issues we get during the dataguard configuration/ broker setup/ auto switchover process, why do we get those issues? How to resolve them?
Primary Database Name : dg1
Standby Database Name : dg1
Primary DB unique Name: dg1_a
Standby DB unique Name: dg1_b
Lets quickly change some of the DB parameter which are required for the data guard setup. (DataGuard setup involves very few steps for the basic configuration unlike RAC and I find DG more interesting, if u ask me why I don't deny the fact that its easy ;-) )
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(dg1_a,dg1_b)' scope=spfile;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=dg1_b NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg1_b';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' SCOPE=SPFILE;
ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=30;
ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=SPFILE;
ALTER SYSTEM SET FAL_SERVER=dg1_b;
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;
ALTER SYSTEM SET DB_FILE_NAME_CONVERT='dg1_b','dg1_a' scope=spfile;
ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='dg1_b','dg1_a' scope=spfile;
ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=SPFILE;
ALTER SYSTEM SET FAL_SERVER=dg1_b;
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;
ALTER SYSTEM SET DB_FILE_NAME_CONVERT='dg1_b','dg1_a' scope=spfile;
ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='dg1_b','dg1_a' scope=spfile;
Tnsnames for primary (standby same)
dg1_a =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.27.152.123)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dg1)
)
)
dg1_b =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.27.154.139)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dg1)
)
)
Listener.ora for Primary server (standby only hostname and global_dbname will differ)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /opt/app/oracle/11.2.0.2/A13db)
(SERVICE_NAME=dg1.domain.com)
(global_dbname = dg1_a_DGMGRL.domain.com)
(SID_NAME = dg1)
)
(SID_DESC =
(SID_NAME = dg1)
(ORACLE_HOME = /opt/app/oracle/11.2.0.2/A13db)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1.domain.com)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
## note global_dbname is set as db_unique_name_DGMGRL.domain.com and this is mandatory for the dataguard broker to work (required for the automatic switchover)
rman target sys/system@dg1_a AUXILIARY sys/system@dg1_b
Recovery Manager: Release 11.2.0.2.0 - Production on Tue Sep 11 03:53:43 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: DG1 (DBID=1774279666)
connected to auxiliary database: DG1 (not mounted)
RMAN> DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER
SPFILE
SET db_unique_name='dg1_b' COMMENT 'Is standby'
SET LOG_ARCHIVE_DEST_2='SERVICE=dg1_a ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg1_a'
SET FAL_SERVER='dg1_a' COMMENT 'Is primary'
NOFILENAMECHECK;2> 3> 4> 5> 6> 7> 8> 9>
Starting Duplicate Db at 11-SEP-12
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 09/11/2012 03:55:48
RMAN-05501: aborting duplication of target database
RMAN-05537: DUPLICATE without TARGET connection when auxiliary instance is started with spfile cannot use SPFILE clause
Recovery Manager: Release 11.2.0.2.0 - Production on Tue Sep 11 03:53:43 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: DG1 (DBID=1774279666)
connected to auxiliary database: DG1 (not mounted)
RMAN> DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER
SPFILE
SET db_unique_name='dg1_b' COMMENT 'Is standby'
SET LOG_ARCHIVE_DEST_2='SERVICE=dg1_a ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg1_a'
SET FAL_SERVER='dg1_a' COMMENT 'Is primary'
NOFILENAMECHECK;2> 3> 4> 5> 6> 7> 8> 9>
Starting Duplicate Db at 11-SEP-12
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 09/11/2012 03:55:48
RMAN-05501: aborting duplication of target database
RMAN-05537: DUPLICATE without TARGET connection when auxiliary instance is started with spfile cannot use SPFILE clause
The above error provide all the info, have to use the pfile ( we are using spfile )
create a dummy pfile ---set onle db_name=dg1
sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Tue Sep 11 04:02:25 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='initdg1_b.ora';
ORACLE instance started.
Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
SQL>
SQL*Plus: Release 11.2.0.2.0 Production on Tue Sep 11 04:02:25 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='initdg1_b.ora';
ORACLE instance started.
Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
SQL>
Run the Duplicate command, it will succeed this time.
Check the standby database status and start the recovery process -
SQL> select name , open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
DG1 MOUNTED
SQL> select PROCESS,CLIENT_PROCESS,THREAD#,SEQUENCE#,BLOCK# from v$managed_standby where process = 'MRP0' or client_process='LGWR';
PROCESS CLIENT_P THREAD# SEQUENCE# BLOCK#
--------- -------- ---------- ---------- ----------
MRP0 N/A 1 20 0
SQL>
SQL>
SQL> SELECT sequence#, first_time, next_time
FROM v$archived_log
ORDER BY sequence#;
2 3
SEQUENCE# FIRST_TIME NEXT_TIME
---------- -------------------- --------------------
18 11-SEP-2012 03:40:15 11-SEP-2012 04:03:12
19 11-SEP-2012 04:03:12 11-SEP-2012 04:07:23
SQL> alter database recover managed standby database cancel;
Database altered.
NAME OPEN_MODE
--------- --------------------
DG1 MOUNTED
SQL> select PROCESS,CLIENT_PROCESS,THREAD#,SEQUENCE#,BLOCK# from v$managed_standby where process = 'MRP0' or client_process='LGWR';
PROCESS CLIENT_P THREAD# SEQUENCE# BLOCK#
--------- -------- ---------- ---------- ----------
MRP0 N/A 1 20 0
SQL>
SQL>
SQL> SELECT sequence#, first_time, next_time
FROM v$archived_log
ORDER BY sequence#;
2 3
SEQUENCE# FIRST_TIME NEXT_TIME
---------- -------------------- --------------------
18 11-SEP-2012 03:40:15 11-SEP-2012 04:03:12
19 11-SEP-2012 04:03:12 11-SEP-2012 04:07:23
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database flashback on; --In both the databases Primary and Standby
Database altered.
Database altered.
Now check from the above query that you are receiving the data fine, try log switch on primary and check the sequence in standby. In case of any error check the alert log of primary as well as standby. A silly mistake I have done once, dg1_b should be the unique name in log_file_config I have set it to dg_b. somehow "1" is missed (Anyway I never liked this number "1" too much :D ) with me and it takes long time for me to figure that out. you can see something like this in the alert log -
PING[ARC1]: Heartbeat failed to connect to standby 'dg1_b'. Error is 16057
This is a very common error so thought of sharing with you guys. Just check all the basic parameters once again and you will find something wrong there, always start with the basic steps.
Verify the data transfer
SELECT sequence#, first_time, next_time
FROM v$archived_log
ORDER BY sequence#;
FROM v$archived_log
ORDER BY sequence#;
Once you can see the above query result same from primary and Standby you are good to go.
If not going with rman duplicate database
Changes Required in the Standby parameter file, though these are required only when you are not using the duplicate database. And duplicate database works with standby started with pfile, it can be dummy as we recover the same file neway. if you are planning to use user managed backup, rman backup, following are the minimal changes required in the standby pfile*.db_unique_name='dg1_b'
*.fal_server='dg1_a'
*.log_archive_dest_2='SERVICE=dg1_a ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg1_a'
*.control_files='/opt/app/oracle/11.2.0.2/A13db/oradata/dg1/dg1_b_control01.ctl',
'/opt/app/oracle/11.2.0.2/A13db/oradata/dg1/dg1_b_control02.ctl',
DG BROKER Configuration
As we have primary and standby in sync, we will try the DG Broker configurations to avoid the manual switchover task, following are the steps-
SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;
System altered.
Edit the listener.ora on both nodes to add a static entry for DGMGRL
This is to prevent the ORA-12154 error which can be observed on startup of the standby database after performing a switchover.
Ensure that the GLOBAL_DBNAME is set to db_unique_name_DGMGRL.db_domain
System altered.
Edit the listener.ora on both nodes to add a static entry for DGMGRL
This is to prevent the ORA-12154 error which can be observed on startup of the standby database after performing a switchover.
Ensure that the GLOBAL_DBNAME is set to db_unique_name_DGMGRL.db_domain
Check the broker config files
SQL> show parameter dg_broker_config_file1
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1 string /opt/app/oracle/11.2.0.2/A13db
/dbs/dr1DG1_A.dat
SQL> show parameter dg_broker_config_file2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file2 string /opt/app/oracle/11.2.0.2/A13db
/dbs/dr2DG1_A.dat
DGMGRL> connect sys/system
Connected.
DGMGRL> CREATE CONFIGURATION 'dg1_conf' AS PRIMARY DATABASE IS 'dg1_a' CONNECT IDENTIFIER IS 'dg1_a';
Configuration "dg1_config" created with primary database "dg1_a"
DGMGRL> ADD DATABASE 'dg1_b' AS CONNECT IDENTIFIER IS 'dg1_b' MAINTAINED AS PHYSICAL;
Database "dg1_b" added
DGMGRL>
DGMGRL>
DGMGRL> show configuration;
Configuration - dg1_config
Protection Mode: MaxAvailability
Databases:
dg1_a - Primary database
dg1_b - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
DGMGRL>
DGMGRL> enable configuration;
Enabled.
DGMGRL> show configuration;
Configuration - dg1_config
Protection Mode: MaxAvailability
Databases:
dg1_a - Primary database
Error: ORA-16810: multiple errors or warnings detected for the database
dg1_b - Physical standby database
Error: ORA-16810: multiple errors or warnings detected for the database
Fast-Start Failover: DISABLED
Configuration Status:
ERROR
Following is the command to check the errors
DGMGRL> show database dg1_a statusreport;
STATUS REPORT
INSTANCE_NAME SEVERITY ERROR_TEXT
* WARNING ORA-16629: database reports a different protecti
dg1 ERROR ORA-16737: the redo transport service for standb
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1 string /opt/app/oracle/11.2.0.2/A13db
/dbs/dr1DG1_A.dat
SQL> show parameter dg_broker_config_file2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file2 string /opt/app/oracle/11.2.0.2/A13db
/dbs/dr2DG1_A.dat
DGMGRL> connect sys/system
Connected.
DGMGRL> CREATE CONFIGURATION 'dg1_conf' AS PRIMARY DATABASE IS 'dg1_a' CONNECT IDENTIFIER IS 'dg1_a';
Configuration "dg1_config" created with primary database "dg1_a"
DGMGRL> ADD DATABASE 'dg1_b' AS CONNECT IDENTIFIER IS 'dg1_b' MAINTAINED AS PHYSICAL;
Database "dg1_b" added
DGMGRL>
DGMGRL>
DGMGRL> show configuration;
Configuration - dg1_config
Protection Mode: MaxAvailability
Databases:
dg1_a - Primary database
dg1_b - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
DGMGRL>
DGMGRL> enable configuration;
Enabled.
DGMGRL> show configuration;
Configuration - dg1_config
Protection Mode: MaxAvailability
Databases:
dg1_a - Primary database
Error: ORA-16810: multiple errors or warnings detected for the database
dg1_b - Physical standby database
Error: ORA-16810: multiple errors or warnings detected for the database
Fast-Start Failover: DISABLED
Configuration Status:
ERROR
Following is the command to check the errors
DGMGRL> show database dg1_a statusreport;
STATUS REPORT
INSTANCE_NAME SEVERITY ERROR_TEXT
* WARNING ORA-16629: database reports a different protecti
dg1 ERROR ORA-16737: the redo transport service for standb
Get the above error while enabling configuration, why? the error suggest that clearly.
Check the protection mode and log shipping method from both Primary and Standby
SQL> select name , protection_mode , database_role, db_unique_name from v$database;
NAME PROTECTION_MODE DATABASE_ROLE DB_UNIQUE_NAME
--------- -------------------- ---------------- ------------------------------
DG1 MAXIMUM AVAILABILITY PRIMARY DG1_A
SQL> show parameter LOG_ARCHIVE_DEST_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=dg1_b AFFIRM SYNC VALI
D_FOR=(ONLINE_LOGFILES,PRIMARY
_ROLE) DB_UNIQUE_NAME=dg1_b
log_archive_dest_20 string
DB_UNIQUE_NAME PROTECTION_MODE DATABASE_ROLE DB_UNIQUE_NAME
------------------------------ -------------------- ---------------- ------------------------------
dg1_b MAXIMUM AVAILABILITY PHYSICAL STANDBY dg1_b
SQL> show parameter LOG_ARCHIVE_DEST_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=dg1_a ASYNC VALID_FOR=
(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=dg1_a
NAME PROTECTION_MODE DATABASE_ROLE DB_UNIQUE_NAME
--------- -------------------- ---------------- ------------------------------
DG1 MAXIMUM AVAILABILITY PRIMARY DG1_A
SQL> show parameter LOG_ARCHIVE_DEST_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=dg1_b AFFIRM SYNC VALI
D_FOR=(ONLINE_LOGFILES,PRIMARY
_ROLE) DB_UNIQUE_NAME=dg1_b
log_archive_dest_20 string
DB_UNIQUE_NAME PROTECTION_MODE DATABASE_ROLE DB_UNIQUE_NAME
------------------------------ -------------------- ---------------- ------------------------------
dg1_b MAXIMUM AVAILABILITY PHYSICAL STANDBY dg1_b
SQL> show parameter LOG_ARCHIVE_DEST_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=dg1_a ASYNC VALID_FOR=
(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=dg1_a
So there is a difference in a way the redo is shipped from primary and standby, have to make this similar for the DG configuration work properly, lets do that -
Using SQLPLUS
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=dg1_b NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg1_b';
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=dg1_a NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg1_a';
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=dg1_a NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg1_a';
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;
Using DGMGRL Command line
EDIT DATABASE dg1_a SET PROPERTY LogXptMode=ASYNC;
EDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;
Note:
If broker management of the database is enabled, setting a database property value
causes the underlying parameter value to be changed in the corresponding database,
and the value for the changed parameter is reflected in the server parameter file. Thus,
if the database is shut down and restarted outside of Oracle Enterprise Manager and
DGMGRL (such as from the SQL*Plus interface), the database uses the new parameter
values from the updated server parameter file when it starts. However, you should not make changes to the redo transport services initialization parameters through SQL statements. Doing so will cause an inconsistency between the database and the broker.
If broker management of the database is enabled, setting a database property value
causes the underlying parameter value to be changed in the corresponding database,
and the value for the changed parameter is reflected in the server parameter file. Thus,
if the database is shut down and restarted outside of Oracle Enterprise Manager and
DGMGRL (such as from the SQL*Plus interface), the database uses the new parameter
values from the updated server parameter file when it starts. However, you should not make changes to the redo transport services initialization parameters through SQL statements. Doing so will cause an inconsistency between the database and the broker.
Now lets try the same once again -
dgmgrl
DGMGRL for Linux: Version 11.2.0.2.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/system
Connected.
DGMGRL> EDIT DATABASE dg1_a SET PROPERTY LogXptMode=ASYNC;
Property "logxptmode" updated
DGMGRL for Linux: Version 11.2.0.2.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/system
Connected.
DGMGRL> EDIT DATABASE dg1_a SET PROPERTY LogXptMode=ASYNC;
Property "logxptmode" updated
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;
Succeeded.
DGMGRL> EDIT DATABASE dg1_b SET PROPERTY LogXptMode=ASYNC;
Property "logxptmode" updated
DGMGRL> connect sys/system ---standby
Connected.
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;
DGMGRL>
DGMGRL> enable configuration
Enabled.
DGMGRL> show configuration
Configuration - dg1_config
Protection Mode: MaxPerformance
Databases:
dg1_a - Primary database
dg1_b - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
Let’s change the listener file above and see what happens when we set the DBNAME_DGMGRL.domain.com in the listener.ora file not db_unique_name_DGMGRL.domain.com
Let’s try the switchover from DGMGRL now -
DGMGRL> switchover to 'dg1_b'
--As expected error, and the famous one, listener doesn't know the service requested in the connect identifier when connecting to dg1_b
Before resolving this error we have to switchover manually. Check the status of the switchover as switchover might be in pending state-
primary
SQL> select protection_mode , database_role, switchover_status from v$database;
PROTECTION_MODE DATABASE_ROLE SWITCHOVER_STATUS
-------------------- ---------------- --------------------
MAXIMUM PERFORMANCE PRIMARY TO STANDBY
standby
SQL> select protection_mode , database_role, switchover_status from v$database;
PROTECTION_MODE DATABASE_ROLE SWITCHOVER_STATUS
-------------------- ---------------- --------------------
MAXIMUM PERFORMANCE PHYSICAL STANDBY SWITCHOVER PENDING
As per the standby status, switchover is pending and as with the DGMGRL it wasn’t successful we have only option left is manual switchover. Following is the manual way of switching over
Manual Switchover
First check the SWITCHOVER_STATUS column from v$database before going for the manual switchover. Following are the different values it can take-
The SWITCHOVER_STATUS column of v$database can have the following values:
NOT ALLOWED - Either this is a standby database and the primary database has not been switched first, or this is a primary database and there are no standby databases.
SESSIONS ACTIVE - Indicates that there are active SQL sessions attached to the primary or standby database that need to be disconnected before the switchover operation is permitted.
SWITCHOVER PENDING - This is a standby database and the primary database switchover request has been received but not processed. –Our case
SWITCHOVER LATENT - The switchover was in pending mode, but did not complete and went back to the primary database.
TO PRIMARY - This is a standby database, with no active sessions, that is allowed to switch over to a primary database.
TO STANDBY - This is a primary database, with no active sessions, that is allowed to switch over to a standby database.
RECOVERY NEEDED - This is a standby database that has not received the switchover request.
During normal operations it is acceptable to see the following values for
SWITCHOVER_STATUS on the primary to be SESSIONS ACTIVE or TO STANDBY.
During normal operations on the standby it is acceptable to see the values of
NOT ALLOWED or SESSIONS ACTIVE.
Steps to do Manual switchover
SQL> alter database commit to switchover to standby with session shutdown;
Note that the clause also works with the switchover to primary command.
Note that the clause also works with the switchover to primary command.
2. Convert the primary database to the new standby:
SQL> alter database commit to switchover to physical standby ;
Database altered.
3. Shutdown the former primary and mount as a standby database:
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 85020944 bytes
Fixed Size 454928 bytes
Variable Size 71303168 bytes
Database Buffers 12582912 bytes
Redo Buffers 679936 bytes
SQL> alter database mount standby database;
Database altered.
4. Defer the remote archive destination on the old primary:
SQL> alter database commit to switchover to physical standby ;
Database altered.
3. Shutdown the former primary and mount as a standby database:
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 85020944 bytes
Fixed Size 454928 bytes
Variable Size 71303168 bytes
Database Buffers 12582912 bytes
Redo Buffers 679936 bytes
SQL> alter database mount standby database;
Database altered.
4. Defer the remote archive destination on the old primary:
SQL> alter system set log_archive_dest_state_2=defer;
5. Verify that the physical standby can be converted to the new primary:
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
------------------
SWITCHOVER PENDING
Note that if the status returns SESSIONS ACTIVE then you should append the with session shutdown clause to the command in the next step.
6. Convert the physical standby to the new primary:
SQL> alter database commit to switchover to primary;
Database altered.
7. Shutdown and startup the new primary:
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 85020944 bytes
Fixed Size 454928 bytes
Variable Size 71303168 bytes
Database Buffers 12582912 bytes
Redo Buffers 679936 bytes
Database mounted.
Database opened.
8. Enable remote archiving on the new primary to the new standby:
SQL> alter system set log_archive_dest_state_2=enable;
9. Start managed recover on the new standby database:
SQL> recover managed standby database disconnect;
Media recovery complete.
5. Verify that the physical standby can be converted to the new primary:
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
------------------
SWITCHOVER PENDING
Note that if the status returns SESSIONS ACTIVE then you should append the with session shutdown clause to the command in the next step.
6. Convert the physical standby to the new primary:
SQL> alter database commit to switchover to primary;
Database altered.
7. Shutdown and startup the new primary:
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 85020944 bytes
Fixed Size 454928 bytes
Variable Size 71303168 bytes
Database Buffers 12582912 bytes
Redo Buffers 679936 bytes
Database mounted.
Database opened.
8. Enable remote archiving on the new primary to the new standby:
SQL> alter system set log_archive_dest_state_2=enable;
9. Start managed recover on the new standby database:
SQL> recover managed standby database disconnect;
Media recovery complete.
SQL> select protection_mode , database_role, switchover_status from v$database;
PROTECTION_MODE DATABASE_ROLE SWITCHOVER_STATUS
-------------------- ---------------- --------------------
MAXIMUM PERFORMANCE PRIMARY TO STANDBY
SQL> select protection_mode , database_role, switchover_status from v$database;
PROTECTION_MODE DATABASE_ROLE SWITCHOVER_STATUS
-------------------- ---------------- --------------------
MAXIMUM PERFORMANCE PHYSICAL STANDBY NOT ALLOWED
Verify the log shipping once again
PROTECTION_MODE DATABASE_ROLE SWITCHOVER_STATUS
-------------------- ---------------- --------------------
MAXIMUM PERFORMANCE PRIMARY TO STANDBY
SQL> select protection_mode , database_role, switchover_status from v$database;
PROTECTION_MODE DATABASE_ROLE SWITCHOVER_STATUS
-------------------- ---------------- --------------------
MAXIMUM PERFORMANCE PHYSICAL STANDBY NOT ALLOWED
Verify the log shipping once again
What is the status of SYNC?
From Primary:-
SQL> select thread#,max(sequence#) from v$archived_log group by thread#;
From Standby:-
SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;
From Primary:-
SQL> select thread#,max(sequence#) from v$archived_log group by thread#;
From Standby:-
SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;
OR
SELECT sequence#, first_time, next_time
FROM v$archived_log
ORDER BY sequence#;
We are good to go now after the manual switchover, but let’s look at what has gone wrong when we tried the same from the DGMGRL. Ok first change the Listener file and keep the db_unique_name_DGMGRL.domain.com in the listener file. Reconfigure the DGMGRL.
DGMGRL> disable configuration;
Disabled.
DGMGRL> remove configuration;
Removed configuration
Reconfigure the DGMGRL and enable the configuration.
Try the switchover now
dg2.amazon$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Tue Sep 25 13:01:40 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name ,database_role , switchover_status, db_unique_name from v$database;
NAME DATABASE_ROLE SWITCHOVER_STATUS DB_UNIQUE_NAME
--------- ---------------- -------------------- ------------------------------
DG1 PRIMARY TO STANDBY dg1_b
DGMGRL> connect sys/system
Connected.
DGMGRL> switchover to dg1_a
Performing switchover NOW, please wait...
New primary database "dg1_a" is opening...
Operation requires shutdown of instance "dg1" on database "dg1_b"
Shutting down instance "dg1"...
ORACLE instance shut down.
Operation requires startup of instance "dg1" on database "dg1_b"
Starting instance "dg1"...
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "dg1_a"
SQL*Plus: Release 11.2.0.2.0 Production on Tue Sep 25 13:01:40 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name ,database_role , switchover_status, db_unique_name from v$database;
NAME DATABASE_ROLE SWITCHOVER_STATUS DB_UNIQUE_NAME
--------- ---------------- -------------------- ------------------------------
DG1 PRIMARY TO STANDBY dg1_b
DGMGRL> connect sys/system
Connected.
DGMGRL> switchover to dg1_a
Performing switchover NOW, please wait...
New primary database "dg1_a" is opening...
Operation requires shutdown of instance "dg1" on database "dg1_b"
Shutting down instance "dg1"...
ORACLE instance shut down.
Operation requires startup of instance "dg1" on database "dg1_b"
Starting instance "dg1"...
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "dg1_a"
So all good now :-)
Following are the details for the good configuration, just to avoid any confusion as we have seen so many scenarios with errors; –
Primary Database: dg1
Db_unique_Name:dg1_a
tnsnames.ora
dg1_a =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1.domain.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dg1)
)
)
dg1_b =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg2.domain.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dg1)
)
)
dg1_a =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1.domain.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dg1)
)
)
dg1_b =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg2.domain.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dg1)
)
)
listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /opt/app/oracle/11.2.0.2/A13db)
(SERVICE_NAME=dg1.domain.com)
(global_dbname = dg1_a_DGMGRL.domain.com)
(SID_NAME = dg1)
)
(SID_DESC =
(SID_NAME = dg1)
(ORACLE_HOME = /opt/app/oracle/11.2.0.2/A13db)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1.domain.com)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /opt/app/oracle/11.2.0.2/A13db)
(SERVICE_NAME=dg1.domain.com)
(global_dbname = dg1_a_DGMGRL.domain.com)
(SID_NAME = dg1)
)
(SID_DESC =
(SID_NAME = dg1)
(ORACLE_HOME = /opt/app/oracle/11.2.0.2/A13db)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1.domain.com)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
DGMGRL> show database verbose dg1_a
Database - dg1_a
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 8 minutes 2 seconds
Apply Lag: 8 minutes 2 seconds
Real Time Query: OFF
Instance(s):
dg1
Properties:
DGConnectIdentifier = 'dg1_a'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '30'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'dg1_b, dg1_a'
LogFileNameConvert = 'dg1_b, dg1_a'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
SidName = 'dg1'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg1.domain.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=DG1_A_DGMGRL.domain.com)(INSTANCE_NAME=dg1)(SERVER=DEDICATED)))'
StandbyArchiveLocation = 'USE_DB_RECOVERY_FILE_DEST'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
TopWaitEvents = '(monitor)'
Database Status:
SUCCESS
More on DataGuard Check this: http://abhinavsarin.blogspot.in/
Database - dg1_a
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 8 minutes 2 seconds
Apply Lag: 8 minutes 2 seconds
Real Time Query: OFF
Instance(s):
dg1
Properties:
DGConnectIdentifier = 'dg1_a'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '30'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'dg1_b, dg1_a'
LogFileNameConvert = 'dg1_b, dg1_a'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
SidName = 'dg1'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg1.domain.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=DG1_A_DGMGRL.domain.com)(INSTANCE_NAME=dg1)(SERVER=DEDICATED)))'
StandbyArchiveLocation = 'USE_DB_RECOVERY_FILE_DEST'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
TopWaitEvents = '(monitor)'
Database Status:
SUCCESS
More on DataGuard Check this: http://abhinavsarin.blogspot.in/