什么是Inventory呢?Inventory是Oracle安装工具OUI用来管理Oracle安装目录的。Inventory里注册了某个ORACLE_HOME下安装的数据库的组件及其版本。Oracle数据库软件的升级、增删组件,都需要使用Inventory。在一台服务器上,Oracle OUI会创建一个全局的Inventory,全局Inventory的目录在oraInst.loc文件中指定。根据操作系统的不同,oraInst.loc所在的目录也不一样。在AIX或者LINUX等系统中,oraInst.loc存放在/etc目录下,在有些操作系统中,这个文件存放在/var/opt/oracle目录下。oraInst.loc文件中包含下面的配置项目:
- Inventory_loc=<oraInventory所在目录>
- inst_group=<OUI安装ORACLE的操作系统组>
比如说,老白的一台测试机上的oraInst.loc内容是这样的:
- Inventory_loc=/opt/oracle/oraInventory
- inst_group=oinstall
这里面有两个信息,第一个是Inventory所在的目录位置,第二个是安装Oracle的组的名称。这个inst_group参数十分重要,它会在link Oracle映像的时候被使用,如果这个参数设置错了,那么link出来的Oracle映像就无法被正常使用了。
在全局Inventory中定义了所有Oracle HOME的情况,这个文件就是ContentsXML目录下的Inventory.xml:
- <?xml version="1.0" standalone="yes" ?>
- <!-- Copyright (c) 2001 Oracle Corporation. All rights Reserved -->
- <!-- Do not modify the contents of this file by hand. -->
- <Inventory>
- <VERSION_INFO>
- <SAVED_WITH>2.2.0.18.0</SAVED_WITH>
- <MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
- </VERSION_INFO>
- <HOME_LIST>
- <HOME NAME="Ora10gHome1" LOC="/opt/oracle/product/10g" TYPE="O" IDX="1"/>
- <HOME NAME="ora9i" LOC="/home/ora9i/product/9204" TYPE="O" IDX="2"/>
- </HOME_LIST>
- </Inventory>
比如上面的例子中,老白的系统上有两个Oracle Home,一个是9i的一个是10g的。
在ORACLE_HOME下面也有一个Inventory目录,这个目录就是我们平时说的Local Inventory。这个Inventory是本地的,每个ORACLE_HOME所独有的。它记录了本ORACLE_HOME中OUI安装的组件的信息。
了解了Inventory的一些基础知识,下面我们就要聊聊了解这些知识有什么好处了。假设这么一个场景,我们去给一个客户的数据库打补丁,到了客户现场,首先使用opatch lsInventory来查看一下当前系统的情况。正常情况显示的数据是这样的:
- Invoking OPatch 10.2.0.4.2
- Oracle Interim Patch Installer version 10.2.0.4.2
- Copyright (c) 2007, Oracle Corporation. All rights reserved.
- Oracle Home : /opt/oracle/product/10g
- Central Inventory : /opt/oracle/oraInventory
- from : /etc/oraInst.loc
- OPatch version : 10.2.0.4.2
- OUI version : 10.2.0.4.0
- OUI location : /opt/oracle/product/10g/oui
- Log file location : /opt/oracle/product/10g/cfgtoollogs/opatch/opatch2011-05-06_11 -41-25AM.log
- LsInventory Output file location : /opt/oracle/product/10g/cfgtoollogs/opatch/lsinv/ lsInventory2011-05-06_11-41-25AM.txt
- --------------------------------------------------------------------------------
- Installed Top-level Products (4):
- Oracle Database 10g 10.2.0.1.0
- Oracle Database 10g Products 10.2.0.1.0
- Oracle Database 10g Release 2 Patch Set 3 10.2.0.4.0
- Oracle Database Vault 10.2.0.4.0
- There are 4 products installed in this Oracle Home.
- There are no Interim patches installed in this Oracle Home.



