About Me

I am a Database Administrator with over 13 years of IT experience and my core expertise being Oracle, Oracle Ebusiness Suite and SQL server. Currently I am working as a Database Administrator for Experis US Inc and located in Phoenix, Arizona. I would like to write blogs on whatever I learn on daily basis which might be helpful for others.

Friday, August 2, 2013

Dataguard Maintenance using DGMGRL Commands...Continuation from previous post.

In my earlier post on DG setup using OEM 12c, I have mentioned that the DG Instance have to act as reporting database whole day except for few hours when the DG instance is converted to recovery mode and have the redo logs applied and then converted back to read-only mode.

We have accomplished this through Dataguard Broker (DGMGRL) commands and scheduled them through OEM 12c.

As we were using Windows platform, I created these scripts as a batch program and scheduled them as an EM job and made sure that we will get notifications in case if there are any problems with the job.

Script to convert to recovery mode:

set ORACLE_SID=ASHGBADS
set ORACLE_HOME=<Your Oracle home path>
set PATH=%ORACLE_HOME%\bin;%path%
%ORACLE_HOME%\bin\dgmgrl -silent / "edit database 'ASHGBADS' set state= offline";
%ORACLE_HOME%\bin\dgmgrl -silent / "startup mount;"
ping -w 1000 -n 120 1.1.1.1 > NULL
%ORACLE_HOME%\bin\dgmgrl -silent / "edit database 'ASHGBADS' set state= apply-on;"

I used ping command in the script to introduce a delay (as a equivalent for sleep command) so that the dataguard broker gets started before we run the next command to turn the apply on.

Script to convert to read-only mode:

set ORACLE_SID=ASHGBADS
set ORACLE_HOME=<Your Oracle home path>
set PATH=%ORACLE_HOME%\bin;%path%
%ORACLE_HOME%\bin\dgmgrl -silent / "edit database 'ASHGBADS' set state = read-only;"

No comments:

Post a Comment