如何彻底卸载OJVM组件

2022-02-10 00:00:00 集群 专区 删除 生产 组件


              OJVM组件是OracleRDBMS自带的一个组件,也就是Oracle的JVM,支持对于Java代码的执行,一般用户使用很少,由于很多公司需要漏扫,会发现OJVM有漏洞,所以需要删除(或者打patch),这里记录下如何彻底删除OJVM组件

1 连接数据库设置为限制连接模式,集群会显示三个节点实例均为限制连接模式。

sqlplus /  as sysdba

alter system enable restricted session;
alter system set "_system_trig_enabled" = false scope=memory;

2 设置日志记录以审计操作过程

spool force_removal.txt
         set echo on

3 逐个执行以下脚本

 @?/rdbms/admin/catnoexf.sql -- Expression Filter should only exist in 11g but it doesn't hurt to try to remove it anyway
 @?/rdbms/admin/catnojav.sql -- remove the 'Oracle Database Java Packages' component part of the JVM
 @?/xdk/admin/rmxml.sql -- remove 'Oracle XDK' component which is not related to the JVM but gets installed in SYS schema

4 删除JServer JAVA Virtual Machine和数据库内的java对象。

execute rmjvm.run(TRUE);

此时如果遇到'ORA-00001: unique constraint (SYS.I_OBJ1) violated' trying to remove the jvm

参考文档

Note:2212082.1 "Removal of JVM After Upgrade to 12c Fails With ORA-00001: unique constraint (SYS.I_OBJ1) violated"

5 清理工作删除相关表和对象

 truncate table java$jvm$status;
 delete from obj$ where obj#=0 and type#=0;
 commit;

6 验证OJVM 删除成功,没有数据返回说明成功

select count(*) from obj$ where type#=29 and owner#=0;

7 修改组件的注册信息

delete from sys.registry$ where cid in ('JAVAVM','CATJAVA','XML','EXF');
 commit;

8 disable禁止访问

alter system disable restricted session;

9 关闭日志记录

 set echo off
 spool off

10重启数据库以清除内存中遗留的JVM信息。


相关文章