ORA-24248 XMLDB extensible security not installed

本文介绍了解决Oracle 11g中ORA-24248错误的方法,该错误通常出现在未安装XML数据库的情况下使用网络PL/SQL包时。文章详细解释了如何安装和配置XML数据库及访问控制列表(ACL),以允许用户通过特定主机和端口访问外部网络资源。

ORA-24248 XMLDB extensible security not installed

Oracle 11g introduces more secure and fine grained access on network packages like UTL_TCP, UTL_SMTP, UTL_MAIL, UTL_HTTP and UTL_INADDR, i.e. an execute privilege on these packages is not enough to access an external network resource using these packages. You have to configure ACL (Access Control List), assign the network host and port to it and grant connect privilege to the users through this ACL .

Please see: Oracle 11g Access Control List for External Network Services

These ACLs are XML files which are stored in the XML Database repository inside the database itself, which means that XML Database must be installed in the database to use the network PL/SQL packages. XML Database is installed automatically when you create a database using DBCA with default options. However, if you unselect/uncheck the XML Database option in DBCA while creating the database, XML Database won't installed.

A few days ago I ran into this problem. We upgraded one of our development database from oracle 10gR2 to 11gR1 recently. After the upgrade the application was broken very badly. Any user trying to login to the application was getting the error below:

ORA-24248: XMLDB extensible security not installed
ORA-06512: at "SYS.UTL_INADDR", line 19
ORA-06512: at "SYS.UTL_INADDR", line 40
ORA-06512: at line 1

After I investigated, I found that that in one of Java classes in the application, where a connection was being established to the databases, a query was being executed like this.

SELECT global_name,utl_inaddr.get_host_address FROM global_name;

When I saw UTL_INADDR being called, I realized instantly that we need an ACL for this call and ACL needs XML Database. The error above is quite self explanatory. I went ahead and verified the existence of Oracle XML Database and found the following:

SQL> select comp_name from dba_registry;

COMP_NAME
----------------------------------------
OWB
Oracle Application Express
Oracle Enterprise Manager
OLAP Catalog
Spatial
Oracle Multimedia
Oracle Text
Oracle Expression Filter
Oracle Rules Manager
Oracle Workspace Manager
Oracle Database Catalog Views
Oracle Database Packages and Types
JServer JAVA Virtual Machine
Oracle XDK
Oracle Database Java Packages
OLAP Analytic Workspace
Oracle OLAP API

17 rows selected.

As can be seen from the output of the above query, we were missing Oracle XML Database. I was able to reproduce the problem in sqlplus.

SQL> conn scott/tiger
Connected.

SQL> select global_name,utl_inaddr.get_host_address from global_name;
select global_name,utl_inaddr.get_host_address from global_name
                   *
ERROR at line 1:
ORA-24248: XML DB extensible security not installed
ORA-06512: at "SYS.UTL_INADDR", line 19
ORA-06512: at "SYS.UTL_INADDR", line 40
ORA-06512: at line 1

SQL>

Install XML Database: Oracle 11g Enterprise Edition

$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus / as sysdba

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

SQL> spool install_xml_db.log
SQL> @catqm xdb sysaux temp YES
-- xdb is the password for XML Database repository schema
-- sysaux is the default tablespace for XML Database repository schema.
-- temp is the default temporary tablespace for XML Database repository schema.
-- YES is for using secure files for xdb$resource
.
.
.
[output trimmed]
.
.
.
SQL> declare
  2    suf  varchar2(26);
  3    stmt varchar2(2000);
  4  begin
  5    select toksuf into suf from xdb.xdb$ttset where flags = 0;
  6    stmt := 'grant all on XDB.X$PT' || suf || ' to DBA';
  7    execute immediate stmt;
  8    stmt := 'grant all on XDB.X$PT' || suf || ' to SYSTEM WITH GRANT OPTION';
  9    execute immediate stmt;
 10  end;
 11  /

PL/SQL procedure successfully completed.

SQL>spool off

The XML Database installation is complete. I opened the install_xml_db.log and didn't find any significant errors in it. Then I verified from dba_registry again to see the status of XML Database installed.

SQL> select comp_name , status from dba_registry;

COMP_NAME                                STATUS
---------------------------------------- --------------------------------------------
Oracle XML Database                      VALID
OWB                                      VALID
Oracle Application Express               VALID
Oracle Enterprise Manager                VALID
OLAP Catalog                             VALID
Spatial                                  VALID
Oracle Multimedia                        VALID
Oracle Text                              VALID
Oracle Expression Filter                 VALID
Oracle Rules Manager                     VALID
Oracle Workspace Manager                 VALID
Oracle Database Catalog Views            VALID
Oracle Database Packages and Types       VALID
JServer JAVA Virtual Machine             VALID
Oracle XDK                               VALID
Oracle Database Java Packages            VALID
OLAP Analytic Workspace                  VALID
Oracle OLAP API                          VALID

18 rows selected.

SQL>

The status should be VALID to indicate that the installation was successfull. Then I tested the UTL_INADDR again.

SQL> conn scott/tiger
Connected.
SQL> select global_name,utl_inaddr.get_host_address from global_name;
select global_name,utl_inaddr.get_host_address from global_name
                   *
ERROR at line 1:
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_INADDR", line 19
ORA-06512: at "SYS.UTL_INADDR", line 40
ORA-06512: at line 1

As you see now the ORA-24248 is gone because we have XML Database installed. Now we are seeing ORA-24247, which means we can't access any network host using UTL_INADDR unless we allow access to this host via ACL.

SQL> conn / as sysdba
Connected.

BEGIN
   DBMS_NETWORK_ACL_ADMIN.CREATE_ACL (
        acl          =>'my_application_acl.xml',
        description  => 'ACL for users of my application.',
        principal    => 'SCOTT',
        is_grant     => TRUE,
        privilege    => 'resolve',
        start_date   => null,
        end_date     => null
	);
END;
/

PL/SQL procedure successfully completed.

/*
 All that UTL_INADDR.get_host_address does is resolve the host and return the IP Address.
 DBMS_NETWORK_ACL_ADMIN.CREATE_ACL creates an ACL and grant privilege to a user or role 
 to that ACL.
 For the sake of this article I am using SCOTT as the grantee of the privilege resolve but 
 in my application I granted this privilege to a role which was assigned to all the 
 application users. So through that role all the users were granted resole privilege to 
 this ACL.
*/

BEGIN
   DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (
     acl         =>'my_application_acl.xml',
     host        => 'localhost',
     lower_port  => null,
     upper_port  => null
     );
END;
/

PL/SQL procedure successfully completed.

/*
 When UTL_INADDR.get_host_address is invoked without a host name specified with it,
 it sends the request to localhost. So we need to assign our ACL to the host "localhost".
*/

commit;

SQL> conn scott/tiger
Connected.
SQL> set lines 10000
SQL> column global_name format a20
SQL> column get_host_address format a15
SQL> select global_name,utl_inaddr.get_host_address from global_name;

GLOBAL_NAME          GET_HOST_ADDRES
-------------------- ---------------
ORA11G.HOME.COM      127.0.0.1

SQL>

As you can see above, SCOTT is now able to get server's IP Adress using utl_inaddr.get_host_address. And this solves our problem with the application.

Uninstall XML Database: Oracle 11g Enterprise Edition

$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus / as sysdba

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

SQL> @catnoqm.sql
-- This will uninstall the Oracle XML Database.

See also:
Oracle 11g Access Control List for External Network Services


From http://oracleflash.com/40/ORA-24248-XMLDB-extensible-security-not-installed.html

and Thanks Zahid Karim

<think>我们被要求解决ORA-20001错误(Latest xml inventory is not loaded into table)。根据提供的引用,我们可以总结以下步骤: 引用[1]和引用[3]都指向了MOS文档1602089.1,其中提到了多种导致该错误的原因和解决方法。特别是引用[3]提到了Symptoms 18(症状18)中关于UTF8字符的问题。 引用[2]是一篇博客,分享了在安装Oracle关键补丁更新时遇到该错误的解决方法。 引用[4]提供了一条命令,用于重建oraInventory。 综合引用内容,我们可以得出以下解决步骤: 1. 环境检查:确保操作系统的语言环境是英文(如引用[3]所建议),以避免字符集问题。 在Linux环境中,可以通过设置环境变量LANG=en_US.UTF-8来实现。 2. 重建XML清单文件:引用[4]提供了一条命令,使用opatch工具生成XML清单文件。命令如下: ``` $ORACLE_HOME/OPatch/opatch lsinventory -xml $ORABASE/rdbms/log/xml_file_$DBSID.xml -retry 0 -invPtrLoc $ORACLE_HOME/oraInst.loc >> $ORABASE/rdbms/log/stout_$DBSID.txt ``` 这里需要替换$ORACLE_HOME、$ORABASE和$DBSID为实际值。 3. 根据引用[1]和[3]的MOS文档,可能还需要检查其他原因,比如: - 确保OPatch版本是最新的。 - 检查oraInventory目录的权限是否正确。 - 如果存在多个ORACLE_HOME,确保invPtrLoc指向正确的oraInst.loc文件。 4. 如果问题是由于字符集引起的(如引用[3]所述),确保环境为英文,并且所有路径和文件名不包含特殊字符。 因此,我们可以按照以下步骤操作: 步骤1:设置环境变量为英文(在shell中执行) ``` export LANG=en_US.UTF-8 ``` 步骤2:更新OPatch到最新版本(建议从Oracle支持网站下载最新OPatch并替换$ORACLE_HOME/OPatch目录) 步骤3:重建清单 首先,确定ORACLE_HOME、ORABASE(通常是ORACLE_BASE)和数据库SID($ORACLE_SID)。 然后执行命令: ``` $ORACLE_HOME/OPatch/opatch lsinventory -xml $ORACLE_BASE/rdbms/log/xml_file_$ORACLE_SID.xml -retry 0 -invPtrLoc $ORACLE_HOME/oraInst.loc >> $ORACLE_BASE/rdbms/log/stout_$ORACLE_SID.txt ``` 注意:如果oraInst.loc不在$ORACLE_HOME下,请根据实际位置指定。 步骤4:检查清单重建过程中是否有错误(查看输出日志$ORACLE_BASE/rdbms/log/stout_$ORACLE_SID.txt),并确保xml文件生成成功。 步骤5:再次运行原本的操作(比如应用补丁)。 如果以上步骤不能解决问题,请参考MOS文档1602089.1中的其他解决方案。 注意:在执行这些操作前,建议备份相关目录。 根据以上步骤,我们给出回答。 </think> ### ORA-20001错误解决方案:Latest xml inventory is not loaded into table 该错误通常发生在Oracle补丁安装或清单操作时,表示XML清单文件未正确加载。以下是已验证的解决方案: #### **1. 设置英文环境(关键步骤)** ```bash export LANG=en_US.UTF-8 # 临时生效 # 或永久生效:编辑/etc/profile 添加 LANG=en_US.UTF-8 ``` > **原因**:非英文字符集(如中文环境)会导致XML解析失败,这是最常见诱因[^3]。 #### **2. 重建Inventory清单文件** 执行以下命令生成新XML清单: ```bash $ORACLE_HOME/OPatch/opatch lsinventory -xml $ORACLE_BASE/rdbms/log/xml_file_$ORACLE_SID.xml -retry 0 -invPtrLoc $ORACLE_HOME/oraInst.loc >> $ORABASE/rdbms/log/stout_$ORACLE_SID.txt ``` > **注意**:替换 `$ORACLE_HOME`, `$ORACLE_BASE`, `$ORACLE_SID` 为实际值[^4]。 #### **3. 更新OPatch工具** 从[Oracle支持网站](https://support.oracle.com)下载最新OPatch版本,替换旧版本: ```bash mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch_bak unzip p6880880_*.zip -d $ORACLE_HOME ``` #### **4. 检查Inventory权限** 确保`oraInventory`目录权限正确: ```bash chown -R oracle:oinstall /path/to/oraInventory chmod -R 775 /path/to/oraInventory ``` #### **5. 验证Inventory完整性** 运行诊断命令: ```bash $ORACLE_HOME/OPatch/opatch lsinventory -detail ``` 若输出包含`OPatch failed: Unable to load inventory`,需重新注册HOME: ```bash $ORACLE_HOME/oui/bin/runInstaller -silent -attachHome -invPtrLoc $ORACLE_HOME/oraInst.loc ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME="<your_home_name>" ``` #### **典型错误场景** - **中文环境问题**:安装日志出现中文字符导致XML解析失败(强制英文环境可解)[^3]。 - **多ORACLE_HOME冲突**:`oraInst.loc`文件未正确指向当前HOME。 - **补丁冲突**:使用`opatch prereq`检查补丁依赖关系。 > **操作前备份**:建议备份`$ORACLE_HOME/inventory`和`oraInst.loc`文件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值