⑴ oracle 用opatch查看PSU版本跟查dba_registry_history结果不一样,请问以哪个为准
dba_registry_history
取决于你是否运行过对应PSU的upgrade script,
opatch显示的取决于你是否打过对应的PSU 补丁,一般以opatch为准
⑵ 怎么检查oracle都安装了哪些patch
我们在windows上安装了测试环境oracle10g,路径E:\oracle\proct\10.2.0\db_1\OPatch,点击执行opatch.bat,报错“Oracle Home is not set. OPatch cannot proceed!”。在环境变量里面配置ORACLE_HOME路径E:\oracle\proct\10.2.0\db_1\,再次执行opatch.bat lsinventory,输出:
Invoking OPatch 10.2.0.1.0
Oracle 中间补丁程序安装程序版本 10.2.0.1.0
版权所有 (c) 2005, Oracle Corporation。保留所有权利。。
Oracle 主目录 : E:\oracle\proct\10.2.0\db_1
主产品清单: n/a
从 : C:\Program Files\Oracle\Inventory
OPatch 版本 : 10.2.0.1.0
OUI 版本 : 10.2.0.1.0
OUI 位置 : E:\oracle\proct\10.2.0\db_1\oui
日志文件位置 : E:\oracle\proct\10.2.0\db_1\cfgtoollogs\opatch\opatch-2007_Jul_
09_10-42-17-CST_Mon.log
Lsinventory Output file location : E:\oracle\proct\10.2.0\db_1\cfgtoollogs\opa
tch\lsinv\lsinventory-2007_Jul_09_10-42-17-CST_Mon.txt
--------------------------------------------------------------------------------
已安装的顶级产品 (1):
Oracle Database 10g 10.2.0.1.0
此 Oracle 主目录中已安装 1 个产品。
此 Oracle 主目录中未安装任何中间补丁程序。
⑶ 打完补丁oracle会更新bin的oracle吗
电梯直达
1#
发表于 2014-6-28 00:23 | 只看该作者 |倒序浏览 |阅读模式
本帖最后由 suyuanwu 于 2014-6-28 18:10 编辑
1.更新Opatch;
2.打补丁;
3.grid 打补丁;
1.更新Opatch(实验版本: oracle:11.2.0.3.0):
默认安装数据库后,在ORACLE_HOME 下会有个OPatch 文件夹,更新前先检查当前Opatch 版本:
[oracle@sywu2 OPatch]$ ./opatch lsinventory
Invoking OPatch 11.2.0.1.7
Oracle 中间补丁程序安装程序版本 11.2.0.1.7
版权所有 (c) 2011, Oracle Corporation。保留所有权利。
Oracle Home : /s01/app/oracle/proct/11.2.0/dbhome_1
Central Inventory : /g01/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.7
OUI version : 11.2.0.3.0
Log file location : /s01/app/oracle/proct/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2014-06-27_23-03-26下午.log
注:有些时候产品清单加载失败,会导致打补丁时出错
[sywu@sywu OPatch]$ ./opatch lsinventory
Invoking OPatch 11.1.0.6.6
Oracle 中间补丁程序安装程序版本 11.1.0.6.6
版权所有 (c) 2009, Oracle Corporation。保留所有权利。
Oracle 主目录 : /u01/app/proct/11.2.0/db_1
主产品清单: /g01/oraInventory
从 : /etc/oraInst.loc
OPatch 版本 : 11.1.0.6.6
OUI 版本 : 11.2.0.1.0
OUI 位置 : /u01/app/proct/11.2.0/db_1/oui
日志文件位置 : /u01/app/proct/11.2.0/db_1/cfgtoollogs/opatch/opatch2014-06-27_21-51-13下午.log
Patch history file: /u01/app/proct/11.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt
List of Homes on this system:
Home name= Ora11g_gridinfrahome1, Location= "/g01/11ggrid/11.2.0/grid"
Home name= OraDb11g_home1, Location= "/s01/app/oracle/proct/11.2.0/dbhome_1"
产品清单加载失败... OPatch cannot load inventory for the given Oracle Home.
Possible causes are:
Oracle Home dir. path does not exist in Central Inventory
Oracle Home is a symbolic link
Oracle Home inventory is corrupted
LsInventorySession 失败: OracleHomeInventory gets null oracleHomeInfo
OPatch failed with error code 73
解决方法:
1)找到产品清单文件,默认安装成功后会在 /etc/oraInst.loc 和oracle 根目录 oraInventory 文件夹下 ,如果/etc/下没有就到ORACLE 安装根目录找到文件夹: oraInventory,里面有oraInst.loc;复制一个到 /etc下
2)到$ORACLE_HOME/oui/bin/ 执行如下脚本加载清单:
./runInstaller -silent -attachHome \
ORACLE_HOME=$ORACLE_HOME \
ORACLE_HOME_NAME="ORACLE_HOME"
3) 加载成功后再次到OPatch目录下执行 ./opatch lsinventory 确认产品清单加载是否成功;
有些时候你打过补丁,然后删除过$ORACLE_HOME/.patch_storage 下的文件,下次重新再打补丁是可能会报:" OracleHomeInventory 无法创建锁文件",怎么处理都不行,也并不是操作权限问题:
[grid@sywu2 shared]$ opatch lsinventory
Oracle 中间补丁程序安装程序版本 11.2.0.3.3
版权所有 (c) 2012, Oracle Corporation。保留所有权利。
Oracle Home : /g01/11ggrid/11.2.0/grid
Central Inventory : /g01/oraInventory
from : /g01/11ggrid/11.2.0/grid/oraInst.loc
OPatch version : 11.2.0.3.3
OUI version : 11.2.0.3.0
Log file location : /g01/11ggrid/11.2.0/grid/cfgtoollogs/opatch/opatch2014-06-28_16-51-09下午_1.log
OracleHomeInventory 无法创建锁文件, 可能是由于 OPatch 会话失败。加载的产品清单可能无法正确显示 Oracle 主目录中的内容。
Lsinventory Output file location : /g01/11ggrid/11.2.0/grid/cfgtoollogs/opatch/lsinv/lsinventory2014-06-28_16-51-09下午.txt
解决方法:
1)首先查看 $ORACLE_HOME/.patch_storage 目录下是否有patch_locked 文件:
[grid@sywu2 shared]$ ls -las $ORACLE_HOME/.patch_storage
总用量 32
4 drwxr-x--- 4 grid oinstall 4096 6月 28 16:55 .
4 drwxr-xr-x 68 grid oinstall 4096 6月 28 16:55 ..
4 drwxr-xr-x 5 grid oinstall 4096 6月 28 11:18 15876003_Jan_11_2013_06_19_07
4 -rw-r--r-- 1 grid oinstall 1949 6月 28 11:18 interim_inventory.txt
4 -rw-r--r-- 1 grid oinstall 93 6月 28 11:18 LatestOPatchSession.properties
4 drwxr-xr-x 3 grid oinstall 4096 6月 28 11:17 NApply
4 -rw-r--r-- 1 grid oinstall 56 6月 28 11:18 patch_locked
4 -rw-r--r-- 1 grid oinstall 52 6月 28 11:18 record_inventory.txt
2)如果有,将patch_locked 文件命名为其它名或移走,然后再次尝试 opatch lsinventory:
[grid@sywu2 shared]$ mv /g01/11ggrid/11.2.0/grid/.patch_storage/patch_locked /g01/11ggrid/11.2.0/grid/.patch_storage/patch_locked_bkp
[grid@sywu2 shared]$ opatch lsinventory
Oracle 中间补丁程序安装程序版本 11.2.0.3.3
版权所有 (c) 2012, Oracle Corporation。保留所有权利。
Oracle Home : /g01/11ggrid/11.2.0/grid
Central Inventory : /g01/oraInventory
from : /g01/11ggrid/11.2.0/grid/oraInst.loc
OPatch version : 11.2.0.3.3
OUI version : 11.2.0.3.0
Log file location : /g01/11ggrid/11.2.0/grid/cfgtoollogs/opatch/opatch2014-06-28_17-01-51下午_1.log
Lsinventory Output file location : /g01/11ggrid/11.2.0/grid/cfgtoollogs/opatch/lsinv/lsinventory2014-06-28_17-01-51下午.txt
这是因为 patch_locked 文件中记录了相关补丁号,当加载时出错或找不到它:
[grid@sywu2 shared]$ cat /g01/11ggrid/11.2.0/grid/.patch_storage/patch_locked_bkp
Locked for patch : 15876003
Locked by class : apply
1.1 更新前先备份原来的Opatch:
[oracle@sywu2 dbhome_1]$ tar -cvf Opatch_20140627.tar OPatch
1.2 解压新版Opatch 文件到$ORACLE_HOME 目录下:
[oracle@sywu2 dbhome_1]$ /tmp/unzip p6880880_112000_linux-x86-64.zip -d $ORACLE_HOME
Archive: p6880880_112000_Linux-x86-64.zip
creating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/README.html
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/README.txt
creating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/oplan.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/oracle.oplan.classpath.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/automation.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/OsysModel.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/EMrepoDrivers.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/Validation.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/ValidationRules.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/osysmodel-utils.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/CRSProctDriver.jar
creating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/apache-commons/
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/apache-commons/commons-cli-1.0.jar
creating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/activation.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/jaxb-api.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/jaxb-impl.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/jsr173_1.0_api.jar
inflating: /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/oplan/oplan
replace /s01/app/oracle/proct/11.2.0/dbhome_1/OPatch/docs/FAQ? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
.............
1.3 确认OPatch 更新是否成功:
[oracle@sywu2 OPatch]$ ./opatch version
OPatch Version: 11.2.0.3.3
OPatch succeeded.
可能会有未知错误,如版本问题,操作前一定记得备份原来的OPatch;
2.打补丁:
打补丁前要关闭数据库实例、监听程序,补丁要与更新的OPatch对应:
2.1 解压补丁文件到$ORACLE_HOME 目录下:
[oracle@sywu2 OPatch]$ unzip /tmp/p14727310_112030_Linux-x86-64.zip -d $ORACLE_HOME
[oracle@sywu2 dbhome_1]$ cd 14727310/
[oracle@sywu2 14727310]$ ls
13343438 13696216 13923374 14275605 14727310 patchmd.xml README.html README.txt
README.html 文件上有介绍打补丁方法,打补丁前先查看一下;
开始打补丁:
[oracle@sywu2 14727310]$ $ORACLE_HOME/OPatch/opatch apply
2.2 将变更的 SQL Files 导入数据库:
[oracle@sywu2 ~]$ cd $ORACLE_HOME/rdbms/admin
[oracle@sywu2 admin]$ sqlplus / as sysdba
SQL> @catbundle.sql psu apply
打补丁信息在 V$version 视图中是查询不到的,要通过 dba_registry_history 视图查询:
SQL> select action_time,action,namespace,version,bundle_series,comments from dba_registry_history;
ACTION_TIME ACTION NAMESPACE VERSION
--------------------------------------------------------------------------- ---------- ---------- ------------------------------
BUNDLE_SERIES COMMENTS
--------------------
⑷ 如何安装/升级Opatch
1、 环境介绍
我们选择11gR2作为实验环境。
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Proction
PL/SQL Release 11.2.0.1.0 - Proction
CORE 11.2.0.1.0 Proction
在安装目录$ORACLE_HOME下,是自带一个OPatch工具包的。一般小版本的升级,都是通过OPatch来完成。
[oracle@bsplinux ~]$ cd $ORACLE_HOME
[oracle@bsplinux oracle]$ ls -l | grep OPatch
drwxr-xr-x 8 oracle oinstall 4096 Oct 23 20:00 OPatch
不过,同Oracle自带的Uninstall一样,11.2.0.1自带的OPatch的版本是不能提供升级功能的。所以,我们通常需要首先升级OPatch,之后才能进行打补丁。
2、OPatch升级
首先,我们需要确定当前的OPatch版本。进入OPatch目录之后,可以通过版本首先确认。
[oracle@bsplinux OPatch]$ ls -l
total 92
drwxr-xr-x 2 oracle oinstall 4096 May 22 16:16 docs
-rw-r--r-- 1 oracle oinstall 21576 May 6 2009 emdpatch.pl
drwxr-xr-x 2 oracle oinstall 4096 May 22 16:16 jlib
drwxr-xr-x 5 oracle oinstall 4096 May 22 16:16 ocm
-rwxr-xr-x 1 oracle oinstall 8709 May 6 2009 opatch
-rw-r--r-- 1 oracle oinstall 49 May 22 16:22 opatch.ini
-rw-r--r-- 1 oracle oinstall 2576 May 6 2009 opatch.pl
drwxr-xr-x 4 oracle oinstall 4096 May 22 16:16 opatchprereqs
[oracle@bsplinux OPatch]$ ./opatch version
Invoking OPatch 11.1.0.6.6
OPatch Version: 11.1.0.6.6
OPatch succeeded.
11.2.0.1自带的OPatch版本为11.1.0.6.6,我们需要首先升级OPatch。第一步是进行原有OPatch备份。
[oracle@bsplinux oracle]$ tar zcvf opatch_bk.tar OPatch
OPatch/
OPatch/opatchprereqs/
OPatch/opatchprereqs/prerequisite.properties
(篇幅原因,省略部分内容)
OPatch/jlib/opatchprereq.jar
OPatch/opatch
OPatch/opatch.ini
[oracle@bsplinux oracle]$ ls -l | grep opatch
-rw-r--r-- 1 oracle oinstall 1187195 Oct 23 19:06 opatch_bk.tar
最新版本的OPatch可以从MOS上面下载到,补丁文件名称为:p6880880_112000_LINUX.zip(For Linux 32)。
[oracle@bsplinux upload]$ ls -l | grep p688
-rw-r--r-- 1 root root 32510812 Oct 23 19:58 p6880880_112000_LINUX.zip
--解压到ORACLE_HOME目录上
[oracle@bsplinux upload]$ unzip p6880880_112000_LINUX.zip -d $ORACLE_HOME
Archive: p6880880_112000_LINUX.zip
creating: /u01/app/oracle/OPatch/oplan/
(篇幅原因,省略部分……)
inflating: /u01/app/oracle/OPatch/crs/s_crsconfig_defs
inflating: /u01/app/oracle/OPatch/crs/s_crsconfig_lib.pm
之后,验证OPatch安装成功。
[oracle@bsplinux OPatch]$ ./opatch version
OPatch Version: 11.2.0.3.0
OPatch succeeded.
[oracle@bsplinux OPatch]$
3、补丁安装
如果OPatch不是最新的版本,直接安装PSU可能会有各种的问题。更新OPatch之后,我们就可以下载对应的PSU进行更新。
[oracle@bsplinux upload]$ ls -l | grep p12
-rw-r--r-- 1 root root 18510829 Oct 23 19:35 p12419378_112010_LINUX.zip
[oracle@bsplinux upload]$ unzip p12419378_112010_LINUX.zip -d $ORACLE_HOME
(省略)
[oracle@bsplinux oracle]$ cd 12419378/
[oracle@bsplinux 12419378]$ ls -l
total 60
drwxr-xr-x 3 oracle oinstall 4096 Jul 8 2011 custom
drwxr-xr-x 4 oracle oinstall 4096 Jul 8 2011 etc
drwxr-xr-x 12 oracle oinstall 4096 Jul 8 2011 files
-rwxr-xr-x 1 oracle oinstall 2871 Jul 8 2011 patchmd.xml
-rw-rw-r-- 1 oracle oinstall 40790 Jul 18 2011 README.html
-rw-r--r-- 1 oracle oinstall 21 Jul 8 2011 README.txt
将数据库和监听程序关闭。
[oracle@bsplinux OPatch]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Proction on Tue Oct 23 19:26:11 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Proction
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@bsplinux OPatch]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.1.0 - Proction on 23-OCT-2012 19:26:55
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully