Configuring Data guard 12cR2 on Linux
Oracle Data Guard is basically a disaster recover solution for enterprises, but also term it as a maximum availability solution.
Oracle Data Guard ensures high availability, data protection, and disaster recovery for enterprise data.
Oracle Data Guard ensures high availability, data protection, and disaster recovery for enterprise data.
Data Guard provides a comprehensive set of services that create, maintain, manage, and monitor one or more standby databases to enable production Oracle databases to survive disasters and data corruptions. Data Guard maintains these standby databases as transactionally consistent copies of the production database. Then, if the production database becomes unavailable because of a planned or an unplanned outage, Data Guard can switch any standby database to the production role, minimizing the downtime associated with the outage. Data Guard can be used with traditional backup, restoration, and cluster techniques to provide a high level of data protection and data availability.
In my current blog, i will show how to configure oracle data guard on linux.
Let's start with machine preparation:
Please follow my above blog link for the installation of 12c DB, while creating the DB, Go with coventional setup of single tenant architecture on primary node, while on standby db machine you need to install software only.
Once the installation is done, lets start preparing the DB for DG:
sqlplus / as sysdba
SELECT LOG_MODE FROM V$DATABASE ;
Or simply
SQL> archive log list;
Convert the database to archive log mode:
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;
Database altered.
Enable the force logging:
SQL>ALTER DATABASE FORCE LOGGING;
ALTER SYSTEM SWITCH LOGFILE;
Add standby by redo log files
ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 10 ('/u01/app/oracle/oradata/DB12C/standby_redo01.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 11 ('/u01/app/oracle/oradata/DB12C/standby_redo02.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 12 ('/u01/app/oracle/oradata/DB12C/standby_redo03.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 13 ('/u01/app/oracle/oradata/DB12C/standby_redo04.log') SIZE 50M;
If you want to use flashback database, enable it on the primary now, so it will be enabled on the standby also. i would recommend you to enable the flash back feature so that we can use advance features of DG broker like database reinstate. It's very useful as you will see below.
ALTER DATABASE FLASHBACK ON;
Initialization Parameters
Check the setting for the DB_NAME and DB_UNIQUE_NAME parameters. In this case they are both set to "cdb1" on the primary database.
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string DB12C
SQL> show parameter db_unique_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string DB12C
SQL>
Setting the standby file management
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;
Now setting up listener file properties and tnsname.ora file
both files can be found @ /u01/app/oracle/product/12.2.0/db12c/network/admin
it is recommended to keep copy of old file before changing any value.
Listener.ora file should be like:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = primary-db)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = DB12C_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0/db12c)
(SID_NAME = DB12C)
)
)
ADR_BASE_LISTENER = /u01/app/oracle
tnsname.ora file should have below enteries:
DB12C =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = primary-db)(PORT = 1521))
)
(CONNECT_DATA =
(SID = DB12C)
)
)
DB12C_STBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = standby-db)(PORT = 1521))
)
(CONNECT_DATA =
(SID = DB12C)
)
)
Once these file are set, stop the listener and start the service again.
check the services set by using tnsping utility, they should be pingable:
So primary DB listener services are all set, now these 2 files should be copy to standby db with same location of primary
scp listener.ora oracle@19*.1**.1.**:/u01/app/oracle/product/12.2.0/db12c/network/admin/
scp tnsname.ora oracle@19*.1**.1.**:/u01/app/oracle/product/12.2.0/db12c/network/admin/
create spfile for standby and having proper changes
CREATE PFILE='/tmp/initDB12C_stby.ora' FROM SPFILE;
Make changes according to your environment:
vi /tmp/initDB12C.stby.ora
*.db_name='DB12C'
*.log_archive_dest_2='SERVICE=db12c ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB12c'
*.fal_server='DB12c'
add/ change these values in pfile created/
now move this pfile to standby DB;
scp initDB12C_stby.ora oracle@19*.1**.1.**:/tmp
Copying the paswordfile of Primary DB to standby DB
scp orapwDB12C oracle@19*.1**.1.**:/u01/app/oracle/product/12.2.0/db12c/dbs/
Primary site is almost ready to go, now lets prepare the standby DB site:
Creating same directory structure on Standby DB
mkdir -p /u01/app/oracle/fast_recovery_area/DB12C
mkdir -p /u01/app/oracle/oradata/DB12C
mkdir -p /u01/app/oracle/admin/DB12C/adump
let's start an auxiliary instance on standby DB:
$ export ORACLE_SID=DB12C
$ sqlplus / as sysdba
SQL> STARTUP NOMOUNT PFILE='/tmp/initDB12C_stby.ora';
once instance has been started now its time to copy the database to standby instance by connecting to RMAN and establing auxiliary connection with standby DB
$ rman TARGET sys/oracle@db12c AUXILIARY sys/oracle@db12c_stby
Now issue the following DUPLICATE command.
DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER
SPFILE
SET db_unique_name='DB12C_stby' COMMENT 'Is standby'
NOFILENAMECHECK;
Once the database copy is completed, now its time to start apply process, in case of manual handling of data guard.
now check the last archive log generated at primary site and confirm the archive log at standby database:
Primary site:
Standby Site:
By default the protection mode will be maximum performance:
Until and unless the DG broker is configured all the operation like protection mode change, Role transition, checking configuration status etc will be done manual.



















































