Installing Oracle EM 12c Agents with EMCLI

Oracle Enterprise Manager Cloud Control 12c introduced several ways to deploy agents to hosts. The Oracle Management Agents are responsible for gathering metrics from targets such as database instances, listeners and the host themselves and sending them to the Oracle Management repository and Server for further processing. It also interacts with targets by executing commands sent via the OMS Console and the EM Command Line Interface (EMCLI).

EM12c release 1 introduced four ways of deploying Management Agents
  1. Add Target Host Wizard - Agents are mass deployed using the Management Console.
  2. AgentPull - Silent install script to automatically download and deploy agents on remote targets using a response file.
  3. agentDeploy - Silent install script to deploy agents using a response file after manually downloading a compressed package of the agent using EMCLI and transferring it to remote targets.
  4. RPM - Use a .rpm package to deploy to targets that support it (Linux x86-64). 
Starting with EM12c release 3 ( agents can now be mass deployed using EMCLI. This enables scripting to ensure rapid and consistent deployment of Management Agents to remote hosts. The third release of EM12c also provides enhanced scripting capability via a Jython interpreter. This is beyond the scope of this article but I hope to discuss this in another post.

In this post I will demonstrate how to deploy Management Agents to a single Linux x86-64 host using EMCLI.
Before installing the agent it should meet all prerequisites as specified in the Oracle Enterprise Manager Cloud Control 12c Installation guide.
To deploy agents we use the EMCLI command with the submit_add_host verb.
emcli submit_add_host
You can find all the options for the command by passing the help verb. 
Note:The output below only shows the mandatory options.
$ emcli help submit_add_host
  emcli submit_add_host
        -host_names="List of host names."
        -platform="Platform id"
        -installation_base_directory="Installation base directory."
        -credential_name="Credential Name"
The syntax requires the host names which is a host or list of hosts to deploy the agents to, platform is the platform id of the host (more about this below), installation base directory is the root path where the agent binaries will be install, credential name is the named credential of the user who will own the binaries on the remote hosts.
To determine the platform id of the target host use emcli with the list_add_host_platforms verb.
emcli list_add_host_platforms -all
Platform ID  Platform Name
226          Linux x86-64
23           Oracle Solaris on SPARC (64-bit) [Agent Software Unavailable]
46           Linux x86 [Agent Software Unavailable]
59           HP-UX PA-RISC (64-bit) [Agent Software Unavailable]
197          HP-UX Itanium [Agent Software Unavailable]
211          IBM S/390 Based Linux (31-bit) [Agent Software Unavailable]
212          IBM AIX on POWER Systems (64-bit) [Agent Software Unavailable]
227          IBM: Linux on POWER Systems [Agent Software Unavailable]
233          Microsoft Windows x64 (64-bit) [Agent Software Unavailable]
267          Oracle Solaris on x86-64 (64-bit) [Agent Software Unavailable]
912          Microsoft Windows (32-bit) [Agent Software Unavailable]
209          IBM: Linux on System z [Agent Software Unavailable]
The output lists the platform id and name of the platforms and indicates whether or not the agent software is available on the OMS for deployment. If the agent software is unavailable you first need to download it using Self-Update in online or offline mode.

Now that we know the platform_id and it's assumed that the host names and base directory is also known, we can deploy the software. It may be a good time to look at all the available options to see if you need to further customize your deployment including changing the agent port, properties or specify whether the deployment is for a fresh install, clone or shared install.
I like to also check which named credentials are available. You can do so using the list_named_credentials verb.
$ emcli list_named_credentials
Credential Name Credential Owner Authenticating Target Type Cred Type Name Target Name Target Username
NC_EM_SFM_ADMIN SYSMAN host HostCreds em_smf_admin
NC_ORACLE SYSMAN host HostCreds oracle
ORACLE_HOST_USER SYSMAN host HostCreds oem5.homenet oracle
With all the mandatory information available the agent can now be deployed.
$ emcli submit_add_host -host_names=db12c01.homenet -platform=226 -installation_base_dir=/u02/oracle/agent12c -credential_name=ORACLE_HOST_USER -session_name="DB12c Add Host"
An Add Host session with the name "DB12c Add Host" has been submitted.
You can track the progress of this session using the command "emcli get_add_host_status -session_name=DB12c Add Host"
The example above will submit a job to deploy an agent to a 64-bit Linux host (platform id 226) to a host name db12c01.homenet. The named credential for the host is ORACLE_HOST_USER. A name for the session was also provided to make it easily identified. Once the job has been submitted you can track its status.
$ emcli get_add_host_status -session_name="DB12c Add Host"
OverAll Status : Initialization in Progress
Host             Platform Name  Initialization  Remote Prerequisite  Agent Deployment  Error
db12c01.homenet  Linux x86-64   In Progress     Not Run              Not Run
All the normal stages of agent deployment will be updated. You can issue the command after a couple minutes to track its status. There's also a -wait_for_completion option that will run the Add Host operation synchronously. However I haven't tested this yet.
$ emcli get_add_host_status -session_name="DB12c Add Host"
OverAll Status : Agent Deployment in Progress
Host             Platform Name  Initialization  Remote Prerequisite  Agent Deployment  Error
db12c01.homenet  Linux x86-64   Succeeded       Succeeded            In Progress

$ emcli get_add_host_status -session_name="DB12c Add Host"
OverAll Status : Agent Deployment Succeeded
Host             Platform Name  Initialization  Remote Prerequisite  Agent Deployment  Error
db12c01.homenet  Linux x86-64   Succeeded       Succeeded            Succeeded
After installation has completed successfully run the $AGENT_HOME/ script if the  -postinstallation_script_run_as_root option was not specified.

In summary we have seen how simple and quick we can deploy agents using using the new EMCLI verb. This should take away some of the drudgery from having to click through multiple screens and lay the framework for creating an automated and repeatable method for managing and monitoring hosts and their dependencies using Oracle Enterprise Manager Cloud Control 12c.


Popular posts from this blog

Viewing ASM trace files and alert logs in Unix/Linux

ORA-00020: maximum number of processes (%s) exceeded

Troubleshooting RAC Public Network Failure