RAC環境ROLLING UPGRADE方式應用PATCH

yangtingkun發表於2009-04-15

OracleRAC環境支援ROLLING UPGRADE方式安裝PATCH

 

 

所謂ROLLING UPGRADE安裝補丁或升級是指高可用環境中一個節點先安裝補丁或升級版本,由其他的節點提供服務,隨後升級或安裝補丁後的節點啟動提供服務,然後其他的節點再安裝補丁或升級。整個安裝補丁或升級過程中不停止對外提供服務。

OracleDATA GUARDSTREAMRAC等高可用環境都支援ROLLING UPGRADE,不過RAC環境僅支援補丁的ROLLING UPGRADE,不支援補丁集的安裝以及版本的升級。

昨天碰到了一個Solaris上的bughttp://yangtingkun.itpub.net/post/468/482352。這裡描述在RAC環境中,使用ROLLING UPGRADE方式來應用PATCH,修正這個bug

首先在本機透過sqlplus登陸資料庫:

SQL> conn test/test@test
已連線。
SQL> set pages 100 lines 120
SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
test1

SQL> select name from v$database;

NAME
---------
TEST

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
CORE    11.1.0.6.0      Production
TNS for Solaris: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production

現在登陸到資料庫的例項1

下面在例項1所在的節點解開補丁:

bash-3.00$ mkdir $ORACLE_HOME/patch
bash-3.00$ mv p5885301_111060_SOLARIS64.zip $ORACLE_HOME/patch
bash-3.00$ cd $ORACLE_HOME/patch
bash-3.00$ ls
p5885301_111060_SOLARIS64.zip
bash-3.00$ unzip p5885301_111060_SOLARIS64.zip
Archive:  p5885301_111060_SOLARIS64.zip
   creating: 5885301/
   creating: 5885301/files/
   creating: 5885301/files/lib/
   creating: 5885301/files/lib/libcommon11.a/
  inflating: 5885301/files/lib/libcommon11.a/slspool.o 
   creating: 5885301/files/lib32/
   creating: 5885301/files/lib32/libcommon11.a/
  inflating: 5885301/files/lib32/libcommon11.a/slspool.o 
   creating: 5885301/etc/
   creating: 5885301/etc/config/
  inflating: 5885301/etc/config/inventory.xml 
  inflating: 5885301/etc/config/actions.xml 
   creating: 5885301/etc/xml/
  inflating: 5885301/etc/xml/GenericActions.xml 
  inflating: 5885301/etc/xml/ShiphomeDirectoryStructure.xml 
  inflating: 5885301/README.txt     

現在要關閉節點1上所有的例項,當然也包括ASM例項:

bash-3.00$ srvctl stop inst -d test -i test1
bash-3.00$ srvctl stop asm -n ser1
bash-3.00$ srvctl stop listener -n ser1

檢查客戶端的連線:

SQL> select * from dual;
select * from dual
*
1 行出現錯誤:
ORA-12571: TNS:
包寫入程式失敗


SQL> conn test/test@test
已連線。
SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
test2

SQL> select name from v$database;

NAME
---------
TEST

SQL> select instance_name from gv$instance;

INSTANCE_NAME
----------------
test2

由於例項1已經關閉,所以會話被斷開,再次連線會話連線到例項2上。

下面開始節點1上的patch操作:

bash-3.00$ cd 5885301/
bash-3.00$ $ORACLE_HOME/Opatch/opatch apply
bash: /data/oracle/product/11.1/database/Opatch/opatch: No such file or directory
bash-3.00$ /data/oracle/product/11.1/database/OPatch/opatch apply
Invoking OPatch 11.1.0.6.0

Oracle Interim Patch Installer version 11.1.0.6.0
Copyright (c) 2007, Oracle Corporation.  All rights reserved.


Oracle Home       : /data/oracle/product/11.1/database
Central Inventory : /data/oraInventory
   from           : /var/opt/oracle/oraInst.loc
OPatch version    : 11.1.0.6.0
OUI version       : 11.1.0.6.0
OUI location      : /data/oracle/product/11.1/database/oui
Log file location : /data/oracle/product/11.1/database/cfgtoollogs/opatch/opatch2009-04-15_16-13-03PM.log

ApplySession applying interim patch '5885301' to OH '/data/oracle/product/11.1/database'

Running prerequisite checks...

OPatch detected the node list and the local node from the inventory.  OPatch will patch the local system then propagate the patch to the remote nodes.

Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '5885301' for restore. This might take a while...
Backing up files affected by the patch '5885301' for rollback. This might take a while...

Patching component oracle.rdbms, 11.1.0.6.0...
Updating archive file "/data/oracle/product/11.1/database/lib/libcommon11.a"  with "lib/libcommon11.a/slspool.o"
Updating archive file "/data/oracle/product/11.1/database/lib32/libcommon11.a"  with "lib32/libcommon11.a/slspool.o"
Running make for target client_sharedlib
ApplySession adding interim patch '5885301' to inventory

Verifying the update...
Inventory check OK: Patch ID 5885301 is registered in Oracle Home inventory with proper meta-data.
Files check OK: Files from Patch ID 5885301 are present in Oracle Home.

Patching in rolling mode.

Updating nodes 'ser2'
   Apply-related files are:
     FP = "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt"
     DP = "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_dirs.txt"
     MP = "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/make_cmds.txt"
     RC = "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/remote_cmds.txt"

Instantiating the file "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt.instantiated" by replacing $ORACLE_HOME in "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt" with actual path.
Propagating files to remote nodes...

OPatch failed to copy files to remote nodes 'ser2' .  Detail: Error while copying files inside directory '/data/oracle/product/11.1/database' based on listed file '/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt.instantiated' to nodes 'ser2'. [PRKC-1073 : Failed to transfer directory "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt.instantiated" to any of the given nodes "ser2 ".
Error on node ser2:PRKC-1044 : Failed to check remote command execution setup for node ser2 using shells /usr/bin/ssh and /usr/bin/rsh
permission denied]

OPatch failed to copy files to remote nodes 'ser2' .
Do you want to proceed? [y|n]
n
User Responded with: N
OPatch failed to propagate the patch to the remote node(s).
Run the patch again on each of the remote node(s) using -local option.
Details: Error while copying files inside directory '/data/oracle/product/11.1/database' based on listed file '/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt.instantiated' to nodes 'ser2'. [PRKC-1073 : Failed to transfer directory "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt.instantiated" to any of the given nodes "ser2 ".
Error on node ser2:PRKC-1044 : Failed to check remote command execution setup for node ser2 using shells /usr/bin/ssh and /usr/bin/rsh
permission denied]
ApplySession failed: OUI-67081:OPatch failed to propagate the patch to the remote node(s).
Run the patch again on each of the remote node(s) using -local option.
Details: Error while copying files inside directory '/data/oracle/product/11.1/database' based on listed file '/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt.instantiated' to nodes 'ser2'. [PRKC-1073 : Failed to transfer directory "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt.instantiated" to any of the given nodes "ser2 ".
Error on node ser2:PRKC-1044 : Failed to check remote command execution setup for node ser2 using shells /usr/bin/ssh and /usr/bin/rsh
permission denied]
System intact, OPatch will not attempt to restore the system
--------------------------------------------------------------------------------
The following warnings have occurred during OPatch execution:
1) OUI-67187:
OPatch failed to copy files to remote nodes 'ser2' .  Detail: Error while copying files inside directory '/data/oracle/product/11.1/database' based on listed file '/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt.instantiated' to nodes 'ser2'. [PRKC-1073 : Failed to transfer directory "/data/oracle/product/11.1/database/.patch_storage/5885301_Oct_6_2008_22_40_42/rac/copy_files.txt.instantiated" to any of the given nodes "ser2 ".
Error on node ser2:PRKC-1044 : Failed to check remote command execution setup for node ser2 using shells /usr/bin/ssh and /usr/bin/rsh
permission denied]
--------------------------------------------------------------------------------

OPatch failed with error code 73

遠端節點操作失敗,這是正常的,因為遠端節點還在執行。下面啟動本地例項:

bash-3.00$ srvctl start asm -n ser1
bash-3.00$ srvctl start inst -d test -i test1
bash-3.00$ srvctl start listener -n ser1

檢查例項1bug是否已經解決:

bash-3.00$ export ORACLE_SID=test1
bash-3.00$ sqlplus test/test

SQL*Plus: Release 11.1.0.6.0 - Production on 星期三 4 15 16:20:31 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.


連線到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> spo /export/home/oracle/result.txt
SQL> select 1 from dual;

         1
----------
         1

SQL> spo out
_default: unknown printer
SQL>

節點1上的bug已經解決,且資料庫一直對外提供服務,下面在節點2上執行相同的操作:

bash-3.00$ srvctl stop inst -d test -i test2
bash-3.00$ srvctl stop asm -n ser2
bash-3.00$ srvctl stop listener -n ser2

檢查客戶端的連線:

SQL> select * from dual;
select * from dual
*
1 行出現錯誤:
ORA-12571: TNS:
包寫入程式失敗


SQL> conn test/test@test
已連線。
SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
test1

SQL> select name from v$database;

NAME
---------
TEST

SQL> select instance_name from gv$instance;

INSTANCE_NAME
----------------
test1

同樣在節點2應用PATCH的時候,節點1上的例項可以對外提供服務。

下面在節點2上打PATCH,為了避免打PATCH的時候出現類似節點1上的錯誤,在應用PATCH的時候指定-LOCAL引數:

bash-3.00$ cd 5885301/
bash-3.00$ $ORACLE_HOME/OPatch/opatch apply -local
Invoking OPatch 11.1.0.6.0

Oracle Interim Patch Installer version 11.1.0.6.0
Copyright (c) 2007, Oracle Corporation.  All rights reserved.


Oracle Home       : /data/oracle/product/11.1/database
Central Inventory : /data/oraInventory
   from           : /var/opt/oracle/oraInst.loc
OPatch version    : 11.1.0.6.0
OUI version       : 11.1.0.6.0
OUI location      : /data/oracle/product/11.1/database/oui
Log file location : /data/oracle/product/11.1/database/cfgtoollogs/opatch/opatch2009-04-15_16-32-03PM.log

ApplySession applying interim patch '5885301' to OH '/data/oracle/product/11.1/database'

Running prerequisite checks...

You selected -local option, hence OPatch 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 '5885301' for restore. This might take a while...
Backing up files affected by the patch '5885301' for rollback. This might take a while...

Patching component oracle.rdbms, 11.1.0.6.0...
Updating archive file "/data/oracle/product/11.1/database/lib/libcommon11.a"  with "lib/libcommon11.a/slspool.o"
Updating archive file "/data/oracle/product/11.1/database/lib32/libcommon11.a"  with "lib32/libcommon11.a/slspool.o"
Running make for target client_sharedlib
ApplySession adding interim patch '5885301' to inventory

Verifying the update...
Inventory check OK: Patch ID 5885301 is registered in Oracle Home inventory with proper meta-data.
Files check OK: Files from Patch ID 5885301 are present in Oracle Home.

OPatch succeeded.

PATCH應用成功,啟動節點2上的服務:

bash-3.00$ srvctl start asm -n ser2
bash-3.00$ srvctl start inst -d test -i test2
bash-3.00$ srvctl start listener -n ser2

節點2上的例項已經啟動,下面檢查客戶端的連線是否正常:

SQL> select instance_name from gv$instance;

INSTANCE_NAME
----------------
test1
test2

可以看到節點1上的連線正常,且資料庫的兩個例項都已經啟動。雖然在應用補丁的過程中,兩個例項都重啟過,但是資料庫對外的服務一直沒有停止。

至此ROLLING UPGRADE方式應用補丁的操作已經完成,本文只是為了說明ROLLING UPGRADE與普通應用PATCH的區別,所以沒有在節點1上使用-LOCAL選項應用補丁。真正ROLLING UPGRADE操作應該在RAC的每個節點上已-LOCAL方式應用補丁。

 

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

相關文章