Looking for something? Try here..

Thursday, June 18, 2020

Enterprise Manager Cloud Control Agent deinstall steps

We have different methods where we can deinstall an OEM Agent. We will see the easiest way of them. First the graphical way of agent decommission introduced in version 12.1.0.4 and above and the silent method which is very easy to perform. The agent we are going to deinstall in this post of version 12.1.0.5. You can get the version as below and the Agent base location where all files reside
-sh-4.2$ /oracle/em_agent12/core/12.1.0.5.0/bin/emctl getversion agent
Oracle Enterprise Manager Cloud Control 12c Release 5
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
       Oracle Enterprise Manager Cloud Control Agent 12c Release 5
-sh-4.2$
-sh-4.2$
-sh-4.2$ pwd
/oracle/em_agent12
-sh-4.2$ ls -lrt
total 16
-rw-rw-r--. 1 oraoem dba  178 Jun 11  2015 agentimage.properties
-rwxr-xr-x. 1 oraoem dba  223 Nov 12  2018 plugins.txt
drwxr-xr-x. 3 oraoem dba   24 Nov 12  2018 core
-rw-r--r--. 1 oraoem dba  298 Nov 12  2018 plugins.txt.status
drwxr-xr-x. 8 oraoem dba 4096 Nov 13  2018 plugins
drwxr-xr-x. 5 oraoem dba  246 Nov  7  2019 sbin
drwxr-xr-x. 7 oraoem dba   74 Apr 11 03:42 agent_inst
-sh-4.2$

Decommmision Agent from OMS

First let’s see how to decommision the agent from within the OMS. Though the method is for 12c, it will be applicable to 13c OEM as well but with different page look.

Go to Setup =>> Manage Cloud Control =>> Agents


This would land you up in the below page where you are going to click on the server you need to decommission the agent.


I do click on the highlighted server (Name).

To decommission an agent the agent must be stopped. So once you land on the agent home page you can stop the agent by following the below.

Agent =>> Control =>> Shutdown


The next step is to provide the host credential to the server where you are trying to decommission the Agent. If you have already stored a named credential, you can choose it and proceed with clicking Shut Down button. You can also provide credentials (Username and Password) by clicking New credentials like I do as below

The following screens will appear to confirm agent shutdown.


You can then click on close and proceed to next step of decommission agent.

The following pics illustrate the Agent decommission steps
Agent =>> Target Setup =>> Click Agent Decommission... =>> Click Continue =>> Click Continue =>> Click Ok



Once the agent has been decommissioned, you will get the following confirmation in the OMS home page.


Decommmision Agent from OMS using command line

All the above can also be achieved by issuing commands in the OMS server which is the simplest way as you just need to find the agent from OMS and use emcli verbs to do the job as below.
Note: Agent on target host has to be down before we proceed with decommission

On Target Host: 
-sh-4.2$ ./emctl stop agent
Oracle Enterprise Manager Cloud Control 12c Release 5
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
Stopping agent ..... stopped.
-sh-4.2$
On OMS server:
-sh-4.2$ emcli login -username=xxxx
Enter password :

Login successful
-sh-4.2$ emcli sync
Synchronized successfully
-sh-4.2$ emcli get_targets -target='oracle_emd' |grep xxxxx
4       Agent Unreachab  oracle_emd            xxxxx:3872
-sh-4.2$
-sh-4.2$
-sh-4.2$ emcli delete_target -name="xxxxx:3872" -type="oracle_emd" -delete_monitored_targets
Target "xxxxx:3872:oracle_emd" deleted successfully
-sh-4.2$
We can see that the agent is in "Agent Unreachable" state (line 8) as we already shutdown the agent in the target host.
Now use the delete_target verb (line 11) to delete all the monitored targets and to decommission the agent from the OMS.

Proceeding with Agent deinstall..

Now as we have decommissioned the Agent and its target from the OMS, we have 2 choice left
1. Either leave the agent software untouched so we can use it later if required or
2. Complete the deinstallation as below.

Steps are explained followed by actual commands in action.

1. Set AGENT home and AGENT instance home environment variables (lines 2,3)
2. List current plugins the agent installation contains and also create a plugin file which can be used later if you intend to reinstall the agent and use it with same or another OMS (lines 4, 15)
3. Make a copy of plugin file if you may need later (line 27)
4. Deinstall the agent using AgentDeinstall.pl script. (line 28)
-sh-4.2$
-sh-4.2$ export AGENT_HOME=/oracle/em_agent12/core/12.1.0.5.0
-sh-4.2$ export AGENT_INSTANCE_HOME=/oracle/em_agent12/agent_inst
-sh-4.2$ $AGENT_INSTANCE_HOME/bin/emctl listplugins agent -type all
Oracle Enterprise Manager Cloud Control 12c Release 5
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
---------------------------------------------------------------
oracle.sysman.oh    12.1.0.5.0           /oracle/em_agent12/plugins/oracle.sysman.oh.agent.plugin_12.1.0.5.0
oracle.sysman.db    12.1.0.8.0           /oracle/em_agent12/plugins/oracle.sysman.db.agent.plugin_12.1.0.8.0
oracle.sysman.xa    12.1.0.6.0           /oracle/em_agent12/plugins/oracle.sysman.xa.discovery.plugin_12.1.0.6.0
oracle.sysman.db    12.1.0.8.0           /oracle/em_agent12/plugins/oracle.sysman.db.discovery.plugin_12.1.0.8.0
oracle.sysman.emas  12.1.0.8.0           /oracle/em_agent12/plugins/oracle.sysman.emas.discovery.plugin_12.1.0.8.0
oracle.sysman.oh    12.1.0.5.0           /oracle/em_agent12/plugins/oracle.sysman.oh.discovery.plugin_12.1.0.5.0

-sh-4.2$ $AGENT_HOME/perl/bin/perl $AGENT_HOME/sysman/install/create_plugin_list.pl -instancehome $AGENT_INSTANCE_HOME
The agent Base Dir is /oracle/em_agent12
 Creating file : /oracle/em_agent12/rwFile
Removed the /oracle/em_agent12/rwFile file.
oracle.sysman.xa|12.1.0.6.0||discoveryPlugin
oracle.sysman.db|12.1.0.8.0||discoveryPlugin
oracle.sysman.emas|12.1.0.8.0||discoveryPlugin
oracle.sysman.oh|12.1.0.5.0||discoveryPlugin
oracle.sysman.oh|12.1.0.5.0||agentPlugin
oracle.sysman.db|12.1.0.8.0||agentPlugin

/oracle/em_agent12/plugins.txt
-sh-4.2$ cp /oracle/em_agent12/plugins.txt /tmp/plugins.txt
-sh-4.2$ perl $AGENT_HOME/sysman/install/AgentDeinstall.pl -agentHome $AGENT_HOME


 Agent Oracle Home: /oracle/em_agent12/core/12.1.0.5.0

agentHome = /oracle/em_agent12/core/12.1.0.5.0

NOTE: The agent base directory: /oracle/em_agent12 will be removed after successful deinstallation of agent home.


 DetachHome Command executed:/oracle/em_agent12/core/12.1.0.5.0/oui/bin/runInstaller -detachHome -force -depHomesOnly -silent ORACLE_HOME=/oracle/em_agent12/core/12.1.0.5.0 -waitForCompletion -invPtrLoc /oracle/em_agent12/core/12.1.0.5.0/oraInst.loc
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 36799 MB    Passed
The inventory pointer is located at /oracle/em_agent12/core/12.1.0.5.0/oraInst.loc
'DetachHome' was successful.
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 36799 MB    Passed
The inventory pointer is located at /oracle/em_agent12/core/12.1.0.5.0/oraInst.loc
The Oracle home '/oracle/em_agent12/sbin' could not be updated as it does not exist.


Deinstall Command executed:/oracle/em_agent12/core/12.1.0.5.0/oui/bin/runInstaller -deinstall -silent "REMOVE_HOMES={/oracle/em_agent12/core/12.1.0.5.0}" -waitForCompletion -removeAllFiles -invPtrLoc /oracle/em_agent12/core/12.1.0.5.0/oraInst.loc
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 36799 MB    Passed
Oracle Universal Installer, Version 11.1.0.13.0 Production
Copyright (C) 1999, 2015, Oracle. All rights reserved.

Starting deinstall


Deinstall in progress (Thursday, June 18, 2020 6:49:53 AM UTC)
Configuration assistant "Agent Deinstall Assistant" succeeded
............................................................... 100% Done.

Deinstall successful

End of install phases.(Thursday, June 18, 2020 6:50:00 AM UTC)
End of deinstallations
Please check '/oracle/oraInventory/logs/silentInstall2020-06-18_06-49-50AM.log' for more details.

NOTE: The targets monitored by this Management Agent will not be deleted in the Enterprise Manager Repository by this deinstall script. Make sure to delete the targets manually from the Cloud Control Console for a successful deinstallation.
-sh-4.2$
-sh-4.2$
-sh-4.2$
-sh-4.2$ pwd
/oracle/em_agent12
-sh-4.2$ ls -lrt
total 0
-sh-4.2$
Once after deinstall you can see that the Agent base directory is also cleaned up by the agent deinstall script.

Happy deinstalling..