Three Methods, Supported and NOT Supported to Remove Targets in EM12c

I’ve had a couple peers ask me about this recently-   They’ve attempted to discover targets on a host and experienced failures.  This commonly occurs for the following reasons:

1.  Incorrect information regarding the target exists at the target host level.

2.  The OMS has an unresolved issue, status in pending state, etc.

My recommendation on #2 is to always check each step as your implement EM12c, (complete the EM12c installation, adding a new host, adding a new database, etc.)  Your status should be 100% green, if its not, take care of this first before you start attempting to add (more) targets.  It can save you a lot of time in the long run.

There is a supported and unsupported way to remove targets from EM12c and their are multiple ways to do so.


Log into the EMCLI from the command line:

emcli login -username=sysman

Its always best to syncronize, so please do so before proceeding to ensure the EMCLI has the latest information from the OMS.

emcli sync

Now list the targets-

emcli get_targets

Inspect the list and see if there are any that you need to remove.

Status  Status           Target Type           Target Name
1       Up               oracle_beacon         EM Management Beacon
1       Up               oracle_em_service     EM Console Service
1       Up               oracle_em_service     EM Jobs Service
1       Down             host         
1       Up               host         
1       Up               host         
1       Up               host        

In our example, the host, has ben decommissioned and can be removed.  For this host to be removed successfully, we’ve already removed the “child targets”, i.e. databases, listener, agent is shutdown, etc….

To remove the target, we run the following:

emcli delete_target -name="" -type="host" -delete_monitored_targets

2. From SQL Plus using MGMT_ADMIN Clean up option

From the OMS Server, open a command prompt, set you environment for the EM12c database-

Set the ORACLE_SID to the Repository Database.

Set the ORACLE_HOME to the Repository Database home.

Log in with SQL Plus and list out the targets:

SQL> select target_name, target_type, target_guid from sysman.mgmt_targets 
where target_type like '%Instance%';

To delete the target from the OMS, run the following:

SQL> exec mgmt_admin.cleanup_agent('<Target_Name>:<port#>');
SQL> PL/SQL procedure successfully completed.

3. Unsupported Removal- Using SQL Plus

There are a number of tables that are part of the two above methods that are cleaned properly, but there are is a rare bug or two, along with the initial reasons I mentioned that may keep you from cleaning up properly, just as you weren’t able to add a target properly.

After verifying you don’t have the problems I first mentioned, then correcting them and find that the supported methods of removing targets aren’t successful, then this is the last choice and is not supported by Oracle in any way!

Log into SQL Plus and do the following:

Find your target:

Management Services and Repository
EM Jobs Service


Now generate a script that will tell you how many tables the failed target registered in:

spool <output file>.sql;
prompt "set feedback on"
prompt "set echo on"
select 'select count(*) from '||owner||'.'||table_name||' where Target_guid=''TARGET_GUID'';' from dba_tab_columns
where owner='SYSMAN'
and column_name ='TARGET_GUID'
and table_name like 'MGMT_%'
and table_name not like '%$%'
spool off;

Run this script, spooling the output to see what tables contain the target.

Now you will need to delete from the tables that resulted in >0 row counts for the Target GUID.

delete from MGMT_TARGETS where target_guid = HEXTORAW('3173D0F6C7C3FD8C09A8B480765FE5A3');

You can generate a script to perform this task as well, saving yourself time.  Remember to commit post the delete.

These are the three types of removal choice in the EM12c for failed targets.  Again, ALWAYS attempt the first two, as they are supported by Oracle.


Print Friendly, PDF & Email
August 30, 2013

Comments Closed