Top 60 Oracle Blogs

Recent comments

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:

#c0c0c0;">emcli login -username=sysman

#000000;">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-

#c0c0c0;">emcli get_targets

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

#c0c0c0;">Status  Status           Target Type           Target Name
#c0c0c0;">1       Up               oracle_beacon         EM Management Beacon
1       Up               oracle_em_service     EM Console Service
1       Up               oracle_em_service     EM Jobs Service
#c0c0c0;">1       Down             host         
#c0c0c0;">1       Up               host         
#c0c0c0;">1       Up               host         
#c0c0c0;">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:

#c0c0c0;">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:

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

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

#c0c0c0;">SQL> exec mgmt_admin.cleanup_agent(':');
#c0c0c0;">SQL> PL/SQL procedure successfully completed.

3. #ff0000;">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:

#c0c0c0;">Management Services and Repository
#c0c0c0;">EM Jobs Service


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

#c0c0c0;">spool .sql;
#c0c0c0;">prompt "set feedback on"
#c0c0c0;">prompt "set echo on"
#c0c0c0;">select 'select count(*) from '||owner||'.'||table_name||' where Target_guid=''TARGET_GUID'';' from dba_tab_columns
#c0c0c0;">where owner='SYSMAN'
#c0c0c0;">and column_name ='TARGET_GUID'
#c0c0c0;">and table_name like 'MGMT_%'
#c0c0c0;">and table_name not like '%$%'
#c0c0c0;">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.

#c0c0c0;">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.








Copyright © DBA Kevlar [Three Methods, Supported and NOT Supported to Remove Targets in EM12c], All Right Reserved. 2013.