Thursday, May 21, 2009

How to Recreate the Database Control Repository

Create Database Console: -
To create the configuration files and repository for Database Console, run:
$ emca -config dbcontrol db -repos create

Drop Database Console: -
To drop (remove) the configuration files and repository for Database Console, run:
$ emca -deconfig dbcontrol db -repos drop

Recreate Database Console: -
To recreate the configuration files and repository for Database Console, run:
$ emca -config dbcontrol db -repos recreate
_______________________________________________________________________________
EM reinstalling procedure: -

After changing of hostname IP address, EM dbconsole port, instance SID, or even TZ settings, EM is going to fail. Using "emca" you can reconfigure eg. the port number to 1150:

emca -reconfig ports -DBCONTROL_HTTP_PORT 1150

but in more serious cases there's only one solution - reinstallation. I tried many approaches (fixing output errors and so on) but this one is effective. Later I've found that Oracle says exactly the same ;-) ... and better do it off rush hours due to its high resource consumption.

Check the status: -
emctl status dbconsole

1st way: -
emca -deconfig dbcontrol db -repos drop
# then
emca -config dbcontrol db -repos create

2nd way: -
emca -deconfig dbcontrol db
# then
emca -config dbcontrol db -repos recreate

When something went wrong, delete DB Control Repository Objects manually with SQLPlus: -
drop user sysman cascade;
drop role MGMT_USER;
drop user MGMT_VIEW cascade;
drop public synonym MGMT_TARGET_BLACKOUTS;
drop public synonym SETEMVIEWUSERCONTEXT;

Now, try again "emca" with create or recreate option.

Example of using an input file for "emca" parameters - dropping EM repository (don't worry, not database, as some may think) with required parameters, for RAC, silent mode:

emca -deconfig dbcontrol db -repos drop -cluster -silent -respFile emca.par

# where emca.par content:
DB_UNIQUE_NAME=[name]
PORT=1521
SYS_PWD=[pwd]
SYSMAN_PWD=[pwd2]
DBSNMP_PWD=[pwd3]
HOST=[hostname]
SID=[sid]
ORACLE_HOSTNAME=[hostname]

Checking which port is correct:

cat $ORACLE_HOME/install/portlist.ini
# eg.
# Enterprise Manager Console HTTP Port (orcl) = 1158

Calling EM in browser: -
http://[hostname]:1158/em

isqlplus: -

isqlplussvc -uninstall
isqlplusctl start
isqlplusctl stop
__________________________________________________________________________________
emca fails on 10.2.0.4 with ORA-04042 and ORA-06512: -

“emca -deconfig dbcontrol db -repos create” it failed with error stack below.

Jan 19, 2009 5:11:53 PM oracle.sysman.emcp.EMReposConfig invoke SEVERE: Error creating the repository
Jan 19, 2009 5:11:53 PM oracle.sysman.emcp.EMReposConfig invoke INFO: Refer to the log file at /oracle/product/ora10204/cfgtoollogs/emca/*****\emca_repos_create_.log for more details.
Jan 19, 2009 5:11:53 PM oracle.sysman.emcp.EMConfig perform SEVERE: Error creating the repository

Then I check the error log, and I found the stack below

Create SYSMAN user.

No errors.
DECLARE
*
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
ORA-06512: at line 11

While it creates the sysman user it cannot find a procedure and fails. To find out which procedure it was looking for I applied metalink and quick Search on metalink took me the note ID 331938.1

The note says problem is caused by the missing procedure dbms_shared_pool (no idea why it was missing on a brand new 10.2.0.2 db)

To solve the problem

1- Create the package

@$ORACLE_HOME/rdbms/admin/dbmspool.sql

2- Give permission to package

grant execute on dbms_shared_pool to sysman;
grant execute on dbms_shared_pool to dba;

3- follow the re-creation steps from the beginning including dropping sysman role and droppping the existing configurations

4- re run the command “emca -config dbcontrol db -repos create”