Installing EMCLI in EM12c

EMCLI is a Java based Command Line Interface that can be used to communicate with your OMS (Oracle Management Server) as an alternative to the GUI for some operations.

Installation is pretty straight forward, and the toolkit can be installed anywhere as long as you have a Java JDK installed (1.6 or higher at the time of writing this) and access to the OMS host.

In this post, I’m using an existing Oracle Management Agent’s home on a Linux machine for the JDK path, and base for the EMCLI installation files, but I’ll also briefly mention how you might do the same from a Windows environment…

First off, download the emclikit.jar from your OMS installation, for example:

https://linux01.vbox:7801/em/console/emcli/download

…or SCP the file from your OMS host over to where you want to install EMCLI:

scp /u01/app/oracle/middleware/oms12c/oms/sysman/jlib/emclikit.jar oracle@linux02:/tmp

Then copy the emclikit.jar file to $AGENT_HOME/sysman/jlib, and setup your environment:

export AGENT_BASE=/u01/app/oracle/product/agent12c
export AGENT_HOME=$AGENT_BASE/core/12.1.0.2.0
export JAVA_HOME=$AGENT_HOME/jdk
export PATH=$JAVA_HOME/bin:$PATH
export EMCLI_BASE=/u01/app/oracle/product/emcli

mkdir $EMCLI_BASE
cp /tmp/emclikit.jar $AGENT_HOME/sysman/jlib

Install the EMCLI toolkit:

java -jar $AGENT_HOME/sysman/jlib/emclikit.jar client -install_dir=$EMCLI_BASE

EM CLI client-side install completed successfully.

Setup EMCLI using an appropriate user (it doesn’t have to be SYSMAN) :

$EMCLI_BASE/emcli setup -url=https://linux01.vbox:7801/em -username=sysman -trustall -autologin

Enter password
Emcli setup successful

The last two flags used in the setup command above are optional.  The trustall flag automatically accepts prompts for trusting the certificate chain, otherwise the setup will just prompt you.  The autologin flag allows EMCLI to re-establish a connection to your OMS without prompting you for a password.  I prefer this option, but some would say it’s insecure…I guess it depends on your environment really.

Once you see “Emcli setup successful” as above, you’re all done!

Running the following command will confirm the setup configuration and status:

$EMCLI_BASE/emcli status
Oracle Enterprise Manager Cloud Control 12c Release 2.
Copyright (c) 1996, 2012 Oracle Corporation and/or its affiliates. All rights reserved.

Instance Home          : /home/oracle/.emcli
Verb Jars Home         : /home/oracle/.emcli
Status                 : Configured
EMCLI Home             : /u01/app/oracle/product/agent12c/emcli
EMCLI Version          : 12.1.0.2.0
Java Home              : /u01/app/oracle/product/agent12c/core/12.1.0.2.0/jdk/jre
Java Version           : 1.6.0.12
Log file               : /home/oracle/.emcli/.emcli.log
EM URL                 : https://linux01.vbox:7801/em
EM user                : sysman
Auto login             : true
Trust all certificates : true

NOTE: It’s important that you use the Fully Qualified Domain Name (FQDN) of your OMS host here, otherwise you could hit issues such as the “Session expired. Run emcli login to establish a session.” bug mentioned in MOS 10625373.

If you didn’t chose the autologin option earlier on, simply run the following to establish a connection:

$EMCLI_BASE/emcli login -username=sysman -password=******
Login successful

…and to logout…

$EMCLI_BASE/emcli logout 
Logout successful

This command is useful for checking the status of a specific target or targets (target type is based on EM12c internal name):

$EMCLI_BASE/emcli get_targets -targets="EMREP:oracle_database;LISTENER_EMREP:oracle_listener"

Status  Status           Target Type           Target Name
 ID
1       Up               oracle_database       EMREP
1       Up               oracle_listener       LISTENER_EMREP

In a Windows environment (perhaps your desktop), you might setup your environment like so from the command prompt:

cd c:\oracle\emcli
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_25
set PATH=%JAVA_HOME%/bin:%PATH%

java -jar emclikit.jar client -install_dir=C:\oracle\emcli
emcli setup -url=https://linux01.vbox:7801/em -username=sysman -trustall -autologin

 

Leave a comment

Your email address will not be published.