Sometimes it is necessary to rename targets in Enterprise Manager Cloud Control 12c. In my case I have listener targets discovered by EM12c with the hostname at the end of the target name: TESTDBA_LSN_dbserver1
As I work in a Veritas clustered environment, when the target switches to the other node (dbserver2) the listener target is relocated, but its name is always TESTDBA_LSN_dbserver1.
How to rename a listener target in EM Cloud Control 12c?
We use emcli to list the agent’s targets:
oracle@dbserver1:/opt/oracle/agent12c/core/12.1.0.4.0/bin/ [agent12c] ./emctl config agent listtargets | grep TESTDBA [TESTDBA_SITE1.domain.com, oracle_database] [TESTDBA_LSN_dbserver1, oracle_listener]
From the Oracle Management Repository, we can also run the query:
SQL>SELECT ENTITY_TYPE,ENTITY_NAME,DISPLAY_NAME FROM SYSMAN.EM_MANAGEABLE_ENTITIES WHERE MANAGE_STATUS = 2 and DISPLAY_NAME like '%TESTDBA%' ORDER BY 1;
ENTITY_TYPE ENTITY_NAME DISPLAY_NAME oracle_database TESTDBA_SITE1.domain.com TESTDBA_SITE1.domain.com oracle_dbsys TESTDBA_SITE1.domain.com_sys TESTDBA_SITE1.domain.com_sys oracle_listener TESTDBA_LSN_dbserver1 TESTDBA_LSN_dbserver1
Then from OMS server you can change the display_name:
oracle@omsserver:/home/oracle/[oms12c] emcli modify_target -name="TESTDBA_LSN_dbserver1" -type="oracle_listener" -display_name="TESTDBA_LSN" Target "TESTDBA_LSN_dbserver1:oracle_listener" modified successfully
If we run again the previous query the display name is modified in the repository, and the Cloud 12c console display the name correctly:
SQL>SELECT ENTITY_TYPE,ENTITY_NAME,DISPLAY_NAME FROM SYSMAN.EM_MANAGEABLE_ENTITIES WHERE MANAGE_STATUS = 2 and DISPLAY_NAME like '%TESTDBA%' ORDER BY 1;
ENTITY_TYPE ENTITY_NAME DISPLAY_NAME oracle_database TESTDBA_SITE1.domain.com TESTDBA_SITE1.domain.com oracle_dbsys TESTDBA_SITE1.domain.com_sys TESTDBA_SITE1.domain.com_sys oracle_listener TESTDBA_LSN_dbserver1 TESTDBA_LSN
By the way, we need now to change the target name, we use emcli to rename the target from the OMS server but what a surprise the operation is not allowed and we get the following error message:
oracle@omsserver:/home/oracle/ [oms12c] emcli rename_target -target_type="oracle_listener" -target_name="TESTDBA_LSN_dbserver1" -new_target_name="TESTDBA_LSN" Rename not supported for the given Target Type.
If we try to run the procedure from the Oracle Management Repository, we notice we have more details in the error message:
SQL> exec em_target.rename_target('oracle_listener','TESTDBA_LSN_dbserver1','TESTDBA_LSN', 'TESTBA_LSN'); BEGIN em_target.rename_target('oracle_listener','TESTDBA_LSN_dbserver1','TESTDBA_LSN', 'TESTBA_LSN'); END; *ERROR at line 1: ORA-20233: -20233 Not allowed ORA-06512: at "SYSMAN.EM_TARGET", line 8033 ORA-06512: at line 1
I we look more precisely in the sysman em_target package body source code:
-- we will implement rename of agent side targets when it is fully -- supported by agent IF ( l_trec.manage_status = MANAGE_STATUS_MANAGED AND l_trec.emd_url IS NOT NULL) THEN raise_application_error(MGMT_GLOBAL.INVALID_PARAMS_ERR, MGMT_GLOBAL.INVALID_PARAMS_ERR||' Not allowed') ; END IF ;
I decided to test the following modification; I put the code in comment and recreate and recompile the em_target package body:
-- we will implement rename of agent side targets when it is fully -- supported by agent -- IF ( l_trec.manage_status = MANAGE_STATUS_MANAGED AND -- l_trec.emd_url IS NOT NULL) -- THEN -- raise_application_error(MGMT_GLOBAL.INVALID_PARAMS_ERR, -- MGMT_GLOBAL.INVALID_PARAMS_ERR||' Not allowed') ; -- END IF ;
And now the target entity rename is working fine:
Oracle@omsserver:/home/oracle/ [oms12c] emcli rename_target -target_type="oracle_listener" -target_name="TESTDBA_LSN_dbserver1" -new_target_name="TESTDBA_LSN" Target TESTDBA_LSN_dbserver1 successfully renamed to TESTDBA_LSN.
Finally my listener target has now a correct name:
SQL>SELECT ENTITY_TYPE,ENTITY_NAME,DISPLAY_NAME FROM SYSMAN.EM_MANAGEABLE_ENTITIES WHERE MANAGE_STATUS = 2 and DISPLAY_NAME like '%TESTDBA%' ORDER BY 1;
ENTITY_TYPE ENTITY_NAME DISPLAY_NAME oracle_database TESTDBA_SITE1.domain.com TESTDBA_SITE1.domain.com oracle_dbsys TESTDBA_SITE1.domain.com_sys TESTDBA_SITE1.domain.com_sys oracle_listener TESTDBA_LSN TESTDBA_LSN
Conclusion:
Don’t forget to back up your Oracle Management Repository database before any modifications in the EM_TARGET package, and once you have done your target name modification, uncomment the code you have modified to return to the original situation.