在windows上打Oracle的CPU補丁

Jujay發表於2011-10-23
作業系統資訊:Win server 2003 Enterprise Edition SP2
資料庫版本:10g Enterprise Edition Release 10.2.0.4.0 - Production
CPU補丁版本:CPU July 2011
步驟如下:
1. 下載CPU補丁
可以從Oracle官方的”Critical Patch Updates and Security Alerts“ (http://www.oracle.com/technetwork/topics/security/alerts-086861.html) 頁面檢視2011年7月份的CPU補丁在Windows平臺上對於的補丁號,再到metalink上下載。
2. 檢視資料庫資訊
Normal 0 false false false EN-US ZH-CN X-NONEset pagesize 99
col action_time for a30
col action for a30
col comments for a90
col object_name for a30
col object_type for a30
col comp_name for a50
col comp_id for a20
SQL> spool precheck.log
SQL> select instance_name,status from v$instance;
SQL> select * from v$version;
SQL> select sum(bytes)/1024/1024||'M' from dba_segments;
SQL> select COMP_ID,COMP_NAME,VERSION,STATUS from DBA_REGISTRY;
SQL> select ACTION_TIME, ACTION, COMMENTS from sys.DBA_REGISTRY_HISTORY;
SQL> select count(*) from dba_objects where status<>'VALID';
SQL> select object_name,object_type,owner,status from dba_objects where status<>'VALID';
SQL> spool off
Normal 0 false false false EN-US ZH-CN X-NONE3. 備份資料庫
H:\CPUPatch>rman target /
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;
RMAN> configure controlfile autobackup format for device type disk to 'H:\INTEL_DB_DUMPS\O03LSE3\rman\cf_O03LSE3_%F';
RMAN> backup database format 'H:\INTEL_DB_DUMPS\O03LSE3\rman\O03LSE3_%s_%p_%T_%t.bak' tag before_CPUPatch;
4. 備份Oracle home
在備份Oracle home之前,除了確保所有和Oracle相關的服務、程式都已停止之外,還要確保服務Distributed Transaction Coordinator也已停止。
把oracle home整個目錄拷貝至其它盤儲存
5. 打CPU補丁(Oracle binary部分)
H:\CPUPatch>set oracle_home=G:\oracle\ora102
檢視已經打過的補丁:
H:\CPUPatch>%ORACLE_HOME%\OPatch\opatch lsinventory
開始打補丁:
H:\CPUPatch>cd H:\CPUPatch\p12429519_10204_Win32\12429519
H:\CPUPatch\p12429519_10204_Win32\12429519>%ORACLE_HOME%\OPatch\opatch apply    ---大概持續10分鐘
補丁成功之後,再執行以下命令確認:
H:\CPUPatch>%ORACLE_HOME%\OPatch\opatch lsinventory

有可能會出現類似以下錯誤:

Prerequisite check "CheckActiveFilesAndExecutables" failed.
The details are:

Following files are active :
G:\oracle\ora102\bin\oraclient10.dll
G:\oracle\ora102\bin\orapls10.dll
G:\oracle\ora102\bin\oracommon10.dll
G:\oracle\ora102\bin\orageneric10.dll
G:\oracle\ora102\bin\oraplp10.dll
......................

這種錯誤是因為Oracle home中的某些dll還在被其它程式佔用,無法被覆蓋,解決方法可以參考(https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=418479.1)
我覺得最簡便的方法是下載微軟提供的一個小工具Process Explorer  (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx),用這個工具檢視這些dll是被哪些程式佔用,然後手動殺掉這些程式即可。

6 打CPU補丁(資料庫部分)
啟動所有在第4步中停止的服務和程式。
cd /d %ORACLE_HOME%\BUNDLE\Patch45
sqlplus "/as sysdba"
SQL> @catcpu.sql          ---大概持續30分鐘至1小時

7. 重編譯view
SQL> SELECT * FROM registry$history where ID = '6452863';
如果上面的語句有返回行數,則說明資料庫之前已經重編譯過view了,可略過此步驟。
如果沒有返回,則:
Normal 0 false false false EN-US ZH-CN X-NONESQL> SHUTDOWN IMMEDIATE
SQL> STARTUP UPGRADE
SQL> @?/cpu/view_recompile/view_recompile_jan2008cpu.sql
SQL> SHUTDOWN IMMEDIATE

8. 事後檢查
重新編譯無效物件:
@?/rdbms/admin/utlrp.sql
set line 150
set pagesize 99
col action_time for a30
col action for a30
col comments for a90
col object_name for a30
col object_type for a30
col comp_name for a50
col comp_id for a20

SQL> spool post_check.log
SQL> select instance_name,status from v$instance;
SQL> select COMP_ID,COMP_NAME,VERSION,STATUS from DBA_REGISTRY;
SQL> select ACTION_TIME, ACTION, COMMENTS from DBA_REGISTRY_HISTORY;
SQL> select owner,object_name,object_type,status from dba_objects where status<>'VALID';
SQL> select count(*) from dba_objects where status<>'VALID';
SQL> spool off

Normal 0 false false false EN-US ZH-CN X-NONE




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26277071/viewspace-709550/,如需轉載,請註明出處,否則將追究法律責任。

相關文章