Blog | Pythian

How to Use EM CLI to Verify Data Guard Configurations | Official Pythian®® Blog

Written by Michael Dinh | Jul 22, 2021 4:00:00 AM

EM CLI (Enterprise Manager Command Line Interface) allows users to access Enterprise Manager functionality from the operating system instead of from a browser.

Why Use EM CLI Instead of a Browser GUI?

It’s more efficient to execute commands from the operating system rather than navigating through various menus and dropdowns. Also, for large deployments consisting of 100+ databases across many hosts, using a GUI may not be efficient nor scalable.

Syntax and Configuration for Data Guard Verification

Here’s the basic syntax for using EM CLI to verify Data Guard configuration as per the official documentation:

emcli dg_verify_config       -primary_target_name="<primary target name>"       -primary_target_type="oracle_database|rac_database"         [-primary_db_creds_name="<primary database credential name>"]        [-primary_host_creds_name="<primary database host credential name>"]         [-reset_inconsistent_props="broker|database"]       [-create_srls]        [-verify_only] 

Step-by-Step Demonstration: Verifying Config and Creating SRLs

Next, I’ll demonstrate how EM CLI not only verifies Data Guard configuration, but also creates missing standby redo logs (SRLs).

1. Environment Preparation and Login

First, verify the version and establish a session with the Oracle Management Server (OMS).

--- The version of emcli is 13.4.0.0.0 [oracle@emhost ~]$ $OMS_HOME/bin/emcli version Oracle Enterprise Manager 13c EM CLI Version 13.4.0.0.0  --- Login to Enterprise Manager as sysman [oracle@emhost ~]$ $OMS_HOME/bin/emcli login -username=sysman Enter password : Login successful  --- Synchronize the EM CLI client with an OMS [oracle@emhost ~]$ $OMS_HOME/bin/emcli sync Synchronized successfully 

2. Identifying Target Databases

Locate the primary and standby targets. Note that if a target has a domain associated with it, you may encounter a known bug.

--- Find Primary and Standby targets [oracle@emhost bin]$ ./emcli get_targets -targets=rac_database -format=name:csv | grep XXXXXXX 1,Up,rac_database,XXXXXXX_PHOENIX 1,Up,rac_database,XXXXXXX_SYDNEY 

3. Executing the Verification and SRL Creation

Run the verification command with the -create_srls flag to automate the fix for any missing logs.

--- Verify Data Guard configurations and Create missing SRLS  [oracle@emhost bin]$ ./emcli dg_verify_config -primary_target_name="XXXXXXX_SYDNEY" -primary_target_type="rac_database" -create_srls Parsing command line arguments... Verify Data Guard Configuration procedure VERIFY_DG_CONFIG_20210526091058954 has been submitted for primary database XXXXXXX_SYDNEY. 

4. Monitoring Execution Status

Check the progress of the submitted job using the procedure name provided in the previous step.

--- Check status using procedure name [oracle@emhost bin]$ ./emcli get_instances | grep -B1 VERIFY_DG_CONFIG_20210526091058954 GUID                              Execution GUID                    Type  Name                                Status     Owner   Instance Status C32FCFCACD2E2650E05317279D0A7830  C32FCFCACD312650E05317279D0A7830  HA    VERIFY_DG_CONFIG_20210526091058954  Succeeded  SYSMAN  Succeeded 

Reviewing Verification Results

After the status shows "Succeeded," use the GUID to review the detailed output, including protection modes and agent status.

[oracle@emhost bin]$ ./emcli get_instance_status -instance=C32FCFCACD2E2650E05317279D0A7830 -xml -details -showJobOutput | grep -B50 "Data Guard configuration verification complete."  Data Protection Settings:   Protection mode : Maximum Performance   Redo Transport Mode settings:     XXXXXXX_PHOENIX: ASYNC     XXXXXXX_SYDNEY: ASYNC    Checking standby redo log files.....Done    (Standby redo log files needed : 4)  Checking Data Guard status   XXXXXXX_PHOENIX : Normal   XXXXXXX_SYDNEY : Normal ... --- SRLS created: Successfully created the required standby redo log files for all databases. Successfully resolved the issues detected during verification. Data Guard configuration verification complete. 

Conclusion

In conclusion, it may be more efficient to use EM CLI to verify Data Guard configurations. It’s also possible to query the OEM repository to generate emcli dg_verify_config statements automatically, saving a lot of time and allowing you to automate and process their output periodically.

Oracle Database Consulting Services

Ready to optimize your Oracle Database for the future?