Developer Data Modeling Mistakes: From Postgres to NoSQL
11g新特性 在线实施补丁online patching
1. 11g 新特性-在线实施补丁
online patching
by Maclean.liu
liu.maclean@gmail.com
www.oracledatabase12g.com
2. About Me
l Email:liu.maclean@gmail.com
l Blog:www.oracledatabase12g.com
l Oracle Certified Database Administrator Master 10g
and 11g
l Over 6 years experience with Oracle DBA technology
l Over 7 years experience with Linux technology
l Member Independent Oracle Users Group
l Member All China Users Group
l Presents for advanced Oracle topics: RAC,
DataGuard, Performance Tuning and Oracle Internal.
3. 在 Oracle 11g 中提出了 online patch(也叫 hot patch)的特性;Hot patching 允许我们在实例始终在线的情况下安
装,启用或禁用一个修复补丁或者诊断补丁。针对 7*24 在线的业务系统,hot patch 为我们提供了一条既能避免
当机时间而又可以实施补丁的途径。在 Oracle 11g 中我们可以使用 Opatch 命令行工具针对任意数据库实施在线
补丁(前提是该补丁是一个 hot patch)。一般来说在线补丁(hot patches)只能是那些代码修改范围小且复杂度很低
的补丁,举例来说它们往往是一些诊断补丁(diagnostic patches)或者小 bug 的修复(small bug fixes)。值得注意的
是 hot patching 将需要消耗额外的内存,决定其消耗内存数量的因素是:1.补丁本身的大小,2.实例中的进程总数;
举例来说某个补丁的大小正好为一个 OS page 的大小(一般为 4kB),那么当实例中运行的进程总数为 1000 时,
则该 hot patching 所额外消耗的内存总数为 4kB*1000=4MB。
hot patches 与常规 Conventional patches 对比具有可在线实施和安装快的特性,如下图:
在实际生产环境中,相信没有多少朋友实施过 hot patching,一来国内目前还没有普及 11g 的使用,二来 hot
patching 的数量在所有 interim patch 中只占极少数;一直以来都想写这样一篇关于 hot patching 的博文,唯一妨
碍我写作的问题是在 11.2.0.1 下找不到可实施的 online interim patch;以 MOS->patches&upgrade 目前的分类我
们很难找出某个 base release 下可用的 hot patch,当然这并不妨碍补丁专栏的使用。为了这个令人郁闷的问
题,我特意去提交了一个 Service Request,得到的回复:
I have tried to find the patches which support online patching on 11.2.0.1 version,
but I also can not find them because there are too many patches and there is no catalog
for the patches
which support online patching, and I can only check the patch readme to confirm whether
that patch supports online patching.
I found one patch which supports online patching, but this patch is for 11.2.0.2 version.
The patch no. is 10188727.
4. Sorry for the inconvenience brought to you. Hope the above update can help you.
If the above patch is not what you want, then please update the SR and I will continue
for your issue.
这其中提到的 patch 10188727,可以从 Note<RDBMS Online Patching Aka Hot Patching [ID 761111.1]>中找
到,另外一个可找到的 hot patch 是 11.1.0.6 上的 6198642<DUMMY PATCH FOR TESTING DB11
PATCHING>,不过很可惜该补丁只有 Linux x86 一个平台版本的。所以我不得不先将 11.2.0.1 的测试库升级到了
11.2.0.2 上:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
[maclean@rh2 OPatch]$ ps -ef|grep pmon|grep -v grep
maclean 22481 1 0 19:19 ? 00:00:00 ora_pmon_PROD
[maclean@rh2 OPatch]$ pmap -d 22481
22481: ora_pmon_PROD
Address Kbytes Mode Offset Device Mapping
0000000000400000 180232 r-x-- 0000000000000000 008:00002 oracle
000000000b602000 1820 rwx-- 000000000b002000 008:00002 oracle
000000000b7c9000 300 rwx-- 000000000b7c9000 000:00000 [ anon ]
000000000dbef000 436 rwx-- 000000000dbef000 000:00000 [ anon ]
0000000060000000 2050048 rwxs- 0000000000000000 000:00009 [ shmid=0x550001 ]
0000003e09a00000 112 r-x-- 0000000000000000 008:00001 ld-2.5.so
0000003e09c1b000 4 r-x-- 000000000001b000 008:00001 ld-2.5.so
0000003e09c1c000 4 rwx-- 000000000001c000 008:00001 ld-2.5.so
0000003e09e00000 1336 r-x-- 0000000000000000 008:00001 libc-2.5.so
0000003e09f4e000 2044 ----- 000000000014e000 008:00001 libc-2.5.so
0000003e0a14d000 16 r-x-- 000000000014d000 008:00001 libc-2.5.so
0000003e0a151000 4 rwx-- 0000000000151000 008:00001 libc-2.5.so
0000003e0a152000 20 rwx-- 0000003e0a152000 000:00000 [ anon ]
0000003e0a200000 520 r-x-- 0000000000000000 008:00001 libm-2.5.so
8. Oracle Interim Patch Installer version 11.2.0.1.1
Copyright (c) 2009, Oracle Corporation. All rights reserved.
Oracle Home : /s01/product/11.2.0/dbhome_2
Central Inventory : /s01/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.1
OUI version : 11.2.0.2.0
OUI location : /s01/product/11.2.0/dbhome_2/oui
Log file location : /s01/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-02-17_20-
05-21PM.log
Patch history file: /s01/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch_history.txt
--------------------------------------------------------------------------------
Patch created on 2 Dec 2010, 01:44:13 hrs PST8PDT
Need to shutdown Oracle instances: true
Patch is roll-backable: true
Patch is a "Patchset Update": false
Patch is a rolling patch: true
Patch has sql related actions: false
Patch is an online patch: false
Patch is a portal patch: false
Patch is an "auto-enabled" patch: false
List of platforms supported:
226: Linux x86-64
List of bugs to be fixed:
10188727: AFTER UPGRADING TO 11.2.0.2 SOME SQLS FAIL WITH ORA-7445 [KKEIDC()+180] ERROR
This patch is a "singleton" patch.
This patch belongs to the "db" product family
List of executables affected:
ORACLE_HOME/bin/oracle
List of optional components:
oracle.rdbms: 11.2.0.2.0
9. List of optional actions:
Update /s01/product/11.2.0/dbhome_2/lib/libserver11.a with /kkopq.o
cd /s01/product/11.2.0/dbhome_2/rdbms/lib
; make -f ins_rdbms.mk ioracle ORACLE_HOME=/s01/product/11.2.0/dbhome_2
Possible XML representation of the patch:
10188727
--------------------------------------------------------------------------------
OPatch succeeded.
[maclean@rh2 OPatch]$ ./opatch query -is_online_patch 10188727
Invoking OPatch 11.2.0.1.1
Oracle Interim Patch Installer version 11.2.0.1.1
Copyright (c) 2009, Oracle Corporation. All rights reserved.
Oracle Home : /s01/product/11.2.0/dbhome_2
Central Inventory : /s01/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.1
OUI version : 11.2.0.2.0
OUI location : /s01/product/11.2.0/dbhome_2/oui
Log file location : /s01/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-02-17_19-
45-33PM.log
Patch history file: /s01/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch_history.txt
--------------------------------------------------------------------------------
Patch is an online patch: false
OPatch succeeded.
/* 虽然 Opatch 返回"online patch: false",但实际上这是一个 online patch,
造成以上问题的原因可能是 Opatch 版本低 */
[maclean@rh2 OPatch]$ tree 10188727
10188727
|-- README.txt
|-- etc
| |-- config
11. Copyright (c) 2009, Oracle Corporation. All rights reserved.
Oracle Home : /s01/product/11.2.0/dbhome_2
Central Inventory : /s01/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.1
OUI version : 11.2.0.2.0
OUI location : /s01/product/11.2.0/dbhome_2/oui
Log file location : /s01/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-02-17_19-
49-44PM.log
Patch history file: /s01/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch_history.txt
The patch should be applied/rolled back in '-all_nodes' mode only.
Converting the RAC mode to '-all_nodes' mode.
ApplySession applying interim patch '10188727' to OH '/s01/product/11.2.0/dbhome_2'
Running prerequisite checks...
OPatch detected non-cluster Oracle Home from the inventory and will patch the local
system only.
Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '10188727' for restore. This might take a while...
Backing up files affected by the patch '10188727' for rollback. This might take a
while...
Patching component oracle.rdbms, 11.2.0.2.0...
The patch will be installed on active database instances.
Installing and enabling the online patch 'bug10188727.pch', on database 'PROD'.
ApplySession adding interim patch '10188727' to inventory
Verifying the update...
Inventory check OK: Patch ID 10188727 is registered in Oracle Home inventory with proper
meta-data.
Files check OK: Files from Patch ID 10188727 are present in Oracle Home.
OPatch succeeded.
[maclean@rh2 OPatch]$ opatch lsinventory -detail|tail -21
Interim patches (1) :
Patch (online) 10188727: applied on Thu Feb 17 19:49:52 CST 2011
14. [maclean@rh2 OPatch]$ opatch rollback -id 10188727 -connectString PROD:sys:d2nb51tz
-invPtrLoc /s01/product/11.2.0/dbhome_2/oraInst.loc
Invoking OPatch 11.2.0.1.1
Oracle Interim Patch Installer version 11.2.0.1.1
Copyright (c) 2009, Oracle Corporation. All rights reserved.
Oracle Home : /s01/product/11.2.0/dbhome_2
Central Inventory : /s01/oraInventory
from : /s01/product/11.2.0/dbhome_2/oraInst.loc
OPatch version : 11.2.0.1.1
OUI version : 11.2.0.2.0
OUI location : /s01/product/11.2.0/dbhome_2/oui
Log file location : /s01/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-02-17_20-
18-00PM.log
Patch history file: /s01/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch_history.txt
RollbackSession rolling back interim patch '10188727' from OH
'/s01/product/11.2.0/dbhome_2'
The patch should be applied/rolled back in '-all_nodes' mode only.
Converting the RAC mode to '-all_nodes' mode.
Running prerequisite checks...
OPatch detected non-cluster Oracle Home from the inventory and will patch the local
system only.
Backing up files affected by the patch '10188727' for restore. This might take a while...
Patching component oracle.rdbms, 11.2.0.2.0...
The patch will be removed from active database instances.
Disabling and removing online patch 'bug10188727.pch', on database 'PROD'
RollbackSession removing interim patch '10188727' from inventory
OPatch succeeded.
告警日志 alert.log 中的 remove 信息:
Patch bug10188727.pch Disabled - Update #5
Patch bug10188727.pch Removed - Update #6
Thu Feb 17 20:18:07 2011