Create/ Re-Create Oracle Enterprise Manager Repository and DB Control



Steps to create new repository

1. Create new repository using emca

emca -config dbcontrol db -repos create -silent -PORT <DB port> -SERVICE_NAME <ORACLE_SID> -SYS_PWD <sys password> -SID  <ORACLE_SID> -DBSNMP_PWD <dbsnmp password> -SYSMAN_PWD <sysman password> -DBCONTROL_HTTP_PORT <DB Control HTTP port> -AGENT_PORT <DB Control Agent port> -RMI_PORT <RMI port> -JMS_PORT <JMS port>

Default values:
  DB port: 1521
  DB Control HTTP port: 1158
  DB Control Agent port: 3938
  RMI port: 5521
  JMS port: 5541

Example:
emca -config dbcontrol db -repos create -silent -PORT 1521 -SERVICE_NAME ORCL -SYS_PWD oracle -SID ORCL -DBSNMP_PWD dbsnmp -SYSMAN_PWD oem_temp -DBCONTROL_HTTP_PORT 1158 -AGENT_PORT 3938 -RMI_PORT 5521 -JMS_PORT 5541

Steps to re-create existing repository

1. Unlock user accounts and change passwords:
  alter user dbsnmp account unlock identified by <dbsnmp password>;
  alter user sysman account unlock identified by <sysman password>;

2. Ensure that targets.xml file exists and has the following content:
  <?xml version = "1.0"?>
  <Targets>
  </Targets>
The location of targets.xml file is: <ORACLE_HOME>\<Server Name>_<Instance Name>\sysman\emd\targets.xml

3. Re-create repository using emca:

emca -config dbcontrol db -repos recreate -silent -PORT <DB port> -SERVICE_NAME <ORACLE_SID> -SYS_PWD <sys password> -SID <ORACLE_SID> -DBSNMP_PWD <dbsnmp password> -SYSMAN_PWD <sysman password> -DBCONTROL_HTTP_PORT <DB Control HTTP port> -AGENT_PORT <DB Control Agent port> -RMI_PORT <RMI port> -JMS_PORT <JMS port>
  
Default values:
  DB port: 1521
  DB Control HTTP port: 1158
  DB Control Agent port: 3938
  RMI port: 5521
  JMS port: 5541

  Example:
emca -config dbcontrol db -repos recreate -silent -PORT 1521 -SERVICE_NAME ORCL -SYS_PWD oracle -SID ORCL -DBSNMP_PWD dbsnmp -SYSMAN_PWD oem_temp -DBCONTROL_HTTP_PORT 1158 -AGENT_PORT 3938 -RMI_PORT 5521 -JMS_PORT 5541

Steps to completely drop old repository and re-create it
1. Start listener
  lsnrctl start <LISTENER Name>
2. Drop existing repository
emca -deconfig dbcontrol db -repos drop -silent -PORT <DB port> -SERVICE_NAME <ORACLE_SID> -SYS_PWD <sys password> -SID <ORACLE_SID> -DBSNMP_PWD <dbsnmp password> -SYSMAN_PWD <sysman password> -DBCONTROL_HTTP_PORT <DB Control HTTP port> -AGENT_PORT <DB Control Agent port> -RMI_PORT <RMI port> -JMS_PORT <JMS port>
  
Default values:
  DB port: 1521
  DB Control HTTP port: 1158
  DB Control Agent port: 3938
  RMI port: 5521
  JMS port: 5541

  Example:
emca -config dbcontrol db -repos drop -silent -PORT 1521 -SERVICE_NAME ORCL -SYS_PWD oracle -SID ORCL -DBSNMP_PWD dbsnmp -SYSMAN_PWD oem_temp -DBCONTROL_HTTP_PORT 1158 -AGENT_PORT 3938 -RMI_PORT 5521 -JMS_PORT 5541

3. Drop database objects:
  sqlplus "sys as sysdba"
  drop public synonym SETEMVIEWUSERCONTEXT;
  drop ROLE MGMT_USER;
  drop PUBLIC SYNONYM MGMT_TARGET_BLACKOUTS;
  drop user sysman cascade;
  drop user MGMT_VIEW cascade;
  exit;

4. Create new repository:

emca -config dbcontrol db -repos create -silent -PORT <DB port> -SERVICE_NAME <ORACLE_SID> -SYS_PWD <sys password> -SID <ORACLE_SID> -DBSNMP_PWD <dbsnmp password> -SYSMAN_PWD <sysman password> -DBCONTROL_HTTP_PORT <DB Control HTTP port> -AGENT_PORT <DB Control Agent port> -RMI_PORT <RMI port> -JMS_PORT <JMS port>
  
Default values:
  DB port: 1521
  DB Control HTTP port: 1158
  DB Control Agent port: 3938
  RMI port: 5521
  JMS port: 5541

  Example:
emca -config dbcontrol db -repos create -silent -PORT 1521 -SERVICE_NAME 
ORCL -SYS_PWD oracle -SID ORCL -DBSNMP_PWD dbsnmp -SYSMAN_PWD oem_temp -DBCONTROL_HTTP_PORT 1158 -AGENT_PORT 3938 -RMI_PORT 5521 -JMS_PORT 5541