Online Patching 說明
創新互聯擁有一支富有激情的企業網站制作團隊,在互聯網網站建設行業深耕10余年,專業且經驗豐富。10余年網站優化營銷經驗,我們已為上千多家中小企業提供了成都網站制作、網站建設解決方案,按需網站建設,設計滿意,售后服務無憂。所有客戶皆提供一年免費網站維護!
說明:該部分內容摘自OCP 050 教材。
在Oracle 11g中提出了online patch(也叫hot patch)的特性;Hot patching允許我們在實例始終在線的情況下安裝,啟用或禁用一個修復補丁(fix)或者診斷補丁(diagnostic patches)。
使用熱補丁可以安裝、啟用和禁用正在運行的活動Oracle 實例上的bug 修復或診斷補丁程序。使用熱補丁是可在應用熱補丁程序時避免停機的建議解決方案。Oracle 提供了使用opatch 命令行實用程序對任何Oracle 數據庫進行熱補丁的功能。如果代碼的更改范圍和復雜性都較小(例如,診斷補丁程序或小型bug 修復),則可提供熱補丁程序。
2.1 安裝熱補丁程序
(1) 應用熱補丁程序不需要關閉實例、重新鏈接Oracle二進制文件或重新啟動實例。
(2) OPatch 可用于安裝或卸載熱補丁程序。
(3) OPatch 可以檢測兩個熱補丁程序之間以及熱補丁程序與常規補丁程序之間的沖突。
可以使用以下命令來確定某個補丁程序是否為熱補丁程序:
opatch query -is_online_patch <patchlocation> or
opatch query <patch location> -all
注:
打過補丁的代碼將作為動態/共享庫提供,該庫隨后會被每個Oracle 進程映射至內存中。
(關于熱補丁的機制可以參考1.2 節的內容。)
2.2 熱補丁的優點
(1) 無停機時間,不中斷業務
(2) 安裝和卸載速度極快
(3) 與OPatch 集成:
檢測沖突
在補丁程序清單中列出
在RAC 環境中工作
(4) 雖然不改變磁盤上的Oracle二進制文件,但熱補丁程序在實例關閉和啟動時都保持有效。
2.3 常規補丁和熱補丁
常規補丁基本上要求關閉數據庫實例。
熱補丁不需要任何停機時間。在安裝熱補丁時,應用程序可以繼續運行。
同樣的,無需停機便可卸載已安裝的熱補丁程序。
常規補丁和熱補丁的對比,如下圖:
2.4 熱補丁注意事項
(1)可能不是所有平臺上都有熱補丁程序。當前在以下平臺上有熱補丁程序:
– Linux x86
– Linux x86-64
– Solaris SPARC64
--這個具體可以參考:1.3 小節。
(2)要消耗一些額外的內存。
– 確切的內存數取決于:
— 補丁程序的大小
— 當前運行的Oracle 進程數
– 最小內存數:每個Oracle 進程大約占一個OS 頁面
如:一個操作系統(OS) 頁面在Linux x86 上一般為4 KB,在和Solaris SPARC64 上為8 KB。
在平均大約一千個Oracle 進程同時運行的情況下,這意味著一個小型的熱補丁程序大約額外占用4 MB 內存。
(3) 在每個Oracle 進程安裝或卸載熱補丁程序之前,可能會有一段極短的延遲(幾秒)。
(4) 并非所有bug 修復和診斷補丁程序都可用作熱補丁程序。
極大部分診斷補丁程序可作為熱補丁程序提供。對于bug 修復,則具體取決于其性質。并非每個bug 修復或診斷補丁程序都可用作熱補丁程序。但熱補丁工具的長期目標是為關鍵補丁程序更新提供熱補丁功能。
(5) 不能在停機時間使用熱補丁程序。
(6) 如果可能有停機時間,則應以常規補丁程序方式安裝所有相關的bug 修復。
三. Online Patch 操作示例
測試環境是11.2.0.3:
SQL> select * from v$version;
BANNER
--------------------------------------------
Oracle Database 11g Enterprise EditionRelease 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 -Production
NLSRTL Version 11.2.0.3.0 – Production
Google了一下,找了一個對應版本的onlinepatch:
Oracle online patching for bug 13817131(backport for ORA-7445 near ksfqfcrx()+X during RMAN backups)
http://jakub.wartak.pl/blog/?p=624
這里用online patch:13817131的相關操作為例。
3.1 解壓縮:
[oracle@dave u01]$ unzipp13817131_112030_Linux-x86-64.zip
Archive: p13817131_112030_Linux-x86-64.zip
creating: 13817131/
creating: 13817131/etc/
creating: 13817131/etc/xml/
inflating: 13817131/etc/xml/ShiphomeDirectoryStructure.xml
inflating: 13817131/etc/xml/GenericActions.xml
creating: 13817131/etc/config/
inflating: 13817131/etc/config/inventory.xml
inflating: 13817131/etc/config/actions.xml
inflating: 13817131/etc/config/deploy.xml
creating: 13817131/online/
creating: 13817131/online/files/
creating: 13817131/online/files/hpatch/
inflating: 13817131/online/files/hpatch/bug13817131.pch
creating: 13817131/online/etc/
creating: 13817131/online/etc/xml/
inflating: 13817131/online/etc/xml/GenericActions.xml
inflating: 13817131/online/etc/xml/ShiphomeDirectoryStructure.xml
creating: 13817131/online/etc/config/
inflating: 13817131/online/etc/config/actions.xml
inflating: 13817131/online/etc/config/deploy.xml
inflating: 13817131/online/etc/config/inventory.xml
creating: 13817131/files/
creating: 13817131/files/lib/
creating: 13817131/files/lib/libserver11.a/
inflating: 13817131/files/lib/libserver11.a/ksfq.o
inflating: 13817131/README.txt
3.2 查看Patch 類型3.2.1 用樹形結構看一下:如果是online patch,會有online 的目錄:
[oracle@dave u01]$ ls
13817131 dave dave2.trc p13817131_112030_Linux-x86-64.zip rcopy.sh rename.sh
app dave1.trc nohup.out rcopy.out rcopy.sh.out
[oracle@dave u01]$ tree 13817131
13817131
|-- etc
| |-- config
| | |-- actions.xml
| | |-- deploy.xml
| | `-- inventory.xml
| `-- xml
| |-- GenericActions.xml
| `-- ShiphomeDirectoryStructure.xml
|-- files
| `-- lib
| `-- libserver11.a
| `-- ksfq.o
|-- online
| |-- etc
| | |-- config
| | | |-- actions.xml
| | | |-- deploy.xml
| | | `-- inventory.xml
| | `-- xml
| | |-- GenericActions.xml
| | `--ShiphomeDirectoryStructure.xml
| `-- files
| `-- hpatch
| `-- bug13817131.pch
`-- README.txt
12 directories, 13 files
3.2.2 使用opatch 查看patch 類型:
[oracle@dave u01]$ mv 13817131/u01/app/oracle/product/11.2.0/db_1/OPatch
[oracle@dave u01]$ cd/u01/app/oracle/product/11.2.0/db_1/OPatch
[oracle@dave OPatch]$ ls
13817131 emdpatch.pl jlib opatch opatch.ini opatchprereqs
docs fmw ocm opatch.bat opatch.pl
[oracle@dave OPatch]$ ./opatch query 13817131 -all
Invoking OPatch 11.2.0.1.7
Oracle Home : /u01/app/oracle/product/11.2.0/db_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.7
OUI version : 11.2.0.3.0
Log file location :/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch3012-10-09_19-00-40????.log
--------------------------------------------
Patch created on 25 Sep 2012, 08:46:37 hrsPST8PDT
Needto 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
Listof platforms supported:
226: Linux x86-64
Listof bugs to be fixed:
13817131: OAM ORA-7445-[KSFQFCRX()+812] [SIGSEGV] [ADDR 0X8 ]
Thispatch is a "singleton" patch.
Thispatch belongs to the "db" product family
Listof executables affected:
ORACLE_HOME/bin/oracle
Listof optional components:
oracle.rdbms: 11.2.0.3.0
Listof optional actions:
Update /u01/app/oracle/product/11.2.0/db_1/lib/libserver11.a with/ksfq.o
cd/u01/app/oracle/product/11.2.0/db_1/rdbms/lib
; make -f ins_rdbms.mk ioracleORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
Possible XML representation of the patch:
<ONEOFF REF_ID="13817131"ROLLBACK="T" XML_INV_LOC="oneoffs/13817131/"ACT_INST_VER="11.2.0.3.0" INSTALL_TIME="2012.Oct.09 19:00:40CST">
<DESC></DESC>
<REF_LIST>
<REF NAME="oracle.rdbms" VER="11.2.0.3.0"HOME_IDX="0"/>
</REF_LIST>
<BUG_LIST>
<BUG>13817131</BUG>
</BUG_LIST>
<FILE_LIST/>
</ONEOFF>
--------------------------------------------
OPatch succeeded.
這里顯示為False。 用opatch is_online_patch 查看:
[oracle@dave OPatch]$ ./opatch query -is_online_patch 13817131
Invoking OPatch 11.2.0.1.7
Oracle Home : /u01/app/oracle/product/11.2.0/db_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.7
OUI version : 11.2.0.3.0
Log file location :/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch3012-10-09_19-02-47????.log
--------------------------------------------
Patch is an online patch: false
OPatch succeeded.
這里顯示的還是為False,但實際上,我們的Patch 確實是online 的patch。
3.3 應用Patch并確認Online Patch 對內存的消耗:
安裝online patch需要額外的消耗一些內存資源,所以這里我們驗證一下:
--查看pmon 進程的內存消耗:
[oracle@dave 13817131]$ ps -ef|grep pmon|grep-v grep
oracle 2118 1 0 15:15 ? 00:00:13 ora_pmon_dave
[oracle@dave 13817131]$ pmap -d 2118 |tail -20
00007fb4ef13a000 1020 ----- 0000000000289000 008:00003libnnz11.so
00007fb4ef239000 264 rwx-- 0000000000288000 008:00003libnnz11.so
00007fb4ef27b000 12 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef28d000 4 rwxs- 0000000000000000 008:00003hc_dave.dat
00007fb4ef28e000 8 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef290000 864 r-x-- 0000000000000000 008:00003libskgxp11.so
00007fb4ef368000 1024 ----- 00000000000d8000 008:00003libskgxp11.so
00007fb4ef468000 8 rwx-- 00000000000d8000 008:00003libskgxp11.so
00007fb4ef46a000 392r-x-- 0000000000000000 008:00003 libcell11.so
00007fb4ef4cc000 1024 ----- 0000000000062000 008:00003libcell11.so
00007fb4ef5cc000 40 rwx-- 0000000000062000 008:00003libcell11.so
00007fb4ef5d6000 8 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef5d8000 4 r-x-- 0000000000000000 008:00003libodmd11.so
00007fb4ef5d9000 1024 ----- 0000000000001000 008:00003libodmd11.so
00007fb4ef6d9000 4 rwx-- 0000000000001000 008:00003libodmd11.so
00007fb4ef6da000 4 rwx-- 0000000000000000 000:00000 [ anon ]
00007ffff0261000 132 rwx-- 0000000000000000 000:00000 [ stack ]
00007ffff03f6000 4 r-x-- 0000000000000000 000:00000 [ anon ]
ffffffffff600000 4 r-x-- 0000000000000000 000:00000 [ anon ]
mapped: 958080K writeable/private: 8056K shared: 720900K
--安裝Patch:
oracle@dave 13817131]$ opatch apply online -connectString dave:sys:oracle
Invoking OPatch 11.2.0.1.7
Oracle 中間補丁程序安裝程序版本11.2.0.1.7
版權所有 (c) 2011, Oracle Corporation。保留所有權利。
Oracle Home : /u01/app/oracle/product/11.2.0/db_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.7
OUI version : 11.2.0.3.0
Log file location :/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch3012-10-09_19-10-51下午.log
補丁程序只應在 '-all_nodes' 模式下應用/回退。
將 RAC 模式轉換為'-all_nodes' 模式。
Applying interim patch '13817131' to OH'/u01/app/oracle/product/11.2.0/db_1'
Verifying environment and performingprerequisite checks...
是否繼續? [y|n]
y
User Responded with: Y
All checks passed.
Backing up files...
正在為組件 oracle.rdbms, 11.2.0.3.0 打補丁...
The patch will be installed on activedatabase instances.
正在數據庫 'dave' 上安裝和啟用聯機補丁程序 'bug13817131.pch'。
Patch 13817131 successfully applied
Log file location:/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch3012-10-09_19-10-51下午.log
OPatch succeeded.
--查看alert log:
Tue Oct 09 19:11:05 2012
Patch file bug13817131.pch is out of syncwith oracle binary; performing fixup
Patch file bug13817131.pch has been syncedwith oracle binary
Patch bug13817131.pchInstalled - Update #1
Patch bug13817131.pchEnabled - Update #2
Tue Oct 09 19:11:07 2012
Online patch bug13817131.pch has beeninstalled
Online patch bug13817131.pch has beenenabled
--再次查看pmon 進程的內存:
[oracle@dave trace]$ ps -ef|grep pmon|grep-v grep
oracle 2118 1 0 15:15 ? 00:00:14 ora_pmon_dave
[oracle@dave trace]$ pmap -d 2118|tail -20
00007fb4ef239000 264 rwx-- 0000000000288000 008:00003libnnz11.so
00007fb4ef27b000 12 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef28c000 4 r-x-- 000000000c955000 008:00003oracle
00007fb4ef28d000 4 rwxs- 0000000000000000 008:00003hc_dave.dat
00007fb4ef28e000 8 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef290000 864 r-x-- 0000000000000000 008:00003libskgxp11.so
00007fb4ef368000 1024 ----- 00000000000d8000 008:00003libskgxp11.so
00007fb4ef468000 8 rwx-- 00000000000d8000 008:00003libskgxp11.so
00007fb4ef46a000 392r-x-- 0000000000000000 008:00003 libcell11.so
00007fb4ef4cc000 1024 ----- 0000000000062000 008:00003libcell11.so
00007fb4ef5cc000 40 rwx-- 0000000000062000 008:00003libcell11.so
00007fb4ef5d6000 8 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef5d8000 4 r-x-- 0000000000000000 008:00003libodmd11.so
00007fb4ef5d9000 1024 ----- 0000000000001000 008:00003libodmd11.so
00007fb4ef6d9000 4 rwx-- 0000000000001000 008:00003libodmd11.so
00007fb4ef6da000 4 rwx-- 0000000000000000 000:00000 [ anon ]
00007ffff0261000 132 rwx-- 0000000000000000 000:00000 [ stack ]
00007ffff03f6000 4 r-x-- 0000000000000000 000:00000 [ anon ]
ffffffffff600000 4 r-x-- 0000000000000000 000:00000 [ anon ]
mapped: 964344K writeable/private: 8068K shared: 720900K
--安裝Patch 之前是:
mapped: 958080K writeable/private: 8056K shared: 720900K。
private 內存增加了 8k。
--并且安裝之后,從pmon 進程的內存中,可以看到多出如下3個庫文件:
[oracle@davetrace]$ pmap -d 2118|grep 13817131
00007fb4ecf66000 168 r-x-- 0000000000000000 008:00003bug13817131.so
00007fb4ecf90000 1020 ----- 000000000002a000 008:00003bug13817131.so
00007fb4ed08f000 12 rwx-- 0000000000029000 008:00003bug13817131.so
3.4 使用oradebug 來禁用patch
在1.7 小節提到了2種Oracle 不推薦的,使用oradebug 來禁用online patch的方法。 我們這里測試一下。
(1)使用Oradebug
SQL> oradebug patch list
Patch File Name State
================ =========
bug13817131.pch ENABLED
SQL> oradebugpatch disable bug13817131.pch
Statement processed.
SQL> oradebug patch list
Patch File Name State
================ =========
bug13817131.pch DISABLED
注意,這種方法不會釋放安裝onlinepatch 時消耗的額外內存。
[oracle@dave trace]$ pmap -d 2118|tail-20
00007fb4ef239000 264 rwx-- 0000000000288000 008:00003libnnz11.so
00007fb4ef27b000 12 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef28c000 4 r-x-- 000000000c955000 008:00003oracle
00007fb4ef28d000 4 rwxs- 0000000000000000 008:00003hc_dave.dat
00007fb4ef28e000 8 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef290000 864 r-x-- 0000000000000000 008:00003libskgxp11.so
00007fb4ef368000 1024 ----- 00000000000d8000 008:00003libskgxp11.so
00007fb4ef468000 8 rwx-- 00000000000d8000 008:00003libskgxp11.so
00007fb4ef46a000 392 r-x-- 0000000000000000 008:00003libcell11.so
00007fb4ef4cc000 1024 ----- 0000000000062000 008:00003libcell11.so
00007fb4ef5cc000 40 rwx-- 0000000000062000 008:00003libcell11.so
00007fb4ef5d6000 8 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef5d8000 4 r-x-- 0000000000000000 008:00003libodmd11.so
00007fb4ef5d9000 1024 ----- 0000000000001000 008:00003libodmd11.so
00007fb4ef6d9000 4 rwx-- 0000000000001000 008:00003libodmd11.so
00007fb4ef6da000 4 rwx-- 0000000000000000 000:00000 [ anon ]
00007ffff0261000 132 rwx-- 0000000000000000 000:00000 [ stack ]
00007ffff03f6000 4 r-x-- 0000000000000000 000:00000 [ anon ]
ffffffffff600000 4 r-x-- 0000000000000000 000:00000 [ anon ]
mapped: 964344K writeable/private: 8068K shared: 720900K
--使用oradebug enable patch:
SQL> oradebug patch enablebug13817131.pch
Statement processed.
SQL> oradebug patch list
Patch File Name State
================ =========
bug13817131.pch ENABLED
(2)關閉實例并移除配置文件
Shutting the instancedown and removing the orapatch*.cfg file. Afterstopping the instance do the following:
cd $ORACLE_HOME/hpatch
rm orapatch$ORACLE_SID.cfg
--這里強調是關閉實例在操作,否則可能會出現其他意外情況。
Removing the orapatch*.cfg removes all of the online patches currentlyinstalled for the instance.
--該方法會移除所有online patch:
[oracle@dave db_1]$ cd hpatch/
[oracle@dave hpatch]$ pwd
/u01/app/oracle/product/11.2.0/db_1/hpatch
[oracle@dave hpatch]$ ls
bug13817131.pch bug13817131.pchdave.fixup bug13817131.so orapatchdave.cfg
3.5 rollback patch
語法參考1.7 小節。
[oracle@dave db_1]$ opatch rollback -id 13817131 -connectString dave:sys:oracle
Invoking OPatch 11.2.0.1.7
Oracle 中間補丁程序安裝程序版本11.2.0.1.7
版權所有 (c) 2011, Oracle Corporation。保留所有權利。
Oracle Home : /u01/app/oracle/product/11.2.0/db_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.7
OUI version : 11.2.0.3.0
Log file location :/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch3012-10-09_19-32-31下午.log
RollbackSession 從OH '/u01/app/oracle/product/11.2.0/db_1' 回退中間補丁程序'13817131'
補丁程序只應在 '-all_nodes' 模式下應用/回退。
將 RAC 模式轉換為'-all_nodes' 模式。
正在為組件 oracle.rdbms, 11.2.0.3.0 打補丁...
The patch will be removed from activedatabase instances.
正在數據庫 'dave' 上禁用和刪除聯機補丁程序 'bug13817131.pch'
RollbackSession 從產品清單中刪除中間補丁程序 '13817131'
Log file location:/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch3012-10-09_19-32-31下午.log
OPatch succeeded.
--alert log信息:
Tue Oct 09 19:32:41 2012
Patch bug13817131.pch Disabled - Update #5
Patch bug13817131.pch Removed - Update #6
Tue Oct 09 19:32:44 2012
Online patchbug13817131.pch has been disabled
Online patchbug13817131.pch has been removed
--查看PMON進程對內存的消耗:
[oracle@dave trace]$ pmap -d 2118|tail-20
00007fb4ef239000 264 rwx-- 0000000000288000 008:00003libnnz11.so
00007fb4ef27b000 12 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef28c000 4 r-x-- 000000000c955000 008:00003oracle
00007fb4ef28d000 4rwxs- 0000000000000000 008:00003 hc_dave.dat
00007fb4ef28e000 8 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef290000 864 r-x-- 0000000000000000 008:00003libskgxp11.so
00007fb4ef368000 1024 ----- 00000000000d8000 008:00003libskgxp11.so
00007fb4ef468000 8 rwx-- 00000000000d8000 008:00003libskgxp11.so
00007fb4ef46a000 392 r-x-- 0000000000000000 008:00003libcell11.so
00007fb4ef4cc000 1024 ----- 0000000000062000 008:00003libcell11.so
00007fb4ef5cc000 40 rwx-- 0000000000062000 008:00003libcell11.so
00007fb4ef5d6000 8 rwx-- 0000000000000000 000:00000 [ anon ]
00007fb4ef5d8000 4 r-x-- 0000000000000000 008:00003libodmd11.so
00007fb4ef5d9000 1024 ----- 0000000000001000 008:00003libodmd11.so
00007fb4ef6d9000 4 rwx-- 0000000000001000 008:00003libodmd11.so
00007fb4ef6da000 4 rwx-- 0000000000000000 000:00000 [ anon ]
00007ffff0261000 132 rwx-- 0000000000000000 000:00000 [ stack ]
00007ffff03f6000 4 r-x-- 0000000000000000 000:00000 [ anon ]
ffffffffff600000 4 r-x-- 0000000000000000 000:00000 [ anon ]
mapped: 964344K writeable/private: 8068K shared: 720900K
這里我們使用oradebugdisable 和opatch rollback 都不會釋放安裝online patch 消耗的額外內存。當然重啟實例之后,這些內存自會釋放。
當前題目:hotpatching
當前鏈接:http://m.kartarina.com/article24/pgoice.html
成都網站建設公司_創新互聯,為您提供網站設計、定制開發、動態網站、靜態網站、網站改版、網站排名
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯