With Oracle database 10g Release 2, there is a feature called Fast Start Failover (FSFO), that can be configured to enable the production Dataguard configuration to automatically trigger a role change (switchover or failover) to an appropriate standby database in the event of any outages to production.
To demonstrate this, I will setup a simple 10g Dataguard configuration using the Dataguard Broker client (DGMGRL), and then enable FSFO. Before proceeding further, a simple explanation of the components involved will be useful. The main components in a Dataguard Broker configuration are
i. Primary database
ii. Up to nine standby databases
iii. Dataguard broker client (DGMGRL)
iv. Associated background processes (DMON, INSV, etc)
In order to configure the Dataguard Broker, first we will need to have a standby database created, and start recovery. This can easily be done via RMAN (Recovery Manager), or even with a manual copy and transfer of database files to the standby server, setting the relevant initialization parameters, and running the relevant SQLplus commands (not listed here).
In my case, the working environment has been setup as per the configuration (named MSDPOB) below:
DB Unique Name / Role |
Server Hostname |
Server IP Address |
Operating Sytem |
Service Name |
MSDP / Primary |
solaris1 |
192.168.247.131 |
Solaris 10 |
MSDP |
MSDP_DG / Standby |
solaris2 |
192.168.247.132 |
Solaris 10 |
MSDP_DG |
The tasks that need to be completed can be divided into the following categories:
i. enable and start dataguard broker processes on both primary and standby databases
ii. create a dataguard configuration with Oracle Dataguard Broker
iii. enable Fast Start Failover for the configuration
I. Enable and start dataguard broker processes on both primary and standby databases
We need to start the relevant background processes, and also set the location for the Dataguard broker configuration files (by default located in $ORACLE_HOME/dbs):
SQL> ALTER SYSTEM SET dg_broker_config_file1 = ‘ /u01/app/oracle/product/10.2.0/ /db_1/dbs/dr1msdp_dg.dat’ scope=both sid=’*’;
SQL> ALTER SYSTEM SET dg_broker_config_file2 = ‘ /u01/app/oracle/product/10.2.0/ /db_1/dbs/dr2msdp_dg.dat’ scope=both sid=’*’;
Next, we will need to start the Dataguard broker process on both nodes by using the following command on the primary and standby databases:
SQL>ALTER SYSTEM SET DG_BROKER_START=TRUE;
II. Create a dataguard configuration with Oracle Dataguard Broker
First, we need to ensure that the databases have been manually registered with the listeners on both the primary and standby servers, and that a separate TNS names entry for the Dataguard broker has been created:
Sample TNSNAMES.ORA entries
LISTENER_MSDPDG =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = solaris2)(PORT = 1523))
)
)
MSDP =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = solaris1)(PORT = 1523))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = msdp_DGMGRL)
)
)
MSDP_DG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = solaris2)(PORT = 1523))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = msdp_dg_DGMGRL)
)
)
MSDP =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = solaris1)(PORT = 1523))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = msdp)
)
)
MSDP_DG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = solaris2)(PORT = 1523))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = msdp_dg)
)
)
Note*: Please ensure that the service name entries have been configured correctly for each of the services.
Sample LISTENER.ORA entries:
SID_LIST_LISTENER_MSDPDG =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = msdp_dg_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = msdp_dg)
)
)
LISTENER_MSDPDG =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = solaris2)(PORT = 1523))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
Note*: Please ensure that database instance on each server have been listed in the listener.ora file to enable Dataguard broker to perform switchovers that involve shutdown.
We also need to set the LOCAL_LISTENER parameter in both the primary and standby databases accordingly (as shown below):
SQL> show parameter local
NAME TYPE VALUE
———————- ———– ——————————
local_listener string (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=solaris1)(PORT=1523)))
SQL> show parameter local
NAME TYPE VALUE
———————- ———– ——————————
local_listener string (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=solaris2)(PORT=1523)))
Connect to the DGMGRL client (from either the primary or standby servers) and create the Dataguard broker configuration:
$ dgmgrl
DGMGRL> create configuration msdpconf as primary database is msdp connect identifier is mdsp;
DGMGRL> add database msdp_dg as connect identifier is msdp_dg maintained as physical;
DGMGRL> show configuration verbose;
DGMGRL> show configuration verbose;
Configuration
Name: msdpconf
Enabled: NO
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
msdp – Primary database
msdp_dg – Physical standby database
Current status for “msdpconf”:
DISABLED
Enable the configuration and ensure that it is functioning as expected:
DGMGRL> enable configuration
DGMGRL> show configuration verbose;
Configuration
Name: msdpconf
Enabled: YES
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
msdp – Primary database
msdp_dg – Physical standby database
Current status for “msdpconf”:
SUCCESS
I. Enable Fast Start Failover for the configuration
Now that we have an Oracle Dataguard broker configuration created, we are ready to enable Fast Start Failover (FSFO).
Fast-start failover provides the ability to totally automate the failover of database processing from the production to standby database, without any human intervention. Fast-start failover automatically, quickly, and reliably fails over to a designated, synchronized standby database in the event of loss of the primary database.
To enable the functionality described above, a separate Observer process must be started for the Dataguard Broker, to monitor the entire configuration, and trigger a switchover if required. As such, it is recommended to run the Observer from a separate server/workstation entirely.
However, to implement FSFO, there are several additional pre-requisites that have to be met, namely:
i. the primary and standby databases must have Flashback enabled (consequently, the Flash Recovery Area must be created first)
ii. both the primary and standby databases must be running with FORCELOGGING enabled
iii. the standby database (and the primary database during switchover) must have standby archived logs created
iv. the transport mode for archived log files must be in SYNC mode
v. the protection mode for the Dataguard configuration must be upgraded to Maximum Availability, at least
vi. the FSFO target must be set for both the primary and standby databases
To enable Flashback, first create a designated area for the Flash Recovery Area (FRA), and then enable Flashback as shown below (must be carried out on primary and standby):
SQL> show parameter recovery_file
NAME TYPE VALUE
———————————— ———– ——————————
db_recovery_file_dest string /u01/app/oracle/flash_recovery_area
db_recovery_file_dest_size big integer 2G
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database flashback on;
To place the database in FORCELOGGING mode, run the following in SQLplus:
SQL> alter database force logging;
Verify using the following command:
SQL> select db_unique_name, open_mode,flashback_on, force_logging from v$database;
DB_UNIQUE_NAME OPEN_MODE FLASHBACK_ON FOR
—————————— ———- —————— —
msdp READ WRITE YES YES
SQL> select db_unique_name, open_mode,flashback_on, force_logging from v$database;
DB_UNIQUE_NAME OPEN_MODE FLASHBACK_ON FOR
—————————— ———- —————— —
msdp_dg MOUNTED YES YES
To create the standby redo logs, run the following commands in SQLplus on the standby and primary databases:
SQL> select a.GROUP#,a.BYTES/1024/1024 “MB”,b.type, b.member from v$log a, v$logfile b where a.group#=b.group#;
GROUP# MB TYPE MEMBER
———- ———- ——- ——————————————
1 50 ONLINE /u01/app/oracle/oradata/msdpdg/redo01.log
3 50 ONLINE /u01/app/oracle/oradata/msdpdg/redo03.log
2 50 ONLINE /u01/app/oracle/oradata/msdpdg/redo02.log
SQL> alter database add standby logfile group 4 ‘/u01/app/oracle/oradata/msdpdg/stdbyredo01.log’ size 50m;
SQL> alter database add standby logfile group 5 ‘/u01/app/oracle/oradata/msdpdg/stdbyredo02.log’ size 50m;
SQL> alter database add standby logfile group 6 ‘/u01/app/oracle/oradata/msdpdg/stdbyredo03.log’ size 50m;
SQL> alter database add standby logfile group 7 ‘/u01/app/oracle/oradata/msdpdg/stdbyredo04.log’ size 50m;
Note*: The number of standby log files (in this case for our single instance primary database MSDP) is equivalent to (#of online logfile groups + 1). We do not need to multiplex standby redo log files, as it is only used for recovery.
After this, we need to change the Dataguard Broker configuration settings, as shown below:
DGMGRL> edit database msdp set property LogXptMode=’SYNC’;
Property “logxptmode” updated
DGMGRL> edit database msdp_dg set property LogXptMode=’SYNC’;
Property “logxptmode” updated
Next we need to define the failover targets for both the primary and standby databases. This is to enable the Oracle Observer process to automatically switchover in the event of an outage to the primary database, as shown below:
DGMGRL> EDIT DATABASE msdp SET PROPERTY FastStartFailoverTarget=’msdp_dg’;
Property “faststartfailovertarget” updated
DGMGRL> EDIT DATABASE msdp_dg SET PROPERTY FastStartFailoverTarget=’msdp’;
Property “faststartfailovertarget” updated
After that, we will upgrade the Dataguard protection level to Maximum Availability. This is a pre-requisite before enabling FSFO, with the following:
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Succeeded.
Finally, we are able to enable the FSFO for our Dataguard configuration, by running the following command:
DGMGRL> ENABLE FAST_START FAILOVER;
Enabled.
To verify, start the Observer process and run the following:
In a separate window, run the following command from DGMGRL to start the Observer process (connect to either the primary or standby database)
DGMGRL> connect sys/oracle@msdp
DGMGRL> start observer;
Verify configuration from DGMGRL:
DGMGRL> show configuration verbose;
Configuration
Name: msdpconf
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: ENABLED
Databases:
msdp_dg – Physical standby database
– Fast-Start Failover target
msdp – Primary database
Fast-Start Failover
Threshold: 30 seconds
Observer: solaris2
Shutdown Primary: TRUE
Current status for “msdpconf”:
SUCCESS
Verify from SQLplus as well:
SQL> select DB_UNIQUE_NAME,DATABASE_ROLE,OPEN_MODE,FS_FAILOVER_STATUS,FS_FAILOVER_CURRENT_TARGET from v$database;
DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE FS_FAILOVER_STATUS
—————————— —————- ———- ———————
FS_FAILOVER_CURRENT_TARGET
——————————
msdp PRIMARY READ WRITE SYNCHRONIZED
msdp_dg
SQL> select DB_UNIQUE_NAME,DATABASE_ROLE,OPEN_MODE,FS_FAILOVER_STATUS,FS_FAILOVER_CURRENT_TARGET from v$database;
DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE FS_FAILOVER_STATUS
—————————— —————- ———- ———————
FS_FAILOVER_CURRENT_TARGET
——————————
msdp_dg PHYSICAL STANDBY MOUNTED SYNCHRONIZED
msdp_dg
Now that we have a working FSFO configuration, we can test the automated failover functionality.
To do this, we will:
i. simulate a failure on the production database
ii. allow the primary database to be switched over to the standby server
iii. carry out some changes on the new primary database
iv. reinstate (re-enable) the former primary database
The easiest way to simulate a failure on the primary database, is to run the SHUTDOWN ABORT command via SQLplus. This will shutdown the primary database, without going through the steps involved in a ‘clean’ shutdown (flushing the memory buffers, performing a checkpoint, synchronizing datafile headers, etc) and is similar to a power failure of the primary server.
SQL> shut abort
ORACLE instance shut down.
From the DGMGRL log, we can observe the following:
DGMGRL> start observer;
Observer started
18:44:48.74 Tuesday, October 05, 2010
Initiating fast-start failover to database “msdp_dg”…
Performing failover NOW, please wait…
Operation requires shutdown of instance “msdp_dg” on database “msdp_dg”
Shutting down instance “msdp_dg”…
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance “msdp_dg” on database “msdp_dg”
Starting instance “msdp_dg”…
ORACLE instance started.
Database mounted.
Failover succeeded, new primary is “msdp_dg”
18:45:57.98 Tuesday, October 05, 2010
The Observer process detected a disconnect from the primary database, and after the threshold specified (the Threshold parameter in the FSFO configuration, default 30 seconds) it automatically initiated a switchover to the standby MSDP_DG instance.
To continue our simulation, we will then carry out some changes on the new primary database. For this example, the STANDBY_FILE_MANAGEME NT parameter should have been set to AUTO earlier, and the datafile path /u01/app/oracle/oradata/msdp must be mirrored in the standby server.
SQL> select name from v$datafile;
NAME
——————————————————————————–
/u01/app/oracle/oradata/msdpdg/system01.dbf
/u01/app/oracle/oradata/msdpdg/undotbs01.dbf
/u01/app/oracle/oradata/msdpdg/sysaux01.dbf
/u01/app/oracle/oradata/msdpdg/users01.dbf
SQL> create tablespace fsfotest datafile ‘/u01/app/oracle/oradata/msdpdg/fsfotest01.dbf’ size 10m;
Tablespace created.
Finally, we will look at how we reinstate the former primary instance (MSDP) into our Dataguard Broker configuration, using the FSFO functionality. First, we will bring up the MSDP instance in NOMOUNT state:
SQL> startup nomount
ORACLE instance started.
Total System Global Area 209715200 bytes
Fixed Size 2095120 bytes
Variable Size 96471024 bytes
Database Buffers 104857600 bytes
Redo Buffers 6291456 bytes
Next, we will mount the MSDP database. At this point, note the output from the FSFO logfile (or from the screen, if starting the observer manually):
SQL> alter database mount;
DGMGRL output:
18:56:37.09 Tuesday, October 05, 2010
Initiating reinstatement for database “msdp”…
Reinstating database “msdp”, please wait…
Operation requires shutdown of instance “msdp” on database “msdp”
Shutting down instance “msdp”…
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance “msdp” on database “msdp”
Starting instance “msdp”…
ORACLE instance started.
Database mounted.
Continuing to reinstate database “msdp” …
Reinstatement of database “msdp” succeeded
18:57:56.94 Tuesday, October 05, 2010
From the output, we can see that when the MSDP instance is mounted, the Dataguard Broker processes are also started in the background. At this point, the Observer is able to detect that the former primary database MSDP needs to be reinstated into the configuration, with its role changed to that of a physical standby database.
As part of the reinstatement process, the MSDP instance will be synchronized to a point of time before the failover happened (via Flashback), and then re-started as a standby database before recovery is carried out.
When this entire process is completed, the new configuration will be as below:
DGMGRL> show configuration verbose;
Configuration
Name: msdpconf
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: ENABLED
Databases:
msdp_dg – Primary database
msdp – Physical standby database
– Fast-Start Failover target
Fast-Start Failover
Threshold: 30 seconds
Observer: solaris1
Shutdown Primary: TRUE
Current status for “msdpconf”:
SUCCESS
Additionally, the changes we carried out earlier have been reflected on the MSDP instance:
SQL> select DB_UNIQUE_NAME,DATABASE_ROLE,OPEN_MODE,FS_FAILOVER_STATUS,FS_FAILOVER_CURRENT_TARGET from v$database;
DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE FS_FAILOVER_STATUS
—————————— —————- ———- ———————
FS_FAILOVER_CURRENT_TARGET
——————————
msdp PHYSICAL STANDBY MOUNTED SYNCHRONIZED
msdp
SQL> select name from v$datafile;
NAME
——————————————————————————–
/u01/app/oracle/oradata/msdp/system01.dbf
/u01/app/oracle/oradata/msdp/undotbs01.dbf
/u01/app/oracle/oradata/msdp/sysaux01.dbf
/u01/app/oracle/oradata/msdp/users01.dbf
/u01/app/oracle/oradata/msdpdg/fsfotest01.dbf
This demonstrates briefly the functionality of FSFO with Oracle Dataguard 10g, as a means of automatically performing role transitions in a configuration, as well as re-enabling a former primary database after a failover. This, in addition to recommended client failover strategies, help to create a easily manageable, highly available disaster recovery solution with Oracle Dataguard 10g.