手动修改inventory.xml文件,有可能会导致inventory.xml文件损坏

发布时间 2023-11-27 18:02:55作者: 石云华

1、故障概要

在RAC集群环境下,如果需要重建DB软件,我通常的做法就是直接删除DB软件所在的目录,然后手动修改inventory.xml文件。具体如下所示:

(1)、删除DB软件所在目录,假设DB_HOME为/u01/app/oracle/product/11.2.0.4/dbhome_1:
# cd /u01/app/oracle
# rm -rf *
(2)、手动修改inventory.xml文件:
<HOME_LIST>
<HOME NAME="Ora11g_gridinfrahome1" LOC="/u01/app/11.2.0.4/grid" TYPE="O" IDX="1" CRS="true">
   <NODE_LIST>
      <NODE NAME="11grac1"/>
      <NODE NAME="11grac2"/>
   </NODE_LIST>
</HOME>
<HOME NAME="OraDb11g_home1" LOC="/u01/app/oracle/product/11.2.0.4/dbhome_1" TYPE="O" IDX="2">
   <NODE_LIST>
      <NODE NAME="11grac1"/>
      <NODE NAME="11grac2"/>
   </NODE_LIST>
</HOME>
</HOME_LIST>

修改成:
<HOME_LIST>
<HOME NAME="Ora11g_gridinfrahome1" LOC="/u01/app/11.2.0.4/grid" TYPE="O" IDX="1" CRS="true">
   <NODE_LIST>
      <NODE NAME="11grac1"/>
      <NODE NAME="11grac2"/>
   </NODE_LIST>
</HOME>
</HOME_LIST>

在11g版本时期,上面的这种做法屡试不爽,但在19c版本,上面这种做法竟然遭遇inventory.xml文件损坏。

其实,在MOS文档FAQs on Central Inventory and Oracle Home Inventory (Local Inventory) in Oracle RDBMS (Doc ID 564192.1)中,官方已经明确提出不允许修改inventory.xml文件,否则可能会导致inventory损坏。

•    Oracle recommends that you do not remove or manually edit this file as it could affect installation and patching.
•    OUI lists all the Oracle Homes installed on the node using the inventory.xml file. So if the inventory.xml file is edited, this may lead to inventory corruption.
NOTE : Removing or manually editing ANY file in the oraInventory directory is not supported by Oracle.

 

2、故障分析过程及处理办法

(1). 一套测试的RAC环境,需要重建DB软件,还是按照以前的做法,先直接删除DB软件所在的目录,然后手动修改inventory.xml文件。

(2). 执行runInstaller脚本重新安装DB软件时报错。相应的trace日志如下所示。

oracle.install.commons.base.driver.common.InstallerException: [INS-10102] Installer initialization failed.
        at oracle.install.commons.base.driver.common.Installer.run(Installer.java:317)
        at oracle.install.ivw.common.util.OracleInstaller.run(OracleInstaller.java:106)
        at oracle.install.ivw.db.driver.DBInstaller.run(DBInstaller.java:136)
        at oracle.install.commons.util.Application.startup(Application.java:896)
        at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:165)
        at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:182)
        at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:348)
        at oracle.install.ivw.db.driver.DBInstaller.startup(DBInstaller.java:124)
        at oracle.install.ivw.db.driver.DBInstaller.main(DBInstaller.java:155)
Caused by: oracle.install.commons.base.driver.common.SetupDriverException: [INS-10002] Inventory initialization failed
        at oracle.install.driver.oui.OUISetupDriver.load(OUISetupDriver.java:388)
        at oracle.install.ivw.db.driver.DBSetupDriver.load(DBSetupDriver.java:207)
        at oracle.install.commons.base.driver.common.Installer.run(Installer.java:299)
        ... 8 more

可以看出,执行runInstaller脚本时,提示[INS-10102] Installer initialization failed错误,这个错误是由于[INS-10002] Inventory initialization failed导致的。

(3). 检验inventory.xml文件

$ opatch util LoadXML -xmlInput /u01/app/oraInventory/ContentsXML/inventory.xml
Oracle Interim Patch Installer version 12.2.0.1.37
Copyright (c) 2023, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/19.3.0/grid
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/19.3.0/grid/oraInst.loc
OPatch version    : 12.2.0.1.37
OUI version       : 12.2.0.7.0
Log file location : /u01/app/19.3.0/grid/cfgtoollogs/opatch/opatch2023-11-27_08-29-43AM_1.log

org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 7; <Line 16, Column 7>: XML-20121: (Fatal Error) End tag does not match start tag 'HOME_LIST'.
        at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:425)
        at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:291)

可以看出,该文件已经损坏。

(4). 重建inventory.xml文件,命令如下所示:

$ mv inventory.xml inventory.xml_2023
$ cd $ORACLE_HOME/oui/bin
$ ./runInstaller -silent -attachHome ORACLE_HOME="/u01/app/19.3.0/grid" ORACLE_HOME_NAME="OraGI19Home1" CLUSTER_NODES="{db01,db02}" CRS=true

(5). 再次检测inventory.xml文件。

$ opatch util LoadXML -xmlInput /u01/app/oraInventory/ContentsXML/inventory.xml
Oracle Interim Patch Installer version 12.2.0.1.37
Copyright (c) 2023, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/19.3.0/grid
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/19.3.0/grid/oraInst.loc
OPatch version    : 12.2.0.1.37
OUI version       : 12.2.0.7.0
Log file location : /u01/app/19.3.0/grid/cfgtoollogs/opatch/opatch2023-11-27_08-57-48AM_1.log

Invoking utility "loadxml"
UtilSession: XML file is OK.

OPatch succeeded.

可以看出,inventory.xml文件已经重建成功。

(6). 至此,可以继续执行runInstaller来安装DB软件。

 

3、建议

不要手动修改inventory.xml文件,可能会导致文件损坏。