This post is about the commands which is used by Oracle DBA during using OEM 12c.

EMCLI – Enterprise Command Line Interface. Though Managing OEM cloud control from GUI is easy. Few people like to use emcli command line tool.

Here I have listed few useful commands.

1. Login to syman

./emcli login -username=SYSMAN

2. SYNC OMS REPOSITORY:

./emcli login -username=SYSMAN
./emcli sync

3. Get THE LIST OF TARGETS

./emcli get_targets

For listing only the oracle_database

./emcli get_targets -targets="oracle_database"

4. Delete a target from OEM cloud control:

./emcli delete_target -name="B2BOMT2" -type="oracle_database"
Target "B2BOMT2:oracle_database" deleted successfully

5. Run autodiscovery on a target host

You can configure autodiscover from GUI also, after a target host is added. Below is for doing using EMCLI

Create a property file:

./emcli describe_job_type -job_type=RunAutoDiscovery > inputs.prop

Update the property file:( It will look as below)

# Description: (Optional) The user specified name of the job
name=AUTO_DISC

# Description: (Optional) The job type for this job
type=RunAutoDiscovery

# Description: (Optional) The user specified description of the job
description=

# Description: The job owner. The job owner is the user who creates the job.
# Default: the logged in user
# The job owner information displayed here is for documentation only and user is not expected to change it.
owner=

# Description: (Optional) The kind of job
# Legal Values: active, library
kind=

# Fill in the target list before submitting.
# For Example:
# target_list=MyTarget:cluster
target_list=172.20.294.137:host

# Description: The type of targets to use for this job
targetType=host

# Description: (Optional) Notify the job owner when a selected state occurs
# Allowed Values: SCHEDULED, RUNNING, ACTION_REQUIRED, SUSPENDED, SUCCEEDED, PROBLEMS
notification=

# Description: (Optional) The run time properties for the job
properties=

Create a job:

./emcli create_job -input_file=property_file:inputs.prop

Creation of job "AUTO_DISC" was successful.
The following properties were not set to any value and were ignored: description, owner, kind, notification, properties

Get the job status:

emcli get_jobs -name=AUTO_DISC
Name Type Job ID Execution ID Scheduled Completed TZ Offset Status Status ID Owner Target Type Target Name
AUTO_DISC RunAutoDiscovery 4A115DB150B74968E0540010E01F328C 4A115DB150BA4968E0540010E01F328C 2017-03-06 17:03:55 none GMT+03:00 Running 2 SYSMAN host 172.20.294.137

Alternatively we can see the execution detail as :

./emcli get_job_execution_detail -execution=4A115DB150BA4968E0540010E01F328C -xml -showOutput
<!--?xml version = '1.0' encoding = 'UTF-8'?-->
emcli get_jobs -name=AUTO_DISC
Name Type Job ID Execution ID Scheduled Completed TZ Offset Status Status ID Owner Target Type Target Name
AUTO_DISC RunAutoDiscovery 4A115DB150B74968E0540010E01F328C 4A115DB150BA4968E0540010E01F328C 2017-03-06 17:03:55 2017-03-06 17:05:22 GMT+03:00 Succeeded 5 SYSMAN host 172.20.204.137

6 . Add target database to OEM cloud:

SYNTAX:

./emcli add_target -name=”ORACLE_SID” -type=”oracle_database” -host=”$oemhost” -credentials=”UserName:dbsnmp;password:dbsnmp_password;Role:Normal” -properties=”SID:ORACLE_SID;Port:1521;OracleHome:;MachineName:\”

7. Get list of plugins installed on OMS server:

./emcli list_plugins_on_server

OMS name is dbadev64.dba.com.sa:4889_Management_Service
Plug-in Name Plugin-id Version [revision]

Oracle Audit Vault oracle.em.soav 12.1.0.4.0
Oracle GoldenGate oracle.fmw.gg 13.1.1.0.0
Oracle Cloud Framework oracle.sysman.cfw 13.2.1.0.0
Oracle Database oracle.sysman.db 13.2.1.0.0
Oracle Fusion Middleware oracle.sysman.emas 13.2.1.0.0
Oracle Fusion Applications oracle.sysman.emfa 13.2.1.0.0
Oracle Siebel oracle.sysman.empa 13.1.1.0.0
Oracle ORAchk Healthchecks oracle.sysman.orhc 13.1.1.0.0
Systems Infrastructure oracle.sysman.si 13.2.1.0.0
Oracle Exadata oracle.sysman.xa 13.2.1.0.0

8 . Get list of plugins installed on a Management Agent:

./emcli list_plugins_on_agent -agent_names="172.25.224.2:3872"
The Agent URL is https://172.20.204.2:3872/emd/main/ -
Plug-in Name Plugin-id Version [revision]

Oracle Home oracle.sysman.oh 13.2.0.0.0
Oracle Database oracle.sysman.db 13.2.1.0.0

9 . Create BLACKOUT:

Creating blackout for single database

DBNAME – DBATEST
BLACKOUT DUATION – 30 MIN
SCHEDULE- START IMMEDIATELY
./emcli create_blackout -name="db_blackout_phase1" -reason="patching" -add_targets="DBATEST:oracle_database" -schedule="duration:30"
Blackout "db_blackout_phase1" created successfully

For multiple databases:
DB NAME – DBATEST1,DBATEST2

emcli create_blackout -name="DBACLASS_MULTDB_BLACKOUT" -reason="psu patchcing" -add_targets="DBATEST1:oracle_database;DBATEST2:oracle_database" -schedule="duration:30"

Create blackout for a host(target agent) and all this services/database runnin on that server

TARGET AGENT HOST – localhost.dbaclass.com
DURATIO – 30 MIN
START IMMEDIATELY

./emcli create_blackout -name="DBACLASS_HOST_BLACKOUT" -reason="OS PATCHING OUTAGE" -add_targets="localhost.dbaclass.com:host" -schedule="duration:60" -propagate_targets
Blackout "DBACLASS_HOST_BLACKOUT" created successfully

Get status of a blackout:

SYNTAX

./emcli get_blackout_details -name="BLACK_OUT_NAME"

EXAMPLE:

./emcli get_blackout_details -name="db_blackout_phase1"

Stop a BLACKOUT:

./emcli stop_blackout -name="db_blackout_phase1"
Blackout "db_blackout_phase1" stopped successfully

Delete a blackout:

./emcli delete_blackout -name="db_blackout_phase1"
Blackout "db_blackout_phase1" deleted successfully

10 . Decommission an agent and delete the respective targets:

./emcli delete_target -name="dbahost-local:3872" -type="oracle_emd" -delete_monitored_targets

Target "dbahost-local:3872:oracle_emd" deleted successfully

11. Stop and start an agent from OMS server

STOP AN AGENT:

/data/app/oracle/oms13c/bin$ ./emcli stop_agent -agent_name="dbahost-local:3872" -host_username=oracle
Host User password:
The Shut Down operation is in progress for the Agent: dbahost-local:3872
The Agent "dbahost-local:3872" has been stopped successfully.
---------------------
Operation Output
---------------------
Oracle Enterprise Manager Cloud Control 13c Release 2
Copyright (c) 1996, 2016 Oracle Corporation. All rights reserved.Stopping agent ... stopped.

START AN AGENT:

./emcli start_agent -agent_name="dbahost-local:3872" -host_username=oracle
Host User password:
The Start Up operation is in progress for the Agent: dbahost-local:3872
The Agent "dbahost-local:3872" has been started successfully.
---------------------
Operation Output
---------------------
Oracle Enterprise Manager Cloud Control 13c Release 2
Copyright (c) 1996, 2016 Oracle Corporation. All rights reserved.Starting agent ..................................... started.

12. Change password for dbsnmp user of target database

This will prompt for old password and new password.

./emcli update_db_password -target_name="B2CCRMT2" -target_type="oracle_database" -user_name="dbsnmp" -change_at_target=yes

Enter value for old_password :
Enter value for new_password :
Enter value for retype_new_password :
Successfully submitted a job to change the password in Enterprise Manager and on the target database: "B2CCRMT2"

Execute “emcli get_jobs -job_id=50A66C2EF0EB6E7AE0540010E01F328C” to check the status of the job.
Search for job name “CHANGE_PWD_JOB_1496046676449” on the Jobs home page to check job execution details.

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Skant Gupta’s LinkedIn: www.linkedin.com/in/skantali/

Joel Perez’s LinkedIn: www.linkedin.com/in/SirDBaaSJoelPerez

Anuradha’s LinkedIn: https://www.linkedin.com/in/dbaanuradhamudgal/

LinkedIn Group: Oracle Cloud DBAAS

Facebook Page: OracleHelp

About The Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.