I do a lot of testing in my lab environment with a lot of different Oracle products including Oracle Enterprise Manager (OEM). One of the things that I have run into is when I reinstall my OEM system, I am usually left with several hosts with OEM agents left over on them. Since I might want to re-install OEM on those hosts again, I needed to figure out a way to delete the OEM 13c host agent remotely without removing any other software and leaving the Oracle inventory intact.
This just happened recently when I wanted to verify that OEM 13.3 works well with a 19.3 repository database. So, I wanted to figure out how to setup a script to remove the OEM 13c host agent remotely from several hosts.
Note: If I wanted to remove hosts from a running OEM server I would use the agent decommission option that is available prior to removing the agent from the host.
I found that you can remove the OEM 13c Host Agent remotely with the following command:
$<AGENT_HOME>/perl/bin/perl <AGENT_HOME>/sysman/install/AgentDeinstall.pl -agentHome <AGENT_HOME>
In my case, I installed the agent in /u01/app/oracle/agent13c and the agent was the 13.2 agent, so the AGENT_HOME is /u01/app/oracle/agent13c/agent_126.96.36.199.0. So, I would remove it with the following command:
/u01/app/oracle/agent13c/agent_188.8.131.52.0/perl/bin/perl /u01/app/oracle/agent13c/agent_184.108.40.206.0/sysman/install/AgentDeinstall.pl -agentHome /u01/app/oracle/agent13c/agent_220.127.116.11.0
I easily scripted this to remove the OEM agent from all of my GoldenGate test systems with this:
# This script will remove agents from remote servers.
# etw 2019-05-22
for i in gg20a gg20b gg21a gg21b gg22a gg22b gg23a gg23b gghub00 gghub01
ssh oracle@$i “/u01/app/oracle/agent13c/agent_18.104.22.168.0/perl/bin/perl /u01/app/oracle/agent13c/agent_22.214.171.124.0/sysman/install/AgentDeinstall.pl -agentHome /u01/app/oracle/agent13c/agent_126.96.36.199.0”
ssh oracle@$i “ls /u01/app/oracle”
Once this completed, I was safely able to re-install agents on those hosts.