You are on page 1of 12

Oracle 11g Active Data Guard using (RMAN)

Oracle Database 11g Active Standby Database


Creation using RMAN
PRIMARY SIDE: (Information)

Machine IP: 192.168.1.98


Machine Name: prim
Database name (db_name): prim
Database Unique Name (db_unique_name): prim
TNS Service Name: stand(Through this service, the primary machine will be
connected to STANDBY machine)

STANDBY SIDE: (Information)


Machine IP: 192.168.1.99
Machine Name: stand
Database name (db_name): stand
Database Unique Name (db_unique_name): stand
TNS Service Name: prim (Through this service, the standby machine will be
connected to PRIMARY machine)

CONFIGURATION ON PRIMARY SITE: Step1:


Create pfile from spfile on the primary database:
SQL>create pfile from spfile;
Step2:
Add following settings in the pfile on the PRIMARY side.
DB_UNIQUE_NAME='primary'
FAL_Client='primary'
FAL_Server='standby'
LOG_ARCHIVE_CONFIG=
'DG_CONFIG= (primary, standby)'
standby_file_management=auto
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_DEST_1=
'LOCATION=USE_DB_RECOVERY_FILE_DEST
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=primary'
LOG_ARCHIVE_DEST_2=
'SERVICE=standby LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=standby'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE

Service_names='primary'

Sample Image of primary PFILE.

Step3:
Create password file using Shell prompt.
[oracle@linux1~]$ orapwd file=orapwprim password=manager entries=5
force=y ignorecase=y
Step4:
SQL>startup mount;
Step5:
Take the Primary database to Archive Log Mode.
SQL>alter database archiveLog;
Enable Force Logging.
SQL>alter database force logging;

Now shutdown the database:


SQL>shutdown immediate;
Now startup the database:
SQL>startup;

Step6:
Now add standby Redo Log group to the PRIMARY site.
SQL>Alter database add standby group 5
(/u01/radha/prim/stand01.log,/u01/radha/prim/stand02.log) size 100m;

Step7:
Startup the database from pfile.
SQL>startup pfile;
Create spfile from pfile to startup the database with spfile.
It is necessary for primary database to use spfile in a dataguard environment.
SQL>Create spfile from pfile;
Now bounce the DB to take affect of new parameter from pfile.
Step8:

Restart the database


SQL> shut immediate;
SQL> startup;
Step9:
Configure tnsnames.ora on both servers to hold entries for both databases.
Now on PRIMARY site create following services in TNSnames.ora file. This file
will be use on standby site also.
While createing Listener use NETMGR utility.
# tnsnames.ora Network Configuration File:
/u01/radha/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
This is primary side TNS and Listener file image.

Note: This tnsnames.ora will be used on both side of dataguard env.


Step10:
Listener.ora for Standby Site.
# Generated by Oracle configuration tools.
Standby side TNS and Listener Details Image.

Step11:

Now check the TNS and Listener for Both side Primary and
Standby side
Primary side listener and TNS status

Standby side status of tns and listener

CONFIGURATION ON STANDBY SITE:Step1:

Create following directories on target standby


mkdir -p /u01/gopi/stand
mkdir -p /u01/gopi/stand/FRA
mkdir -p //u01/gopi/stand/
Step2:

Create pfile for standby.


The sample image pfile of standby.

Step3:

Start database using above created pfile


SQL>startup nomount pfile.
Step4:
Create password file using Shell prompt.
[oracle@linux1~]$ orapwd file=oeapwstand password=oracle entries=5
force=y ignorecase=y
Step5:
We can user any one command to connect RMAN

1.Use this command to connect to rman on primary side


rman target sys/manager auxiliary sys/manager@stand
2.Use this command to connect to rman on standby side
rman target sys/manager@prim auxiliary sys/manager
Step6:

Run following script in rman prompt to create standby database using


rman

RMAN>
duplicate target database for standby from active database

The above command will create standby database.

Check Standby Archive Destination

Run following command at primary site to check archive dest_1 for standby .
select status, error from v$archive_dest where dest_id=2;
On PRIMARY site enable Log_archive_dest_state_2 to start shipping archived redo logs.
SQL>Alter system set Log_archive_dest_state_2=ENABLE scope=both;

Start Apply Process


Start the apply process on standby server.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
If you need to cancel the apply process, issue the following command.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
If you prefer, you can set a delay between the arrival of the archived redo log and it being
applied on the standby server using the following commands.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Read-Only Standby and Active Data Guard

Once a standby database is configured, it can be opened in read-only mode to allow query
access. This is often used to offload reporting to the standby server, thereby freeing up
resources on the primary server. When open in read-only mode, archive log shipping
continues, but managed recovery is stopped, so the standby database becomes increasingly
out of date until managed recovery is resumed.
To switch the standby database into read-only mode, do the following.
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE OPEN READ ONLY;
To resume managed recovery, do the following.
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM
SESSION;
In 11g, Oracle introduced the Active Data Guard feature. This allows the standby database
to be open in read-only mode, but still apply redo information. This means a standby can be
available for querying, yet still be up to date. There are licensing implications for this
feature, but the following commands show how active data guard can be enabled.
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE OPEN READ ONLY;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM
SESSION;

Since managed recovery continues with active data guard,


there is no need to switch back to managed recovery from
read-only mode in this case.

Step1:
Cancel the manager recovery.
SQL> recover managed standby database cancel;
Media recovery complete.
Step2:
Open the database in read-only mode.
SQL> alter database open read only;
Database altered.
Step3:
Restarts the Redo apply.
SQL> recover managed standby database disconnect using current logfile;
Media recovery complete.
------------------------------------------------------------------------------------------------------------------------------#######################################################
########################

Active Data Guard Testing:


create one user and table under the primary side and check in the Standbby side.
And add the details in the table on primary side and check the changes in the
standby side.
Primary side user adding

Standby side user login checking image

The final result image of primary and standby


Primary
standby

Protection Mode:

There are three protection modes for the primary database:

Maximum Availability: Transactions on the primary do not commit until redo


information has been written to the online redo log and the standby redo logs of at
least one standby location. If no standby location is available, it acts in the same
manner as maximum performance mode until a standby becomes available again.

Maximum Performance: Transactions on the primary commit as soon as redo


information has been written to the online redo log. Transfer of redo information to
the standby server is asynchronous, so it does not impact on performance of the
primary.

Maximum Protection: Transactions on the primary do not commit until redo


information has been written to the online redo log and the standby redo logs of at

least one standby location. If not suitable standby location is available, the primary
database shuts down.
By default, for a newly created standby database, the primary database is in maximum
performance mode.
SELECT protection_mode FROM v$database;
PROTECTION_MODE
-------------------MAXIMUM PERFORMANCE
SQL>
The mode can be switched using the following commands. Note the alterations in the redo
transport attributes.
-- Maximum Availability.
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=standby AFFIRM SYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STANDBY';
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE AVAILABILITY;
-- Maximum Performance.
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=standby NOAFFIRM ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STANDBY';
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;
-- Maximum Protection.
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=standby AFFIRM SYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STANDBY';
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PROTECTION;
ALTER DATABASE OPEN;

You might also like