unix平台下重建oraInventory

客户查看数据库补丁情况,结果报如下错误

OPatch cannot find a valid oraInst.loc file to locate Central Inventory.

OPatch failed with error code 104

经现场分析,是丢失oraInst.loc和oraInventory导致。

以下是测试环境模拟并恢复的过程。(aix6.1+oracle 11.2.0.3单实例)

--查看补丁信息,正常显示
$ ./opatch lsinventory
Oracle Interim Patch Installer version 11.2.0.3.4
Copyright (c) 2012, Oracle Corporation.  All rights reserved.
Oracle Home       : /app/oracle/product/11.2.0/dbhome_1
Central Inventory : /app/oraInventory
   from           : /app/oracle/product/11.2.0/dbhome_1/oraInst.loc
OPatch version    : 11.2.0.3.4
OUI version       : 11.2.0.4.0
Log file location : /app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2016-03-15_16-45-29PM_1.log
Lsinventory Output file location : /app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2016-03-15_16-45-29PM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (1): 
Oracle Database 11g                                                  11.2.0.4.0
There are 1 products installed in this Oracle Home.
There are no Interim patches installed in this Oracle Home.
--------------------------------------------------------------------------------
OPatch succeeded.

--删除oraInst.loc文件和oraInventory目录
# mv /etc/oraInst.loc /etc/oraInst.loc.bak
$ mv $ORACLE_HOME/oraInst.loc $ORACLE_HOME/oraInst.loc.bak --有则删除
$ mv /app/oraInventory /app/oraInventory.bak

--再次查看补丁信息
$ $ORACLE_HOME/OPatch/opatch lsinventory
Oracle Home       : /app/oracle/product/11.2.0/dbhome_1
Central Inventory : n/a
   from           : 
OPatch version    : 11.2.0.3.4
OUI version       : 11.2.0.4.0
Log file location : n/a
OPatch cannot find a valid oraInst.loc file to locate Central Inventory.
OPatch failed with error code 104

至此,问题模拟出来。

以下步骤重建oraInventory

1、重建oraInst.loc (root用户执行)
# vi /etc/oraInst.loc
inventory_loc=/app/oraInventory  --oraInventory通常放在在$ORACLE_BASE目录下
inst_group=oinstall
# chmod 644 /etc/oraInst.loc

2、创建oraInventory(oracley用户执行)
--命令示例
$ORACLE_HOME/oui/bin/runInstaller -silent –attachHome ORACLE_HOME="" ORACLE_HOME_NAME=""

其中和的信息,可以从$ORACLE_HOME/oui/bin/目录下的attachHome.sh文件获取。
$ cat $ORACLE_HOME/oui/bin/attachHome.sh  --输出部分内容
#!/bin/sh
OHOME=/app/oracle/product/11.2.0/dbhome_1
OHOMENAME=OraDb11g_home1

--代入参数值后,执行命令
$ $ORACLE_HOME/oui/bin/runInstaller -silent  -attachHome ORACLE_HOME="/app/oracle/product/11.2.0/dbhome_1" ORACLE_HOME_NAME="OraDb11g_home1"
Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB.   Actual 3456 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /app/oraInventory
'AttachHome' was successful.

3、查看结果
$ ls -lrt /app/oraInventory
total 0
drwxrwx---    2 oracle   oinstall        256 Mar 15 23:54 logs
drwxrwx---    2 oracle   oinstall        256 Mar 15 23:54 ContentsXML

$ $ORACLE_HOME/OPatch/opatch lsinventory
Oracle Interim Patch Installer version 11.2.0.3.4
Copyright (c) 2012, Oracle Corporation.  All rights reserved.
Oracle Home       : /app/oracle/product/11.2.0/dbhome_1
Central Inventory : /app/oraInventory
   from           : /app/oracle/product/11.2.0/dbhome_1/oraInst.loc
OPatch version    : 11.2.0.3.4
OUI version       : 11.2.0.4.0
Log file location : /app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2016-03-16_00-05-04AM_1.log
Lsinventory Output file location : /app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2016-03-16_00-05-04AM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (1): 
Oracle Database 11g                                                  11.2.0.4.0
There are 1 products installed in this Oracle Home.
There are no Interim patches installed in this Oracle Home.
--------------------------------------------------------------------------------
OPatch succeeded.

以上patch信息也正常显示。

深入一步,RAC环境下,如何修复oraInventory目录的丢失呢?
以12cR1 RAC为示例,丢失节点1的oraIventory,和单实例环境的区别就是在创建oraInvenroy时,针对grid用户和oracle用户的产品信息都要注册
以下给出参考命令:
[grid@db1 ~]$ $ORACLE_HOME/oui/bin/runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME="/app/grid" ORACLE_HOME_NAME="OraGI12Home1" LOCAL_NODE="db1" CLUSTER_NODES="{db1,db2}" CRS=true
[oracle@db1 ~]$ $ORACLE_HOME/oui/bin/runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME="/oracle/db" ORACLE_HOME_NAME="OraDB12Home1" LOCAL_NODE="db1" CLUSTER_NODES="{db1,db2}" CRS=true

其实这两条命令在测试的时候,是报错的,以grid用户为例
[grid@db1 bin]$ ./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME="/oracle/grid" ORACLE_HOME_NAME="OraGI12Home1" LOCAL_NODE="db1" CLUSTER_NODES="{db1,db2}" CRS=true
Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB.   Actual 5135 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
SEVERE:Remote 'AttachHome' failed on nodes: 'db2'. Refer to '/oradata/oraInventory/logs/AttachHome2016-03-15_10-13-36PM.log' for details.
It is recommended that the following command needs to be manually run on the failed nodes: 
 /oracle/grid/oui/bin/runInstaller -attachHome -noClusterEnabled ORACLE_HOME=/oracle/grid ORACLE_HOME_NAME=OraGI12Home1 CLUSTER_NODES=db1,db2 CRS=true  "INVENTORY_LOCATION=/oradata/oraInventory" LOCAL_NODE=. 
Please refer 'AttachHome' logs under central inventory of remote nodes where failure occurred for more details.
'AttachHome' failed.

但是实际在检查结果的时候,oraInventory是创建的,而且查询结果也是正确的。
按照oracle推荐命令测试,代入参数,无报错信息。
[grid@db1 ~]$ /oracle/grid/oui/bin/runInstaller -attachHome -noClusterEnabled ORACLE_HOME=/oracle/grid ORACLE_HOME_NAME=OraGI12Home1 CLUSTER_NODES=db1,db2 CRS=true  "INVENTORY_LOCATION=/oradata/oraInventory" LOCAL_NODE=db1
[oracle@db1 ~]$ /oracle/db/oui/bin/runInstaller -attachHome -noClusterEnabled ORACLE_HOME=/oracle/db ORACLE_HOME_NAME=OraDB12Home1 CLUSTER_NODES=db1,db2 CRS=true  "INVENTORY_LOCATION=/oradata/oraInventory" LOCAL_NODE=db1

总结:
1、oraInventory术语名称为Central Inventory,包含了该主机上的oracle产品的信息(可以通过inventory.xml查看)。
2、oraInst.loc术语名称为Central Inventory Pointer File,内容指向了orainventory。不同的平台,存放路径不同,Linux And AIX — /etc/oraInst.loc   Other Unix Platforms — /var/opt/oracle/oraInst.loc。
3、在$ORACLE_HOME下也有一个oraInventory目录,被称为local inventory,主要存放了oracle产品的补丁信息和第三方的应用信息。
   该目录丢失后比较麻烦,丢失后需要重现安装产品软件,oracle建议总是保留该目录最新的备份。
 
参考:MOS ID 564192.1 556834.1 413939.1

end !

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25923810/viewspace-2059476/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25923810/viewspace-2059476/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值