RAC和ASM環境下打patch

space6212發表於2019-04-10

在RAC環境下打patch與單節點類似,不過在RAC環境下Oracle提供了rolling patch方式,降低打patch對資料庫的影響。

以下是基於RAC + ASM環境的patch步驟,簡單記錄。

[@more@]1. 首先解壓檔案
[oracle@dwdb01 tmp]$ unzip p10017048_10205_Linux-x86-64.zip
Archive: p10017048_10205_Linux-x86-64.zip
creating: 10017048/
creating: 10017048/files/
creating: 10017048/files/lib/
creating: 10017048/files/lib/libserver10.a/
inflating: 10017048/files/lib/libserver10.a/kkfd.o
creating: 10017048/etc/
creating: 10017048/etc/config/
inflating: 10017048/etc/config/inventory
inflating: 10017048/etc/config/actions
creating: 10017048/etc/xml/
inflating: 10017048/etc/xml/GenericActions.xml
inflating: 10017048/etc/xml/ShiphomeDirectoryStructure.xml
inflating: 10017048/README.txt

2. 停止服務

這裡要分幾種情況:
1) 如果是rolling patch方式打補丁,則只需要先停止第一個需要patch的節點;為了簡單起見,你也可以停止所有的節點例項,不過這樣的話停機時間會增加。
2) 如果ASM和Oracle例項執行在同一個ORACLE_HOME下,則需要把ASM和資料庫例項都關閉,否則只需要管理資料庫例項即可。

這裡的環境是ASM和Oracle例項在同一個ORACLE_HOME下,也因為這還不是生產庫,因此可以簡單地把相關服務都停掉。
[oracle@dwdb01 10017048]$ srvctl stop database -d dwrac
[oracle@dwdb01 10017048]$ srvctl stop asm -n dwdb01
[oracle@dwdb01 10017048]$ srvctl stop asm -n dwdb02
[oracle@dwdb01 10017048]$ srvctl stop asm -n dwdb03
[oracle@dwdb01 10017048]$ srvctl stop asm -n dwdb04
可以透過crs_stat檢查一下狀態。

3. 打補丁
[oracle@dwdb01 ]$ cd 10017048
[oracle@dwdb01 10017048]$ export ORACLE_SID=dwrac1
[oracle@dwdb01 10017048]$ /oracle/product/10.2.0/db/OPatch/opatch apply
Invoking OPatch 10.2.0.4.9

Oracle Interim Patch Installer version 10.2.0.4.9
Copyright (c) 2009, Oracle Corporation. All rights reserved.


Oracle Home : /oracle/product/10.2.0/db
Central Inventory : /oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 10.2.0.4.9
OUI version : 10.2.0.5.0
OUI location : /oracle/product/10.2.0/db/oui
Log file location : /oracle/product/10.2.0/db/cfgtoollogs/opatch/opatch2011-02-23_19-13-23PM.log

Patch history file: /oracle/product/10.2.0/db/cfgtoollogs/opatch/opatch_history.txt

ApplySession applying interim patch '10017048' to OH '/oracle/product/10.2.0/db'

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: 'dwdb02' 'dwdb03' 'dwdb04'
Local node: 'dwdb01'
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/oracle/product/10.2.0/db')


Is the local system ready for patching? [y|n]
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 '10017048' for restore. This might take a while...
Backing up files affected by the patch '10017048' for rollback. This might take a while...

Patching component oracle.rdbms, 10.2.0.5.0...
Updating archive file "/oracle/product/10.2.0/db/lib/libserver10.a" with "lib/libserver10.a/kkfd.o"
Running make for target ioracle
ApplySession adding interim patch '10017048' to inventory

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

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


Patching in rolling mode.

Remaining nodes to be patched:
'dwdb02' 'dwdb03' 'dwdb04'
What is the next node to be patched?
dwdb02
You have selected 'dwdb02' from 'dwdb02' 'dwdb03' 'dwdb04'

The node 'dwdb02' will be patched next.


Please shutdown Oracle instances running out of this ORACLE_HOME on 'dwdb02'.
(Oracle Home = '/oracle/product/10.2.0/db')

Is the node ready for patching? [y|n]
y
User Responded with: Y
Updating nodes 'dwdb02'
Apply-related files are:
FP = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_files.txt"
DP = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_dirs.txt"
MP = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/make_cmds.txt"
RC = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/remote_cmds.txt"

Instantiating the file "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_files.txt.instantiated" by replacing $ORACLE_HOME in "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_files.txt" with actual path.
Propagating files to remote nodes...
Instantiating the file "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_dirs.txt.instantiated" by replacing $ORACLE_HOME in "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_dirs.txt" with actual path.
Propagating directories to remote nodes...
Instantiating the file "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/make_cmds.txt.instantiated" by replacing $ORACLE_HOME in "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/make_cmds.txt" with actual path.
Running command on remote node 'dwdb02':
cd /oracle/product/10.2.0/db/rdbms/lib; /usr/bin/make -f ins_rdbms.mk ioracle ORACLE_HOME=/oracle/product/10.2.0/db || echo REMOTE_MAKE_FAILED::>&2


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

Remaining nodes to be patched:
'dwdb03' 'dwdb04'
What is the next node to be patched?
dwdb03
You have selected 'dwdb03' from 'dwdb03' 'dwdb04'

The node 'dwdb03' will be patched next.


Please shutdown Oracle instances running out of this ORACLE_HOME on 'dwdb03'.
(Oracle Home = '/oracle/product/10.2.0/db')

Is the node ready for patching? [y|n]
y
User Responded with: Y
Updating nodes 'dwdb03'
Apply-related files are:
FP = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_files.txt"
DP = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_dirs.txt"
MP = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/make_cmds.txt"
RC = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/remote_cmds.txt"

Propagating files to remote nodes...
Propagating directories to remote nodes...
Instantiating the file "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/make_cmds.txt.instantiated" by replacing $ORACLE_HOME in "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/make_cmds.txt" with actual path.
Running command on remote node 'dwdb03':
cd /oracle/product/10.2.0/db/rdbms/lib; /usr/bin/make -f ins_rdbms.mk ioracle ORACLE_HOME=/oracle/product/10.2.0/db || echo REMOTE_MAKE_FAILED::>&2


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


The node 'dwdb04' will be patched next.


Please shutdown Oracle instances running out of this ORACLE_HOME on 'dwdb04'.
(Oracle Home = '/oracle/product/10.2.0/db')

Is the node ready for patching? [y|n]
y
User Responded with: Y
Updating nodes 'dwdb04'
Apply-related files are:
FP = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_files.txt"
DP = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/copy_dirs.txt"
MP = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/make_cmds.txt"
RC = "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/remote_cmds.txt"

Propagating files to remote nodes...
Propagating directories to remote nodes...
Instantiating the file "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/make_cmds.txt.instantiated" by replacing $ORACLE_HOME in "/oracle/product/10.2.0/db/.patch_storage/10017048_Sep_15_2010_06_14_25/rac/make_cmds.txt" with actual path.
Running command on remote node 'dwdb04':
cd /oracle/product/10.2.0/db/rdbms/lib; /usr/bin/make -f ins_rdbms.mk ioracle ORACLE_HOME=/oracle/product/10.2.0/db || echo REMOTE_MAKE_FAILED::>&2


The node 'dwdb04' 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 'dwdb02' 'dwdb03' 'dwdb04' .
The following make commands were invoked on remote nodes:
'cd /oracle/product/10.2.0/db/rdbms/lib; /usr/bin/make -f ins_rdbms.mk ioracle ORACLE_HOME=/oracle/product/10.2.0/db
'


OPatch succeeded.

整個打補丁的過程,Oracle會詢問是否需要在其他節點打,直到所有節點都打上補丁。注意,要用到這一特性,需要配置ssh互信。

4. 最後啟動asm和資料庫例項
[oracle@dwdb01 bin]$ srvctl start asm -n dwdb01
[oracle@dwdb01 bin]$ srvctl start asm -n dwdb02
[oracle@dwdb01 bin]$ srvctl start asm -n dwdb03
[oracle@dwdb01 bin]$ srvctl start asm -n dwdb04
[oracle@dwdb01 bin]$ srvctl start database -d dwrac
[oracle@dwdb01 bin]$ srvctl start service -d dwrac



如果嚴格使用rolling patch的方式的話,則步驟是:
1. 在第一個節點停止ASM和Oracle instance(ASM和Oracle共用一個ORACLE_HOME)

srvctl stop instance -d dwrac -i dwrac1
srvctl stop asm -n dwdb01

2. 在第一個節點打補丁

opatch apply
打完第一個補丁後,Oracle會詢問下一個需要打patch是那個。

3. 另開視窗,啟動第一個節點的資源,並關閉下一個需要打patch的資源

srvctl start instance -d dwrac -i dwrac1
srvctl start asm -n dwdb01
srvctl stop instance -d dwrac -i dwrac2
srvctl stop asm -n dwdb02

4. 依此類推,直到所有節點打完patch為止


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

相關文章