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