Sunday, December 6, 2015

DROP and Recreate EM repository

Stop dbconsole, if running and the following process
ps -ef | grep console;                                            
ps -ef| grep emwd;
ps -ef | grep emagent;
ps -ef |grep java;
Logon SQLPLUS as sysdba or sys and execute below
drop user sysman cascade;
drop role MGMT_USER;
drop user MGMT_VIEW cascade;
drop public synonym MGMT_TARGET_BLACKOUTS;
drop public synonym SETEMVIEWUSERCONTEXT; 
drop public synonym MGMT_target_blackouts;                   
drop public synonym mgmt_severity_array;
drop public synonym mgmt_guid_obj;  
Verify any leftover object owned by SYSMAN
SELECT owner,TABLE_NAME, synonym_name name FROM dba_synonyms WHERE table_owner = 'SYSMAN';
if you notice any public synonym or any rows returned by the above query .
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;
/
emca -deconfig dbcontrol db -repos drop
emca -config dbcontrol db -repos create


No comments: