在RAC数据库上滚动(Rolling)安装/回退小补丁的方法


在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 <dbname> -i <instance_name>
$srvctl stop asm -n <nodename>

比如:

$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 <nodename>
$srvctl start instance -d <dbname> -i <instance_name>

比如:
$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 <dbname> -i <instance_name>
$srvctl stop asm -n <nodename>

$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 <nodename>
$srvctl start instance -d <dbname> -i <instance_name>

比如:
$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.

  • 1
  • 2
  • 下一页

相关内容