Professional Documents
Culture Documents
You have two servers (physical or VMs) with an operating system and Oracle installed on them. In this
case I've used Oracle Linux 5.6 and Oracle Database 11.2.0.2.
/u01/app/oracle/product/11.2.0/dbhome_1
Update HOSTS file : Path /etc/hosts
*.DB_NAME='lprod'
*.DB_UNIQUE_NAME='lprod'
The DB_NAME of the standby database will be the same as that of the primary, but it must have a
different DB_UNIQUE_NAME value. The DB_UNIQUE_NAME values of the primary and standby database
should be used in theDG_CONFIG setting of the LOG_ARCHIVE_CONFIG parameter. For this example, the
standby database will have the value "lprod_stby".
Set suitable remote archive log destinations. In this case I'm using the fast recovery area for the local location,
but you could specify an location explicitly if you prefer. Notice the SERVICE and the DB_UNIQUE_NAME for
the remote location reference the standby location.
*.LOG_ARCHIVE_DEST_1='LOCATION=use_db_recovery_file_dest
VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lprod'
*.LOG_ARCHIVE_DEST_2='SERVICE=lprod_standby
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=lprod_stby'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
The LOG_ARCHIVE_FORMAT and LOG_ARCHIVE_MAX_PROCESSES parameters must be set to appropriate
values and the REMOTE_LOGIN_PASSWORDFILE must be set to exclusive.
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.LOG_ARCHIVE_PROCESSES=30
*.REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
In addition to the previous setting, it is recommended to make sure the primary is ready to switch roles to
become a standby. For that to work properly we need to set the following parameters.
*.FAL_CLIENT='lprod_primary'
*.FAL_SERVER='lprod_standby'
Set the *CONVERT parameters if primary and standby are on different file system. My standby is on /u02 file
system while primary is on /u01.
*.DB_FILE_NAME_CONVERT='u02','u01'
*.LOG_FILE_NAME_CONVERT='u02','u01'
Set the *STANDBY_FILE_MANAGEMENT to auto.
*.STANDBY_FILE_MANAGEMENT='AUTO'
TYPE
MEMBER
----------------------------------------
3 ONLINE /u01/app/oracle/oradata/novav10g/redo03.log
2 ONLINE / u01/app/oracle/oradata/novav10g/redo02.log
1 ONLINE / u01/app/oracle/oradata/novav10g/redo01.log
Note: you have to create this standby redolog in standby database also.
Step # 5: Now start the instance with new parameter file and create spfile
from it:
Shutdown immediate;
Startup nomount pfile=/u01/initprimary.ora;
Create spfile from pfile= /u01/initprimary.ora;
Shut immediate ;
Startup ;
Primary and copied over to the Standby site. The sys password must be identical on
both sites. This is a key pre requisite in order to be able to ship and apply archived logs
from Primary to Standby.
[oracle@rac6 ~]$ cd $ORACLE_HOME/dbs
[oracle@rac6 dbs]$ orapwd file=orapwnovav10g password=oracle force=y
SQL> select * from v$pwfile_users;
USERNAME
---------------------SYS
SYSDB SYSOP
--------------TRUE TRUE
*.DB_NAME='lprod'
*.DB_UNIQUE_NAME='lprod_stby'
The DB_NAME of the standby database will be the same as that of the primary, but it must have a
different DB_UNIQUE_NAME value. The DB_UNIQUE_NAME values of the primary and standby database
should be used in theDG_CONFIG setting of the LOG_ARCHIVE_CONFIG parameter. For this example, the
standby database will have the value "lprod_stby".
*.LOG_ARCHIVE_DEST_1='LOCATION=use_db_recovery_file_dest
VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lprod_stby'
*.LOG_ARCHIVE_DEST_2='SERVICE=lprod_standby
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lprod'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
The LOG_ARCHIVE_FORMAT and LOG_ARCHIVE_MAX_PROCESSES parameters must be set to appropriate
values and the REMOTE_LOGIN_PASSWORDFILE must be set to exclusive.
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.LOG_ARCHIVE_MAX_PROCESSES=30
*.REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
In addition to the previous setting, it is recommended to make sure the primary is ready to switch roles to
become a standby. For that to work properly we need to set the following parameters.
*.FAL_CLIENT='lprod_standby'
*.FAL_SERVER='lprod_primary'
Set the *CONVERT parameters if primary and standby are on different file system. My standby is on /u02 file
system while primary is on /u01.
*.DB_FILE_NAME_CONVERT='u01','u02'
*.LOG_FILE_NAME_CONVERT='u01','u02'
Set the *STANDBY_FILE_MANAGEMENT to auto.
*.STANDBY_FILE_MANAGEMENT='AUTO'
Step # 3: Once the new parameter file is ready we create from it the spfile:
Startup nomount pfile=/u01/initstandby.ora;
Create spfile from pfile= /u01/initstandby.ora;
Shut immediate ;
Startup nomount;
from session;
Test the configuration by generating archive logs from the primary and
then querying the standby to see if the logs are being successfully
applied.
On the Primary:
SQL> alter system switch logfile;
SQL> alter system archive log current;
SQL> archive log list
Database log mode
Automatic archival
Archive destination
Oldest online log sequence
Next log sequence to archive
Current log sequence
Archive Mode
Enabled
/oracle/10gdg/admin/prim/arch
14
16
16
Standby database
SQL> archive log list
Database log mode
Automatic archival
Archive destination
Oldest online log sequence
Next log sequence to archive
Current log sequence
Archive Mode
Enabled
/oracle/10gdg/admin/stand/arch
14
0
16
SWITHC OVER
We can perform switch over case when we want to perform certain
maintenance work on primary server and we want shutdown the
database
In this scenario we can perform switch over and convert standbyserver to primary-server (temporary use) and perform maintenance on
primary-server
For this
First check any active user connected to the primary-server should be
disconnected and stop any oracle job queue program.
Then check the database status is available for standby. For this we
can perform certain queries on primary-server.
Startup
FAILOVER
For failover scenario we must flashback on for both databases
The advantage of flashback on is that we can up the primary database
when recover.
Otherwise once failover is performed we cannot up the primary
machine and the dataguard is lost.
ON STANDBY
Now suddenly our primary data center lost due to any reason
(flood, fire, bomb any other reason) In this case we just assume.
Thats why we manually shutdown primary database
ON PRIMARY
Shut abort;
ON STANDBY
This column shows from which SCN number this database become
primary.
Select STANDBY_BECAME_PRIMARY_SCN from v$database;
ON PRIMARY NEW
Shut immediate
Startup
Alter system switch logfile ;
Alter system switch logfile ;
Select status, error from v$archivedest;
Alter system set log_archive_dest_2=defer;
Alter system set log_archive_dest_2=enable;
Alter system switch logfile;
statements
Any Data Definition Language (DDL)
Access of local sequences
DMLs on local temporary tables
Step # 1: Check the status of the Primary database and the latest sequence
generated in the primary database.
INSTANCE_NAME
DATABASE_ROLE
OPEN
lprod
PRIMARY
------------
----------------------------------------
---------------------------------------
40
Step # 2: Check the status of the physical standby database and the latest
sequence applied on the physcial standby database.
SQL> select process,status,sequence# from v$managed_standby;
STATUS
INSTANCE_NAME
DATABASE_ROLE
MOUNTED
lprod
PHYSICAL STANDBY
------------
----------------------------------------
---------------------------------------
40
SEQUENCE#
---------0
0
0
ARCH CONNECTED
RFS
IDLE
RFS
IDLE
RFS
IDLE
RFS
IDLE
MRP0 WAIT_FOR_LOG
9 rows selected.
0
41
0
0
0
41
Here, MRP is active. The PROCESS Column above shows that MRP is active
and is waiting for the log sequence 41.
Step # 4: Cancel the MRP on the physical standby database and open the
standby database. The standby database would be opened in the READ-ONLY
Mode.
INSTANCE_NAME DATABASE_ROLE
OPEN_MODE
-----------
------------------------
---------------
OPEN
--------------------------
lprod
PHYSICAL STANDBY
READ ONLY
STATUS
SEQUENCE#
-----------------
---------------
---------------------
ARCH
ARCH
ARCH
ARCH
RFS
RFS
RFS
RFS
MRP0
9 rows selected.
CONNECTED
CONNECTED
CONNECTED
CONNECTED
IDLE
IDLE
IDLE
IDLE
WAIT_FOR_LOG
0
0
0
0
41
0
0
0
41
Step # 1:
Detail of Primary Database.
INSTANCE_NAME
--------------
-------------------------------
OPEN
lprod
DATABASE_ROLE
OPEN_MODE
-------------------------------
------------------------
PRIMARY
READ WRITE
MAX(SEQUENCE#)
--------------
15
INSTANCE_NAME
DATABASE_ROLE
OPEN_MODE
------------
-------------------------------
-----------------------------
-----------------------
OPEN
lprod
MAX(SEQUENCE#)
------------------
----------------- --------------
15
NO
You can observe that the standby database is in sync with the primary
database. Below outcome shows that the Flash Recovery Area is
configured on the physical standby database.
SQL> show parameter db_recovery_file_dest
NAME
--------------------------db_recovery_file_dest
db_recovery_file_dest_size
TYPE
----------string
big integer
VALUE
------------+FRA_NEW
4122M
Step # 2: Cancel the MRP on the physical standby database and then
shutdown the database and startup mount
1269366784
2227984
805306608
452984832
8847360
bytes
bytes
bytes
bytes
bytes
Step # 4: You can now open the snapshot standby database and check its
mode.
INSTANCE_NAME DATABASE_ROLE
-----------
---------------
OPEN
lprod
----------------
SNAPSHOT
OPEN_MODE
------------------
called SNAPTEST
2. Create a table called TEST whose owner is SNAPTEST and insert some
records in it. You can also update some of the records as well.
SQL> commit;
Commit complete.
NAME
----------------
--------------------
101
201
RAHEEL
REHMAN
SQL> commit;
Commit complete.
NAME
----------------
500
201
--------------------
RAHEEL
REHMAN
In the meantime, you can also see that the redo data from the primary
database is received by the snapshot standby database but would not be
applied.
On primary database the latest sequence generated is 208 and that on the
standby database, the RFS process is idle for sequence 209.
On Primary
MAX(SEQUENCE#)
------------------
--------------
18
On Standby
STATUS
SEQUENCE#
---------------------------
---------------
-----------------------
ARCH
ARCH
ARCH
ARCH
RFS
RFS
RFS
CLOSING
CONNECTED
CONNECTED
CONNECTED
IDLE
IDLE
IDLE
1
0
0
0
0
18
0
7 rows selected.
Step # 3: Once done, bounce the physical standby database and start the
Managed Recovery Process (MRP) on it.
SQL> startup
ORACLE instance started.
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted.
Database opened.
1269366784
2227984
805306608
452984832
8847360
bytes
bytes
bytes
bytes
bytes
INSTANCE_NAME
DATABASE_ROLE
------------
--------------
----------------
OPEN
lprod
PHYSICAL STANDBY
OPEN_MODE
----------------
READ ONLY
MAX(SEQUENCE#)
--------------
21
On Standby database:
MAX(SEQUENCE#)
----------
--------------
21
Step # 3: You can see below that the transactions that were carried out
when the standby database is opened in READ WRITE mode are flushed out
after it was converted back to physical standby database mode.
CONCLUSION
Now Database is successfully Configured.
Perform Testing , Switchover and failover scenarios and with active
dataguard and snapshot standby features..