1. Home
  2. Knowledge Base
  3. Data Guard
  4. Oracle 12c Release 2 New Feature DGMGRL Scripting

Oracle 12c Release 2 New Feature DGMGRL Scripting

New in Oracle 12c Release 2 is the ability for scripts to be executed through the Data Guard broker DGMGRL command-line interface very similar to like say in SQL*Plus.

DGMGRL commands, SQL commands using the DGMGRL SQL command, and OS commands using the new HOST (or !) capability can be bundled into a script file and executed via the DGMGRL command line.

A worked example of creating a Data Guard Broker environment via a single script is shown below.
 
 


Create Data Guard Broker Configuration 

[oracle@host01 ~]$ vi cre_dgb_config 
connect sys/G#vin2407@amer_sb;
sql "alter system set dg_broker_start=TRUE";
connect sys/G#vin2407@amer;
sql "alter system set dg_broker_start=TRUE";
host sleep 20;
-- #############################################;
-- Creating the Data Guard Broker Configuration;
-- #############################################;
create configuration 'amer_dg' as primary database is 'amer' connect identifier is 'amer';
add database 'amer_dg' as connect identifier is 'amer_dg';
enable configuration;
show database 'amer';
show database 'amer_dg';
-- #############################################;
-- Changing the Protection Level;
-- #############################################;
EDIT DATABASE 'amer' SET PROPERTY 'LogXptMode'='SYNC';
EDIT DATABASE 'amer_sb' SET PROPERTY 'LogXptMode'='SYNC';
EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
show configuration;
-- #############################################;
-- Checking the Data Guard Broker Configuration;
-- #############################################;
show database 'amer' 'InconsistentProperties';
show database 'amer' 'InconsistentLogXptProps';

show configuration;




DGMGRL> @cre_dgb_config
Connected to "amer_dg"
Connected as SYSDBA.
Succeeded.
Connected to "amer"
Connected as SYSDBA.
Succeeded.
Configuration "amer_dg" created with primary database "amer"
Database "amer_dg" added
Enabled.

Database - amer

  Role:               PRIMARY
  Intended State:     TRANSPORT-ON
  Instance(s):
    amer

Database Status:
SUCCESS

Executing operating system command(s):" sleep 10;"

Database - amer_dg

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 1 second ago)
  Apply Lag:          0 seconds (computed 1 second ago)
  Average Apply Rate: 1.00 KByte/s
  Real Time Query:    ON
  Instance(s):
    amer

Database Status:
SUCCESS

Property "LogXptMode" updated
Property "LogXptMode" updated
Succeeded.

Configuration - amer_dg

  Protection Mode: MaxAvailability
  Members:
  amer    - Primary database
    amer_dg - Physical standby database 

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 4 seconds ago)

INCONSISTENT PROPERTIES
   INSTANCE_NAME        PROPERTY_NAME         MEMORY_VALUE         SPFILE_VALUE         BROKER_VALUE 

INCONSISTENT LOG TRANSPORT PROPERTIES
   INSTANCE_NAME         STANDBY_NAME        PROPERTY_NAME         MEMORY_VALUE         BROKER_VALUE 


Configuration - amer_dg

  Protection Mode: MaxAvailability
  Members:
  amer    - Primary database
    amer_dg - Physical standby database 

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 5 seconds ago)

DGMGRL>
Updated on June 2, 2021

Was this article helpful?

Related Articles

Leave a Comment