Here are the steps I followed:
First, confirmed that java is indeed not installed (see my previous note "Is java installed in my database")
Step 1: Executed full export or another type of full backup (Oracle recommends a cold backup):
Create a parameter file as follows:
USERID='/ as sysdba'
DIRECTORY=DPUMP
DUMPFILE=full_exp_before_java.dmp
LOGFILE=full_exp_before_java.log
JOB_NAME=PREJAVA_EXP
FULL=Y
Execute the export from the command line:
$ [PRODDB11] expdp parfile=full_exp.par
Check that export finished successfully:
Dump file set for SYS.PREJAVA_EXP is:
/db_impexp/oracle/PRODDB1/full_exp_before_java.dmp
Job "SYS"."PREJAVA_EXP" successfully completed at 09:10:41
Step 2: shutdown of the database:
$ [PRODDB11] srvctl status database -d PRODDB10
Instance PRODDB11 is running on node node1
$ [PRODDB11] srvctl stop database -d PRODDB1
$ [PRODDB11] srvctl status database -d PRODDB1
Instance PRODDB1 is not running on node node1
Step 3: Create script full_rmjvm.sql:
-- Start of File full_rmjvm.sql
spool full_rmjvm.log
set echo on
connect / as sysdba
startup mount
alter system set "_system_trig_enabled" = false scope=memory;
alter system enable restricted session;
alter database open;
@?/rdbms/admin/catnoexf.sql
@?/rdbms/admin/catnojav.sql
@?/xdk/admin/rmxml.sql
@?/javavm/install/rmjvm.sql
truncate table java$jvm$status;
select * from obj$ where obj#=0 and type#=0;
delete from obj$ where obj#=0 and type#=0;
commit;
select owner, count(*) from all_objects
where object_type like '%JAVA%' group by owner;
select obj#, name from obj$
where type#=28 or type#=29 or type#=30 or namespace=32;
select o1.name from obj$ o1,obj$ o2
where o1.type#=5 and o1.owner#=1 and o1.name=o2.name and o2.type#=29;
shutdown immediate
set echo off
spool off
exit
-- End of File full_rmjvm.sql
Step 4: Remove existing java installations, if any. From a new sqlplus session, run the script full_rmjvm.sql.
(Note that the script will start up the database for you)
$ [PRODDB11] sqlplus / as sysdba @rmjvm.sql
Step 5: Review the log file FULL_RMJVM.LOG
In my case, java was not installed, so the removal scritp had nothing to do and exited with the following message:
ERROR at line 1:
ORA-20000: CATJAVA has not been loaded into the database.
ORA-06512: at line 3
Step 6: Create script full_jvminst.sql
-- Start of File full_jvminst.sql
spool full_jvminst.log;
set echo on
connect / as sysdba
startup mount
alter system set "_system_trig_enabled" = false scope=memory;
alter database open;
select obj#, name from obj$
where type#=28 or type#=29 or type#=30 or namespace=32;
@?/javavm/install/initjvm.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
@?/xdk/admin/initxml.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
@?/xdk/admin/xmlja.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
@?/rdbms/admin/catjava.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
@?/rdbms/admin/catexf.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
shutdown immediate
set echo off
spool off
exit
-- End of File full_jvminst.sql
Step 7: Install the JVM
a) Be sure the REMOVAL script, full_rmjvm.sql, completed successfully
b) Create the following INSTALL script, full_jvminst.sql
c) Run it from a new SQL*Plus session
$ [PRODDB11] sqlplus / as sysdba @full_jvminst.sql
Step 8: Review the log file FULL_JVMINST.LOG
In my case, there were no errors and the logfile ends with:
SQL> select count(*), object_type from all_objects 2 where object_type like '%JAVA%' group by object_type; COUNT(*) OBJECT_TYPE ---------- ------------------- 317 JAVA DATA 762 JAVA RESOURCE 20332 JAVA CLASS 2 JAVA SOURCE SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down.
Step 9: Start the database:
$ [PRODDB11] srvctl start database -d PRODDB10
Step 10: Resolve Invalid Objects:
$ [PRODDB11] sqlplus / as sysdba @?/rdbms/admin/utlrp.sql
Step 11: Create the file validate_java_installation.sql
-- Start of File validate_java_installation.sql set lines 200 col banner format a80 col comp_name format a30 col version format a20 col status format a20 -- Validation Query 1 select count(*), object_type from all_objects where object_type like '%JAVA%' and owner = 'SYS' group by object_type; -- Validation Query 2 select owner, count(*) from all_objects where object_type like '%JAVA%' and owner = 'SYS'group by owner; -- Validation Query 3 select owner, object_type, count(*) from all_objects where object_type like '%JAVA%' and status <> 'VALID' and owner = 'SYS' group by owner, object_type; SELECT * FROM ALL_REGISTRY_BANNERS WHERE BANNER LIKE INITCAP('%Java%') OR BANNER LIKE UPPER('%JAVA%'); SELECT COMP_NAME,VERSION,STATUS FROM DBA_REGISTRY WHERE COMP_NAME LIKE INITCAP('%Java%') OR COMP_NAME LIKE UPPER('%JAVA%'); SELECT * FROM V$OPTION WHERE PARAMETER = 'Java'; exit -- End of File validate_java_installation.sqlStep 12: Validate the Install. Expected output should be similar to the following:
$ [PRODDB11] sqlplus / as sysdba @validate_java_installation.sql
SQL*Plus: Release 11.2.0.2.0 Production on Wed Jan 8 11:19:04 2014 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security, OLAP, Data Mining, Oracle Database Vault and Real Application Testing options COUNT(*) OBJECT_TYPE ---------- ------------------- 317 JAVA DATA 761 JAVA RESOURCE 20285 JAVA CLASS 2 JAVA SOURCE OWNER COUNT(*) ------------------------------ ---------- SYS 21365 no rows selected BANNER -------------------------------------------------------------------------------- JServer JAVA Virtual Machine Release 11.2.0.2.0 - Development Oracle Database Java Packages Release 11.2.0.2.0 - Development COMP_NAME VERSION STATUS ------------------------------ -------------------- -------------------- JServer JAVA Virtual Machine 11.2.0.2.0 VALID Oracle Database Java Packages 11.2.0.2.0 VALID PARAMETER VALUE ---------------------------------------------------------------- ---------------------------------------------------------------- Java TRUE Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security, OLAP, Data Mining, Oracle Database Vault and Real Application Testing options´
-- All done! --
Best procedure ever seen, thank you.
ReplyDeleteGlad you found it useful :-)
Delete