如何利用oracle opatch打補丁

本文主要介紹瞭如何利用ORACLE的OPATCH工具安裝補丁,同時通過本文的描述,我們也應該瞭解確認BUG一般步驟:分析、排查相關錯誤信息、對比環境、最終確認。

關鍵字: ORACLE、OPATCH、補丁

1.      引言

       近幾年,隨着我們ORACLE數據庫的應用越來越深入,用戶的環境越來越複雜,一些ORACLE常見的BUG也會偶爾的被觸發。因此,我們對技術人員要求不能再象以前一樣只要求會安裝數據庫,還應該要求其掌握如何安裝補丁才行,下面我們就結合一個案例,介紹下如何利用ORACLE OPATCH工具進行補丁的安裝。

2.      案例描述

       前不久,某數據庫監聽在系統高峯期出現偶爾莫名宕掉的現象,導致客戶端無法連接,但是重新啓動監聽又不報任何錯誤,及時重建監聽,現象依舊。聽到問題描述,我們首先檢查監聽停止時段的日誌,發現有如下錯誤提示:

如何利用oracle opatch打補丁 - wendell - 靜雲

 

 

 

 

 

    查詢metalink後,發現有個類似案例《TNS Listener Crash with Core dump [ID 549932.1]》,適用於ORACLE10.2.0.3.0到11.1.0.6.0,平臺是UNINX。該數據庫版本是10.2.0.4,但是平臺是LINUX的,還是有點區別,需要進一步分析,但是看下面的現象,在系統日誌(/var/log/messages)中,會出現如下提示:

文檔中還提到,在出現該錯誤的時間段,系統的虛擬內存會出現異常,於是我們通過配置跟蹤文件,等待再次出現問題後,觀察下系統的虛擬內存觀察的情況如下:

如何利用oracle opatch打補丁 - wendell - 靜雲  

  這些現象都同文檔的的錯誤現象一致,因此,雖然個別條件有所差別,但是可以基本判斷爲同一問題。接下來,我們就來看看解決問題的方法,該問題ORACLE官方提供的解決方法有2種:一種是加物理內存,一種是再當前平臺打補丁6139856。由於加物理內存涉及硬件投入,我們這裏考慮採用打補丁的方式嘗試解決該問題。

3.      準備工作

       決定了採用打補丁的解決思路,接下來就是做準備工作,首先,當然是下載補丁文件(P6139856),然後把文件上傳到服務器的相關目錄,並進行解壓,當然在打補丁前,對數據庫的備份是必不可少的,這些步驟我們就不再一一闡述,重點還是介紹下打補丁的過程。

4.      操作過程

4.1.             閱讀說明

       在正式操作前,我們還是應該認真閱讀補丁的說明,看看有什麼特別需要注意事情,這些在補丁說明中都會有提示,如果你們沒有作特別的提示,我們就可以在正式環境中應用了,小補丁的安裝其實比較簡單,主要利用ORACLE的OPATCH工具進行操作,OPATCH工具是ORACLE自帶的一個補丁安裝程序,默認ORACLE安裝後就自帶該工具,因此無需我們再單獨安裝。

4.2.             檢查環境

       每個補丁的應用都有一定的環境,包括數據庫版本、OPATCH版本等,首先應該對這些環境進行檢查,通過命令opatch lsinventory檢查,操作如下:

Last login: Fri Jul 30 10:08:59 2010

[oracle@wzy01 ~]$ cd 6139856/                  #進入補丁文件目錄           

[oracle@wzy01 6139856]$ ls

etc  files  README.txt

[oracle@wzy01 6139856]$ opatch lsinventory     #用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       : /u01/oracle/product/db10gr2

Central Inventory : /u01/oracle/oraInventory

   from           : /etc/oraInst.loc

OPatch version    : 10.2.0.4.2                                  #opatch版本

OUI version       : 10.2.0.4.0

OUI location      : /u01/oracle/product/db10gr2/oui

Log file location : /u01/oracle/product/db10gr2/cfgtoollogs/opatch/opatch2010-07-30_11-16-12AM.log

Lsinventory Output file location : /u01/oracle/product/db10gr2/cfgtoollogs/opatch/lsinv/lsinventory2010-07-30_11-16-12AM.txt

--------------------------------------------------------------------------------

Installed Top-level Products (2):

Oracle Database 10g                                                  10.2.0.1.0

Oracle Database 10g Release 2 Patch Set 3                            10.2.0.4.0                                                                    #oracle大版本

There are 2 products installed in this Oracle Home.

There are no Interim patches installed in this Oracle Home.

--------------------------------------------------------------------------------

OPatch succeeded.

4.3.             停數據庫

       在打補丁的時候,會有文件的覆蓋替換,因此,大部分時候,在打補丁的時候是要求數據庫處於關閉狀態,因此,我們需要把數據庫實例關閉。

SQL> conn / as sysdba

已連接。

SQL> shutdown immediate

數據庫已經關閉。

已經卸載數據庫。

ORACLE 例程已經關閉。

SQL>

4.4.             應用補丁

       補丁的安裝也非簡單,如果前面的環境都沒有問題,直接運行下opatch apply就行了,OPATCH工具會自動應用補丁,完成補丁的安裝,如下:

[oracle@wzy01 6139856]$ opatch apply     #在補丁文件目錄中用opatch apply應用補丁

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       : /u01/oracle/product/db10gr2

Central Inventory : /u01/oracle/oraInventory

   from           : /etc/oraInst.loc

OPatch version    : 10.2.0.4.2

OUI version       : 10.2.0.4.0

OUI location      : /u01/oracle/product/db10gr2/oui

Log file location : /u01/oracle/product/db10gr2/cfgtoollogs/opatch/opatch2010-07-30_11-16-16AM.log

ApplySession applying interim patch '6139856' to OH '/u01/oracle/product/db10gr2'

Running prerequisite checks...

OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.

(Oracle Home = '/u01/oracle/product/db10gr2')

Is the local system ready for patching? [y|n]        #詢問是否更新文件,輸入Y更新

y

User Responded with: Y

Backing up files and inventory (not for auto-rollback) for the Oracle Home

Backing up files affected by the patch '6139856' for restore. This might take a while...

Backing up files affected by the patch '6139856' for rollback. This might take a while...

Patching component oracle.rdbms, 10.2.0.4.0...

Updating archive file "/u01/oracle/product/db10gr2/lib/libn10.a"  with "lib/libn10.a/nsev.o"

Updating archive file "/u01/oracle/product/db10gr2/lib32/libn10.a"  with "lib32/libn10.a/nsev.o"

Patching component oracle.rdbms.rsf, 10.2.0.4.0...

Updating archive file "/u01/oracle/product/db10gr2/lib/libn10.a"  with "lib/libn10.a/nsev.o"

Updating archive file "/u01/oracle/product/db10gr2/lib32/libn10.a"  with "lib32/libn10.a/nsev.o"

Running make for target client_sharedlib

Running make for target ioracle

ApplySession adding interim patch '6139856' to inventory

Verifying the update...

Inventory check OK: Patch ID 6139856 is registered in Oracle Home inventory with proper meta-data.

Files check OK: Files from Patch ID 6139856 are present in Oracle Home.

The local system has been patched and can be restarted.

OPatch succeeded.                                 #補丁更新成功

4.5.             檢查覈實

       最後,我們要看一下,補丁安裝情況,同樣我們通過opatch lsinventory命令進行查看,如下:

[oracle@wzy01 6139856]$ 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       : /u01/oracle/product/db10gr2

Central Inventory : /u01/oracle/oraInventory

   from           : /etc/oraInst.loc

OPatch version    : 10.2.0.4.2

OUI version       : 10.2.0.4.0

OUI location      : /u01/oracle/product/db10gr2/oui

Log file location : /u01/oracle/product/db10gr2/cfgtoollogs/opatch/opatch2010-07-30_11-23-32AM.log

Lsinventory Output file location : /u01/oracle/product/db10gr2/cfgtoollogs/opatch/lsinv/lsinventory2010-07-30_11-23-32AM.txt

--------------------------------------------------------------------------------

Installed Top-level Products (2):

Oracle Database 10g                                                  10.2.0.1.0

Oracle Database 10g Release 2 Patch Set 3                            10.2.0.4.0

There are 2 products installed in this Oracle Home.

Interim patches (1) :

Patch  6139856      : applied on Fri Jul 30 11:21:01 CST 2010

   Created on 28 Jul 2008, 01:14:03 hrs PST8PDT

   Bugs fixed:

     6139856                                                                 #這裏可以看到,補丁已經安裝成功

--------------------------------------------------------------------------------

OPatch succeeded.

       完成補丁安裝後,重新啓動數據庫實例,接着觀察了2天時間,沒有再出現監聽莫名停止的現象,證明補丁確實起了作用。

5.      結束語

         通過上面的介紹,大家可以看到,只要前期準備工作做好,其實ORACLE補丁的應用其實很簡單,所以大家不要對其有畏難情緒,他的操作同WINDOWS的補丁安裝是一樣的,希望通過這篇文章的介紹,對大家以後的工作有所幫助

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章