Friday, March 25, 2016

Rebuild targets.xml for Oracle Enterprise Manager Grid Control Agent

 1. Agents installations before 10.2.0.3 have a bug in the 'agentca' command
that prevents the targets.xml file from getting populated with the initial
parameters (AGENT_TOKEN, ORACLE_EMD, and/or HOST) when the file does not
already exist. To work around this we will need to manually create a targets.xml
file if it does not exist.

Windows create the new file in the Agent %ORACLE_HOME%\sysman\emd\ directory.
(Where %ORACLE_HOME% is the agent's home)

Unix$
$ cd $ORACLE_HOME/sysman/emd (where $ORACLE_HOME is the Agent's home)
$ touch targets.xml.
 2. Once you have created the targets.xml file, view the Agent's
$ORACLE_HOME/sysman/config/emd.properties file. 
Copy the values for:
agentSeed=12345 EMD_URL=http://hostname.oracle.com:9876/emd/main
3. Manually update the new targets.xml and add the following entries to the file following
the syntax exactly:
<targets agent_seed="agentseed from emd.properties">
  <target name="hostname and port from emd.properrties EMD_URL" type="oracle_emd">
  <target name="hostname as it appears in the emd_url" type="host">
</targets>
  <targets agent_seed="agentseed from emd.properties">
  <target type="oracle_emd" name="hostname and port from emd.properties EMD_URL">
  <target type="host" name="hostname as it appears in the emd_url">
</targets>
For example:

<targets agent_seed="12345">
  <target type="oracle_emd" name="hostname.domain.com:port">
  <target type="host" name="hostname.domain.com">
</targets>
<targets agent_seed="12345">
  <target name="hostname.domain.com:port" type="oracle_emd">
  <target name="hostname.domain.com" type="host">
</targets>

4. Force target re-discovery:

a. Verify that the environment variables are setup for the Management Agent:
$ORACLE_HOME set$ORACLE_HOME/bin in $PATH
b. The agentca utility is expecting the oraInst.loc to be located in the root of the Agent's $ORACLE_HOME

NOTE: Solaris puts the oraInst.loc in /var/opt/oracle.
Agentca will not fine the oraInst.loc on a Solaris platform.
For Solaris platforms you need to create a soft link:
$ORACLE_HOME/oraInst.loc to /var/opt/oracle/oraInst.loc

c. Run agentca -d to force a new discovery of the targets on the host
agentca -d