Search This Blog

Saturday, September 10, 2011

How to delete/remove Oracle Enterprise Manager Console in 11GR2

I received email for asking "how to delete/remove OEM console on 11gr2 windows platform"
How to drop ORACLE ENTERPRISE MANAGER repository and configuration files manually on 11gr2

Step
1. delete DB control repository objects manually
logon as sysdba user
and execute following sql statement
exec DBMS_AQADM.DROP_QUEUE_TABLE(queue_table=>>'SYSMAN.MGMT_NOTIFY_QTABLE',force =>>TRUE);

2. login sys or system and drop SYSMAN AND MANAGEMENT OBJECTS
 SHUTDOWN IMMEDIATE;
 STARTUP RESTRICT;
 EXEC sysman.emd_maintenance.remove_em_dbms_jobs;
 EXEC sysman.setEMUserContext('',5);
 REVOKE dba FROM sysman;
 DECLARE
CURSOR c1 IS
SELECT owner, synonym_name name
FROM dba_synonyms
WHERE table_owner = 'SYSMAN';
BEGIN
FOR r1 IN c1 LOOP
IF r1.owner = 'PUBLIC' THEN
EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM '||r1.name;
ELSE
EXECUTE IMMEDIATE 'DROP SYNONYM '||r1.owner||'.'||r1.name;
END IF;
END LOOP;
END;
/
 DROP USER mgmt_view CASCADE;
 DROP ROLE mgmt_user;
 DROP USER sysman CASCADE;
 ALTER SYSTEM DISABLE RESTRICTED SESSION;


3. Delete DB control configuration files manually
Remove the following directories from your filesystem:
[ORACLE_HOME]/[hostname_sid]
[ORACLE_HOME]/oc4j/j2ee/OC4J_DBConsole_[hostname]_[sid]


If the dbcontrol is upgraded from lower version, for example, from 
11.1.0.2.0 to 11.2.0.1.0, then the following directory also needs to be removed from the file system.
[ORACLE_HOME]/[hostname_sid].upgrade
[ORACLE_HOME]/oc4j/j2ee/OC4J_DBConsole_[hostname]_[sid].upgrade

NOTE:  
On Windows you also need to delete the DB Console service:
- run regedit
- navigate to HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services
- locate the OracleDBConsole[sid] entry and delete it

Alternatively on Windows XP and Windows Server 2003 you can run the following from the command line: 
'sc delete [service_name]'
- where [service_name] is the DB Control service name (typically: OracleDBConsole[sid])
###############################################################################
C:\Documents and Settings\Administrator>>set oracle_sid=fakpropr

C:\Documents and Settings\Administrator>>sqlplus sys/manager1 as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 10 12:54:52 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>> exec DBMS_AQADM.DROP_QUEUE_TABLE(queue_table=>>'SYSMAN.MGMT_NOTIFY_QTABLE',f
orce =>>TRUE);

PL/SQL procedure successfully completed.

SQL>> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>> startup restrict;
ORACLE instance started.

Total System Global Area  945786880 bytes
Fixed Size                  1384328 bytes
Variable Size             637534328 bytes
Database Buffers          301989888 bytes
Redo Buffers                4878336 bytes
Database mounted.
Database opened.
SQL>> EXEC sysman.emd_maintenance.remove_em_dbms_jobs;

PL/SQL procedure successfully completed.

SQL>> EXEC sysman.setEMUserContext('',5);

PL/SQL procedure successfully completed.

SQL>> REVOKE dba FROM sysman;
REVOKE dba FROM sysman
*
ERROR at line 1:
ORA-01951: ROLE 'DBA' not granted to 'SYSMAN'


SQL>> DECLARE
  2  CURSOR c1 IS
  3  SELECT owner, synonym_name name
  4  FROM dba_synonyms
  5  WHERE table_owner = 'SYSMAN';
  6  BEGIN
  7  FOR r1 IN c1 LOOP
  8  IF r1.owner = 'PUBLIC' THEN
  9  EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM '||r1.name;
 10  ELSE
 11  EXECUTE IMMEDIATE 'DROP SYNONYM '||r1.owner||'.'||r1.name;
 12  END IF;
 13  END LOOP;
 14  END;
 15  /

PL/SQL procedure successfully completed.

SQL>> DROP USER mgmt_view CASCADE;

User dropped.

SQL>> DROP ROLE mgmt_user;

Role dropped.

SQL>> DROP USER sysman CASCADE;

User dropped.

SQL>> ALTER SYSTEM DISABLE RESTRICTED SESSION;

System altered.

IMPORTANT: delete the configuration files as mentioned in above Step# 3


C:\>>sc delete OracleDBConsolefakpropr
[SC] DeleteService SUCCESS

No comments: