以下是對Data Guard CPU/PSU補丁安裝的方法進行了詳細的分析介紹,需要的朋友可以參考下
非Data Guard的補丁安裝教程可參考《[Oracle] CPU/PSU補丁安裝詳細教程》,Data Guard需要Primary和Standby同時打上補丁,所以步驟更復雜一些,其主要步驟如下:
1.在Primary停止日志傳輸服務;
2.關閉Standby數據庫,在Standby的軟件上打補丁(注意:不需要為Standby數據庫打補丁),啟動standby為mount狀態,不啟用managed recovery;
3.關閉Primary,在Primary的軟件和數據庫本身都打上補丁;
4.啟動Primary數據庫,重新開啟日志傳輸服務;
5.在Standby啟動Redo Apply,這樣Primary上補丁腳本就會自動同步至Standby;
6.檢查Primary和Standby是否都已安裝補丁。
下面是一個具體例子:
1. 在Primary停止日志傳輸服務
復制代碼 代碼如下:
sys@EPAY>select database_role from v$database;
DATABASE_ROLE
----------------
PRIMARY
sys@EPAY>show parameter log_archive_dest_3
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_3 string SERVICE=sta ASYNC VALID_FOR=(O
NLINE_LOGFILES,PRIMARY_ROLE) D
B_UNIQUE_NAME=epaybk
log_archive_dest_30 string
log_archive_dest_31 string
sys@EPAY>alter system set log_archive_dest_state_3=defer scope=both;
System altered.
2.在Standby的Oracle軟件打上補丁
2.1 關閉數據庫實例,listener,ASM實例等
2.2 查看opatch的版本,如果不夠,就去下載最新的版本
2.3 在Standby的Oracle軟件上打補丁
2.4 啟動Standby到mount狀態,啟動listener
(注意:Standby不需要對數據庫本身打補丁)
3. 在Primary上打補丁
3.1 關閉數據庫實例,listener,ASM實例等
3.2 查看opatch的版本,如果不夠,就去下載最新的版本
3.3 在Primary的Oracle軟件上打補丁
3.4 為Primary數據庫本身打補丁
復制代碼 代碼如下:
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle.sql psu apply
SQL> QUIT
4. 在Primary啟動日志傳輸服務
4.1 啟動Primary listener,數據庫實例等
4.2 強制注冊services到listener
復制代碼 代碼如下:
sys@EPAY>alter system register;
System altered.
4.3 重新啟動日志傳輸服務
復制代碼 代碼如下:
sys@EPAY>alter system set log_archive_dest_state_3=enable scope=both;
System altered.
注意:啟動日志傳輸,在alert裡有可能出現如下錯誤:
復制代碼 代碼如下:
------------------------------------------------------------
Check that the primary and standby are using a password file
and remote_login_passwordfile is set to SHARED or EXCLUSIVE,
and that the SYS password is same in the password files.
returning error ORA-16191
------------------------------------------------------------
根據錯誤信息的提示,應該是主庫在做CPU補丁的時候把sys密碼修改了,用主庫的密碼文件替換備庫的密碼文件即可解決該錯誤。
5. Standby啟動Redo Apply
5.1 open Standby 數據庫
5.2 啟用Redo Apply
復制代碼 代碼如下:
sys@EPAY>alter database recover managed standby database disconnect from session;
Database altered.
5.3 驗證Primary和Standby是否同步
在primary端查詢當前最大的歸檔日志序號:
復制代碼 代碼如下:
sys@EPAY>select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
159
在standby端查詢已傳過來的歸檔日志:
復制代碼 代碼如下:
sys@EPAY>select sequence#, applied from v$archived_log;
5.4 從alert.log可用看出同步了3個日志文件(即把在primary打的補丁同步到了standby)
復制代碼 代碼如下:
alter database recover managed standby database disconnect from session
Attempt to start background Managed Standby Recovery process (epay)
Wed Jul 10 06:03:48 2013
MRP0 started with pid=29, OS id=15030
MRP0: Background Managed Standby Recovery process started (epay)
started logmerger process
Wed Jul 10 06:03:53 2013
Managed Standby Recovery not using Real Time Apply
Wed Jul 10 06:04:01 2013
Parallel Media Recovery started with 32 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Wed Jul 10 06:04:01 2013
Completed: alter database recover managed standby database disconnect from session
Media Recovery Log /data/oradata/epay/archivelog/1_157_814716635.dbf
Media Recovery Log /data/oradata/epay/archivelog/1_158_814716635.dbf
Media Recovery Log /data/oradata/epay/archivelog/1_159_814716635.dbf
Media Recovery Waiting for thread 1 sequence 160 (in transit)
6. 後期檢查補丁是否安裝成功
6.1 在primary, standby分別指向opatch lsinventory
6.2 在數據庫裡檢查補丁是否安裝成功