目录:
- 安装前检查:
- 安装JVM组件:
- 方式一(图形化安装)
- 方式二(执行脚本安装)
- 检查DB JVM状态脚本
安装前检查:
检查角色:
select * from dba_roles where ROLE in ('JAVAIDPRIV','JAVAUSERPRIV');
检查DBMS_JAVA:
select * from dba_procedures where OBJECT_NAME= 'DBMS_JAVA';
检查组件:
-- Start of File full_jvminst_ceshi.sql
spool full_jvminst_ceshi.log;
set echo on
select obj#, name from obj$
where type#=28 or type#=29 or type#=30 or namespace=32;
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
set echo off
spool off
exit
-- End of File full_jvminst_ceshi.sql
安装JVM组件:
方式一(图形化安装)
Add the Oracle JVM component using the Database Configuration Assistant Utility
a. Start the Database Configuration Assistant and Click Next at the Welcome screen.
预计完成时间: 半个小时左右,视数据库的性能安装时间有所偏差
方式二(执行脚本安装)
Manually Add the JVM Component by executing the initjvm.sql script.
The following steps need to be executed precisely as listed below to ensure that they complete successfully:
a. Verify the following system requirements are available:
The Shared Pool has at least 96Mb of free space.
The Java Pool has at least 50Mb of free space
The SYSTEM tablespace has at least 70Mb of free space
The SYSTEM RBS has at least 100Mb of free space
The initjvm.sql script in 11g will check these resources are available when it is run, and if they aren’t available the execution of the script will terminate with an error indicating which resource needs to be increased.
b. Shutdown the instance and then create and run the following sql script from a new sqlplus session:
-- 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
c. Once the database has been restarted, resolve any invalid objects.
This can be performed by running the utlrp.sql script e.g.:
@?/rdbms/admin/utlrp.sql
检查DB JVM状态脚本
column comp_name format a30
column version format a20
column status format a15
column owner format a30
column object_name format a30
column object_type format a15
column long_name format a75
column role format a40
column act_time format a24
column action format a15
column comments format a20
set pagesize 500
set linesize 150
set trimspool on
set serveroutput on
set echo on
spool jvm_info.log
------ REGISTRY INFO ------
SELECT SUBSTR(comp_name, 1, 30) comp_name, SUBSTR(version, 1, 20) version, status
FROM dba_registry
ORDER BY comp_name;
------ REGISTRY HISTORY -------
SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') act_time, action, version, id, comments
FROM dba_registry_history
ORDER BY action_time DESC;
------ JAVA OBJECT INFO ------
-- Are there a substantial number of VALID Java objects in SYS?
SELECT owner, object_type, status, COUNT(*)
FROM dba_objects
WHERE object_type LIKE '%JAVA%'
GROUP BY owner, object_type, status
ORDER BY owner, object_type, status;
-- Is the DBMS_JAVA package VALID?
SELECT owner, object_name, object_type, status
FROM dba_objects
WHERE object_name LIKE 'DBMS_JAVA%'
OR object_name LIKE '%INITJVMAUX%'
ORDER BY owner, object_name, object_type;
-- Are there any INVALID Java objects in SYS?
SELECT owner, NVL(longdbcs,object_name) long_name, object_type, status
FROM dba_objects, sys.javasnm$
WHERE object_type LIKE '%JAVA%'
AND status <> 'VALID'
AND short (+) = object_name
ORDER BY owner, long_name, object_type;
------ JAVA ROLE INFO ------
-- The number expected varies by release.
SELECT role
FROM dba_roles
WHERE role LIKE '%JAVA%'
ORDER BY role;
------ MEMORY INFO ------
SELECT *
FROM v$sgastat
WHERE pool = 'java pool' OR name = 'free memory'
ORDER BY pool, name;
------ DATABASE PARAMETER INFO ------
show parameter pool_size
show parameter target
show parameter sga
------ TEST JAVAVM USAGE (and return the JDK version if > 11g) ------
-- Calling routines in DBMS_JAVA will invoke the JavaVM and expose certain problems.
SET SERVEROUTPUT ON
DECLARE
ver NUMBER := 0;
val VARCHAR2(30);
BEGIN
BEGIN
SELECT TO_NUMBER( SUBSTR(version, 1, 2) )
INTO ver
FROM dba_registry
WHERE comp_name = 'JServer JAVA Virtual Machine';
EXCEPTION
WHEN OTHERS THEN NULL;
END;
IF ver >= 12 THEN
EXECUTE IMMEDIATE
'SELECT ''JDK version is '' ||
dbms_java.get_jdk_version() FROM dual'
INTO val;
ELSE
val := dbms_java.longname('JDK version not available');
END IF;
dbms_output.put_line(val);
END;
/
spool off
至此结束,有什么问题欢迎留言
参考官方文档:
How to Add the JVM Component to an Existing Oracle Database (Doc ID 1461562.1)
Script to Check the Status of the JVM within the Database (Note: 456949.1)