Top Banner
11gR2 Physical Data Guard Setup project, with Active Data Guard option www.oracle-class.com The purpose of this document is to create a step by step guideline for using the Oracle Data Guard a High available mechanism. The Oracle version is 11gR2. We will first introduce to you the Oracle Data Guard. We will define the requirements for this demonstration. We will create 2 windows virtual machines using Oracle virtual Box. Then, We will set up the Primary database. After that, we will use Recovery Manager RMAN to create the Standby database, and, we will check the Data Guard environment. In the end, we will turn on the Active Data Guard option, new with 11g. 1- What is Oracle Data Guard? The primary database is the production database, and the standby database is the remote, secondary database. Oracle Data Guard is an option to the Oracle RDBMS. It maintains a standby database as an alternative database to primary database. In the event of failure, the standby database can be activated and assume the primary database role. Oracle physical standby protects from user and logical errors by maintaining consistent copies of redo data of the primary database at the standby database. The Oracle physical standby database is kept synchronized with the primary database by using media recovery to apply redo data that was generated on the primary database (REDO APPLY). The Oracle logical standby database is kept synchronized with the primary database by using media recovery to apply redo data into SQL statements and then executing those SQL statements against the standby database (SQL APPLY). 2- Set up of windows virtual machines - Download Virtual Box: Download the last version from Virtualbox.org - Use the official manual to install Virtual Box Manual - OS Names: "oradg2" for the Primary database and "oradg3" for the Standby database. - OS type: windows xp (32 bit) - Virtual Memory: 512Mb for each virtual machine. - Host Memory: 2GB. - Hard Drive: 20GB for each virtual machine. Wissem EL KHLIFI www.oracle-class.com
26
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

11gR2 Physical Data Guard Setup project, with Active Data Guard option

www.orac le-c lass .com

The purpose of this document is to create a step by step guideline for using the Oracle Data Guard a High available mechanism.The Oracle version is 11gR2.We will first introduce to you the Oracle Data Guard. We will define the requirements for this demonstration.We will create 2 windows virtual machines using Oracle virtual Box. Then, We will set up the Primary database.After that, we will use Recovery Manager RMAN to create the Standby database, and, we will check the Data Guard environment.In the end, we will turn on the Active Data Guard option, new with 11g.

1 - What is Orac le Data Guard?

The primary database is the production database, and the standby database is the remote, secondary database.Oracle Data Guard is an option to the Oracle RDBMS. It maintains a standby database as an alternative database to primary database.In the event of failure, the standby database can be activated and assume the primary database role.

Oracle physical standby protects from user and logical errors by maintaining consistent copies of redo data of the primary database at the standby database.The Oracle physical standby database is kept synchronized with the primary database by using media recovery to apply redo data that was generated on the primary database (REDO APPLY).The Oracle logical standby database is kept synchronized with the primary database by using media recovery to apply redo data into SQL statements and then executing those SQL statements against the standby database (SQL APPLY).

2- Set up of w indows v i r tua l mach ines

- Download Virtual Box: Download the last version from Virtualbox.org- Use the official manual to install Virtual Box Manual- OS Names: "oradg2" for the Primary database and "oradg3" for the Standby database.- OS type: windows xp (32 bit)- Virtual Memory: 512Mb for each virtual machine.- Host Memory: 2GB.- Hard Drive: 20GB for each virtual machine.

Wissem EL KHLIFI www.oracle-class.com

Page 2: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

Wissem EL KHLIFI www.oracle-class.com

Page 3: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

- Set up the network connectivity:

Ping the Standby server from the Primary server:

Wissem EL KHLIFI www.oracle-class.com

Page 4: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

Ping the Primary server from the Standby server:

Wissem EL KHLIFI www.oracle-class.com

Page 5: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

- Download and install Oracle 11gR2 (32 bit) for windows:+Install binaries.+Install the database, Enterprise edition. (using DBCA)+Set up Oracle net components (using NETCA)+Test sql net connectivity.

3 - Pre requ is i tes

- The primary and standby databases must be using the same version of Oracle Database 11g. In our case, we are using 11gR2.

- The primary database must be opened in ARCHIVELOG mode.

Wissem EL KHLIFI www.oracle-class.com

Page 6: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

– Oracle Net Services network files must be set up on the primary database and on the standby database.

Wissem EL KHLIFI www.oracle-class.com

Page 7: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

SQLNET.ORA f i le o f the Pr imary :

TNSNAMES.ORA f i le o f the Pr imary :

Wissem EL KHLIFI www.oracle-class.com

Page 8: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

L ISTENER.ORA f i le of the Pr imary:

SQLNET.ORA f i le o f the Standby:

Wissem EL KHLIFI www.oracle-class.com

Page 9: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

TNSNAMES.ORA f i le o f the Standby :

Wissem EL KHLIFI www.oracle-class.com

Page 10: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

L ISTENER.ORA f i le of the Standby :

You can use "tnsping" to test the sql connectivity:

Wissem EL KHLIFI www.oracle-class.com

Page 11: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

4- Setup o f the Pr imary database

- Host name: oradg2- Database type: Primary- DB_UNIQUE_NAME=ORAWI1 1G32- TNS Alias: BARCELONA- Create the password file.

Wissem EL KHLIFI www.oracle-class.com

Page 12: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

- Create standby redo logs (Number of Standby redo log files=(maximum number of log files for each thread + 1) * maximum number of threads ), in our case 4 SRL.

Wissem EL KHLIFI www.oracle-class.com

Page 13: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

- Enable force logging (Optional)

- Configure the pfile of the primary. The content should have the content below;

Wissem EL KHLIFI www.oracle-class.com

Page 14: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

- Shut down the primary database with shutdown immediate command.- Create the spfile from the pfile and startup the Primary database.

5- Setup o f the Secondary database

- Host name: oradg3- Database type: Physical standby- DB_UNIQUE_NAME=ORADG3- TNS Alias: MADRID- Copy the password file of the primary to the standby database.

- Create the directory files in the standby database.- Create an initialization parameter file with only one parameter DB_NAME. DB_NAME=ORADG3

Wissem EL KHLIFI www.oracle-class.com

Page 15: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

- Start up no mount the database using the pfile.

- Run RMAN duplicate script on the primary.

Wissem EL KHLIFI www.oracle-class.com

Page 16: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

You can use the content below;

Wissem EL KHLIFI www.oracle-class.com

Page 17: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

Wissem EL KHLIFI www.oracle-class.com

Page 18: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

6- Ver i f y the log sh ipp ing and the app l ica t ion

We are going to include these tests:

Wissem EL KHLIFI www.oracle-class.com

Page 19: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

- Query the v$database, v$logfile and v$datafile in the standby database.

- Check v$archive_dest in both the primary and standby database. The status must be valid for destination ids 1 and 2.

Wissem EL KHLIFI www.oracle-class.com

Page 20: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

The status of the archives destinations in the Primary:

The status of the archives destinations in the Standby:

Wissem EL KHLIFI www.oracle-class.com

Page 21: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

- Check the content of the view v$managed_standby in the standby database.

- Check v$archived_log.

Wissem EL KHLIFI www.oracle-class.com

Page 22: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

- Create a test table in the primary. then, put the standby database into recover managed standby and check if the table will be shown in the standby database..

Wissem EL KHLIFI www.oracle-class.com

Page 23: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

7- Act ive Data Guard opt ion

Oracle Active Data Guard is a new option with Oracle 11g.Oracle Active Data Guard enables read-only access to a physical standby database for queries, sorting, reporting, Web-based access, and so on, while continuously applying changes received from the production database.

The steps below, to activate the option:

1-Cancel the manager recoveryRecover managed standby database cancel;2-Open the database in read-only modeAlter database open read only;3- Restart the Redo applyRecovery managed standby database disconnect using current logfile;

- Create database user test in the primary.- v$dataguard_stats dynamic view.- Test.

So, in the Primary database we create a new user named orawiss and create a table named test_dg_wiss in orawiss schema.We insert 242 records into the test_dg_wiss table.We check that the table is not available in the Standby database (See below).

Wissem EL KHLIFI www.oracle-class.com

Page 24: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

shutdown ;startup mount;alter database open read only;recover managed standby database cancel;recovery managed standby database disconnect using current logfile;select count(*) from orawiss.test_dg_wiss;=> we have 242 rows.

Wissem EL KHLIFI www.oracle-class.com

Page 25: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

Now, we insert more rows into the table orawiss.test_dg_wiss in the Primary database, see below;

Without apply a log switch, the data are there in the Standby database(read only mode), we count the number of rows

Wissem EL KHLIFI www.oracle-class.com

Page 26: 11gR2 Physical Data Guard Setup Project, With Active Data Guard Option

in orawiss.test_dg_wissand we find the 342 records.

8- Summary

In this article;- We have created a physical standby database using RMAN.- We checked the Data Guard health using dynamic views.- We turn on and tested the active Data Guard option.

Please refer to my other article "Step by step creation of physical standby database in 10gR2", following the link below:"Step by step creation of physical standby database in 10gR2"

Wissem EL KHLIFI www.oracle-class.com