在RAC資料庫上滾動(Rolling)安裝或回退小補丁的方法及步驟

db_wjw發表於2012-12-18

    在RAC資料庫上安裝小補丁時,為了不停止業務,可以使用滾動安裝的方式(Rolling),也就是說,安裝補丁的時候,先停止一個資料庫例項,在這臺節點安裝

這個補丁,然後啟動這個例項,再停止下一個例項並安裝這個補丁,這樣能夠保證一直有可用的資料庫例項,業務能夠繼續。
    使用滾動安裝的前提是這個補丁是可以Rolling安裝的,對於如何判斷一個補丁是Rolling的,下面的文章中會提到。

一般來說,大體的Rolling安裝的方式如下:

1. 下載補丁。

2. 打補丁之前,最好做一下資料庫的備份。

3. 檢查這次安裝的補丁是否和以往的補丁衝突。

4. 如果有測試庫,最好先在測試庫測試一下這個補丁。

5. 務必仔細閱讀補丁的Readme並按照其中的步驟來打補丁:
1). 用oracle使用者將這個補丁上傳到伺服器上的一個目錄.
2). 解壓這個檔案:
3). 停止1號機這個ORACLE_HOME下所有的資料庫例項+ASM例項(如果有);
4). 在1號機打補丁:
$cd $ORACLE_HOME/OPatch/10082277
$opatch apply
5). 然後opatch會問您是否要打下一個節點,這時候執行下面的操作:
6). 啟動1號機這個ORACLE_HOME下所有的資料庫例項+ASM例項(如果有);
7). 停止2號機這個ORACLE_HOME下所有的資料庫例項+ASM例項(如果有);
8). 在之前打補丁的那個提示符中,確認繼續打下一個節點;
9). 啟動2號機這個ORACLE_HOME下所有的資料庫例項+ASM例項(如果有);
10).如果有多個節點,依次執行。


下面是在10.2.0.4 RAC上滾動(Rolling)安裝補丁8575528的過程:

1).用oracle使用者將這個補丁上傳到伺服器上的一個目錄,比如:$ORACLE_HOME/OPatch下面.

$ pwd
/u01/app/oracle/OPatch
$ ls
docs  emdpatch.pl  jlib  opatch  opatch.ini  opatch.pl  opatchprereqs  p8575528_10204_Linux-x86.zip

2).解壓這個檔案:
su - oracle
$ unzip p8575528_10204_Linux-x86.zip
Archive:  p8575528_10204_Linux-x86.zip
  creating: 8575528/
  creating: 8575528/files/
  creating: 8575528/files/lib/
  creating: 8575528/files/lib/libserver10.a/
 inflating: 8575528/files/lib/libserver10.a/kks1.o
 inflating: 8575528/files/lib/libserver10.a/kksc.o
 inflating: 8575528/files/lib/libserver10.a/kksh.o
 inflating: 8575528/files/lib/libserver10.a/ksmp.o
  creating: 8575528/etc/
  creating: 8575528/etc/config/
 inflating: 8575528/etc/config/inventory
 inflating: 8575528/etc/config/actions
  creating: 8575528/etc/xml/
 inflating: 8575528/etc/xml/GenericActions.xml
 inflating: 8575528/etc/xml/ShiphomeDirectoryStructure.xml
 inflating: 8575528/README.txt  
$ ls
8575528  docs  emdpatch.pl  jlib  opatch  opatch.ini  opatch.pl  opatchprereqs  p8575528_10204_Linux-x86.zip

3).檢查這個補丁是不是可以在RAC上滾動安裝(rolling)。
$ $ORACLE_HOME/OPatch/opatch query -all /u01/app/oracle/OPatch/8575528|grep rolling
Patch is a rolling patch: true <=====可以滾動安裝

4).停止1號機資料庫的ORACLE_HOME下所有的資料庫例項(如果有ASM,也要停止):
$srvctl stop instance -d -i
$srvctl stop asm -n

比如:

$srvctl stop instance -d ONEPIECE -i ONEPIECE1
$srvctl stop asm -n nascds14
$ crs_stat -t
Name           Type           Target    State     Host    
------------------------------------------------------------
ora....E1.inst application    OFFLINE   OFFLINE          
ora....SM1.asm application    OFFLINE   OFFLINE

5). 在1號機打補丁:
比如:
$su - oracle
$cd /u01/app/oracle/OPatch/8575528
$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/app/oracle
Central Inventory : /home/oracle/oraInventory
  from           : /etc/oraInst.loc
OPatch version    : 10.2.0.4.2
OUI version       : 10.2.0.4.0
OUI location      : /u01/app/oracle/oui
Log file location : /u01/app/oracle/cfgtoollogs/opatch/opatch2012-06-13_01-27-38AM.log

ApplySession applying interim patch '8575528' to OH '/u01/app/oracle'

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.


This node is part of an Oracle Real Application Cluster.
Remote nodes: 'nascds15'
Local node: 'nascds14'
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle')


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 '8575528' for restore. This might take a while...
Backing up files affected by the patch '8575528' for rollback. This might take a while...

Patching component oracle.rdbms, 10.2.0.4.0...
Updating archive file "/u01/app/oracle/lib/libserver10.a"  with "lib/libserver10.a/kks1.o"
Updating archive file "/u01/app/oracle/lib/libserver10.a"  with "lib/libserver10.a/kksc.o"
Updating archive file "/u01/app/oracle/lib/libserver10.a"  with "lib/libserver10.a/kksh.o"
Updating archive file "/u01/app/oracle/lib/libserver10.a"  with "lib/libserver10.a/ksmp.o"
Running make for target ioracle
ApplySession adding interim patch '8575528' to inventory

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

The local system has been patched.  You can restart Oracle instances on it.


Patching in rolling mode.


The node 'nascds15' will be patched next.


Please shutdown Oracle instances running out of this ORACLE_HOME on 'nascds15'.
(Oracle Home = '/u01/app/oracle')

Is the node ready for patching? [y|n]

6). 然後opatch會問您是否要打下一個節點。這時候執行下面的操作。

7). 啟動1號機的ASM 例項和資料庫例項:
$srvctl start asm -n
$srvctl start instance -d -i

比如:
$srvctl start asm -n nascds14
$srvctl start instance -d ONEPIECE -i ONEPIECE1

$crs_stat -t
ora....E1.inst application    ONLINE    ONLINE    nascds14
ora....SM1.asm application    ONLINE    ONLINE    nascds14

8).停止2號機的ASM例項和資料庫例項:
$srvctl stop instance -d -i
$srvctl stop asm -n

$srvctl stop instance -d ONEPIECE -i ONEPIECE2
$srvctl stop asm -n nascds15
$crs_stat
ora....E2.inst application    OFFLINE   OFFLINE          
ora....SM2.asm application    OFFLINE   OFFLINE

9). 在之前打補丁的那個提示符中,確認繼續打下一個節點。
Is the node ready for patching? [y|n]
y <====輸入y
User Responded with: Y
Updating nodes 'nascds15'
  Apply-related files are:
    FP = "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_files.txt"
    DP = "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_dirs.txt"
    MP = "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/make_cmds.txt"
    RC = "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/remote_cmds.txt"

Instantiating the file "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_files.txt.instantiated"

by replacing $ORACLE_HOME in "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_files.txt" with

actual path.
Propagating files to remote nodes...
Instantiating the file "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_dirs.txt.instantiated"

by replacing $ORACLE_HOME in "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_dirs.txt" with

actual path.
Propagating directories to remote nodes...
Instantiating the file "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/make_cmds.txt.instantiated"

by replacing $ORACLE_HOME in "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/make_cmds.txt" with

actual path.
Running command on remote node 'nascds15':
cd /u01/app/oracle/rdbms/lib; /usr/bin/make -f ins_rdbms.mk ioracle ORACLE_HOME=/u01/app/oracle || echo

REMOTE_MAKE_FAILED::>&2


The node 'nascds15' has been patched.  You can restart Oracle instances on it.

There were relinks on remote nodes.  Remember to check the binary size and timestamp on the nodes 'nascds15' .
The following make commands were invoked on remote nodes:
'cd /u01/app/oracle/rdbms/lib; /usr/bin/make -f ins_rdbms.mk ioracle ORACLE_HOME=/u01/app/oracle
'


OPatch succeeded.

10). 啟動2號機的ASM例項和資料庫例項:
$srvctl start asm -n
$srvctl start instance -d -i

比如:
$srvctl start asm -n nascds15
$srvctl start instance -d ONEPIECE -i ONEPIECE2

11).在兩個節點分別執行下面的命令來確認補丁已經安裝成功。
$ORACLE_HOME/OPatch/opatch lsinventory

[oracle@nascds14 8575528]$ $ORACLE_HOME/OPatch/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/app/oracle
Central Inventory : /home/oracle/oraInventory
  from           : /etc/oraInst.loc
OPatch version    : 10.2.0.4.2
OUI version       : 10.2.0.4.0
OUI location      : /u01/app/oracle/oui
Log file location : /u01/app/oracle/cfgtoollogs/opatch/opatch2012-06-13_01-44-11AM.log

Lsinventory Output file location : /u01/app/oracle/cfgtoollogs/opatch/lsinv/lsinventory2012-06-13_01-44-11AM.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  8575528      : applied on Wed Jun 13 01:28:24 CST 2012<<<<<<<<<<<<<<<<<<<
  Created on 17 Aug 2010, 07:56:36 hrs PST8PDT
  Bugs fixed:
    8575528



Rac system comprising of multiple nodes
 Local node = nascds14
 Remote node = nascds15

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

OPatch succeeded.
Rac system comprising of multiple nodes
 Local node = nascds14
 Remote node = nascds15

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

OPatch succeeded.


下面是在10.2.0.4 RAC上滾動(Rolling)回退補丁8575528的過程:

1).停止1號機資料庫ORACLE_HOME下所有的資料庫例項(如果有ASM,也要停止):
$srvctl stop instance -d -i
$srvctl stop asm -n

比如:

$srvctl stop instance -d ONEPIECE -i ONEPIECE1
$srvctl stop asm -n nascds14
$crs_stat -t
Name           Type           Target    State     Host      
------------------------------------------------------------
ora....E1.inst application    OFFLINE   OFFLINE            
ora....SM1.asm application    OFFLINE   OFFLINE

2). 在1號機回滾補丁:
比如:
$su - oracle
$cd $ORACLE_HOME/OPatch/8575528
$opatch rollback -id 8575528
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/app/oracle
Central Inventory : /home/oracle/oraInventory
  from           : /etc/oraInst.loc
OPatch version    : 10.2.0.4.2
OUI version       : 10.2.0.4.0
OUI location      : /u01/app/oracle/oui
Log file location : /u01/app/oracle/cfgtoollogs/opatch/opatch2012-06-13_18-22-10PM.log

RollbackSession rolling back interim patch '8575528' from OH '/u01/app/oracle'

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.


This node is part of an Oracle Real Application Cluster.
Remote nodes: 'nascds15'
Local node: 'nascds14'
Please shut down Oracle instances running out of this ORACLE_HOME on all the nodes.
(Oracle Home = '/u01/app/oracle')


Are all the nodes ready for patching? [y|n]
y <=========輸入y
User Responded with: Y
Backing up files affected by the patch '8575528' for restore. This might take a while...

Patching component oracle.rdbms, 10.2.0.4.0...
Updating archive file "/u01/app/oracle/lib/libserver10.a"  with "lib/libserver10.a/kks1.o"
Updating archive file "/u01/app/oracle/lib/libserver10.a"  with "lib/libserver10.a/kksc.o"
Updating archive file "/u01/app/oracle/lib/libserver10.a"  with "lib/libserver10.a/kksh.o"
Updating archive file "/u01/app/oracle/lib/libserver10.a"  with "lib/libserver10.a/ksmp.o"
Running make for target ioracle
RollbackSession removing interim patch '8575528' from inventory

Patching in rolling mode.


The node 'nascds15' will be patched next.


Please shutdown Oracle instances running out of this ORACLE_HOME on 'nascds15'.
(Oracle Home = '/u01/app/oracle')

Is the node ready for patching? [y|n]


3). 然後opatch會問您是否要在另外一個節點上回滾。這時候執行下面的操作。

4). 啟動1號機ASM 例項和資料庫例項:
$srvctl start asm -n
$srvctl start instance -d -i

比如:
$srvctl start asm -n nascds14
$srvctl start instance -d ONEPIECE -i ONEPIECE1

$crs_stat -t
ora....E1.inst application    ONLINE    ONLINE    nascds14  
ora....SM1.asm application    ONLINE    ONLINE    nascds14

5).停止2號機的ASM例項和資料庫例項:
$srvctl stop instance -d -i
$srvctl stop asm -n

$srvctl stop instance -d ONEPIECE -i ONEPIECE2
$srvctl stop asm -n nascds15
$crs_stat -t
ora....E2.inst application    OFFLINE   OFFLINE            
ora....SM2.asm application    OFFLINE   OFFLINE

6). 在之前回滾補丁的那個提示符中,確認繼續下一個節點。
The node 'nascds15' will be patched next.


Please shutdown Oracle instances running out of this ORACLE_HOME on 'nascds15'.
(Oracle Home = '/u01/app/oracle')

Is the node ready for patching? [y|n]
y <=========輸入y
User Responded with: Y
Updating nodes 'nascds15'
  Rollback-related files are:
    FR = "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/remove_files.txt"
    DR = "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/remove_dirs.txt"
    FP = "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_files.txt"
    MP = "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/make_cmds.txt"
    RC = "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/remote_cmds.txt"

Instantiating the file "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/remove_dirs.txt.instantiated"

by replacing $ORACLE_HOME in "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/remove_dirs.txt" with

actual path.
Removing directories on remote nodes...
Instantiating the file "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_files.txt.instantiated"

by replacing $ORACLE_HOME in "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_files.txt" with

actual path.
Propagating files to remote nodes...
Instantiating the file "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_dirs.txt.instantiated"

by replacing $ORACLE_HOME in "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/copy_dirs.txt" with

actual path.
Propagating directories to remote nodes...
Instantiating the file "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/make_cmds.txt.instantiated"

by replacing $ORACLE_HOME in "/u01/app/oracle/.patch_storage/8575528_Aug_17_2010_07_56_36/rac/make_cmds.txt" with

actual path.
Running command on remote node 'nascds15':
cd /u01/app/oracle/rdbms/lib; /usr/bin/make -f ins_rdbms.mk ioracle ORACLE_HOME=/u01/app/oracle || echo

REMOTE_MAKE_FAILED::>&2


The node 'nascds15' has been patched.  You can restart Oracle instances on it.

There were relinks on remote nodes.  Remember to check the binary size and timestamp on the nodes 'nascds15' .
The following make commands were invoked on remote nodes:
'cd /u01/app/oracle/rdbms/lib; /usr/bin/make -f ins_rdbms.mk ioracle ORACLE_HOME=/u01/app/oracle
'


OPatch succeeded.

7). 啟動2號機的ASM例項和資料庫例項:
$srvctl start asm -n
$srvctl start instance -d -i

比如:
$srvctl start asm -n nascds15
$srvctl start instance -d ONEPIECE -i ONEPIECE2

8).在兩個節點分別執行下面的命令來確認補丁已經回滾成功。
$ $ORACLE_HOME/OPatch/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/app/oracle
Central Inventory : /home/oracle/oraInventory
  from           : /etc/oraInst.loc
OPatch version    : 10.2.0.4.2
OUI version       : 10.2.0.4.0
OUI location      : /u01/app/oracle/oui
Log file location : /u01/app/oracle/cfgtoollogs/opatch/opatch2012-06-13_19-40-41PM.log

Lsinventory Output file location : /u01/app/oracle/cfgtoollogs/opatch/lsinv/lsinventory2012-06-13_19-40-41PM.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.


There are no Interim patches installed in this Oracle Home.


Rac system comprising of multiple nodes
 Local node = nascds14
 Remote node = nascds15

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

OPatch succeeded.

本文摘自:https://blogs.oracle.com/Database4CN/entry/%E5%9C%A8rac%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%8A%E6%BB%9A%E5%8A%A8_rolling_%E5%AE%89%E8%A3%85_%E5%9B%9E%E9%80%80%E5%B0%8F%E8%A1%A5%E4%B8%81%E7%9A%84%E6%96%B9%E6%B3%95

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

相關文章