11gR2 RAC out-of-place 滾動升級(1)

westzq1984發表於2013-08-02
本週給一套AIX下RAC庫打PSU
正常情況下,AIX平臺,2個節點打PSU就需要2小時,而且還老出一點檔案無法拷貝的錯
報錯一會滾,OPatch自己的備份又要備份很久
而且經常發生前面的PSU報告有爭用的問題,無法自動回滾掉
要是心裡素質不好,決定要被弄的手忙腳亂

當天升級的時候,客戶都不敢在邊上看了。最後總算是有驚無險完成升級

回來思索grid能否 out-of-place 打PSU,總算找到了一篇文件
Minimal downtime patching via cloning 11gR2 ORACLE_HOME directories (Doc ID 1136544.1)

文件是基於EXADA他的,但是文件中明確說明,適用於其他平臺

安裝可以提前進行,到了計劃時間點,只需要做switch即可,測試1個節點切換10分鐘即可

-------------------------------------------
1.首先,準備新的grid和database的安裝目錄
-------------------------------------------
我的環境是:
當前:/u01/app/11.2.0/grid   /u01/app1/oracle/product/11.2/db_1  11.2.0.3.3
目標:/u01/app/11.2.0/grid_2 /u01/app1/oracle/product/11.2/db_2  11.2.0.3.6

[oracle@database1 11.2]$ pwd
/u01/app/oracle/product/11.2
[oracle@database1 11.2]$ ls -l
total 4
drwxr-xr-x 76 oracle oinstall 4096 Aug  2 11:08 db_1
lrwxrwxrwx  1 oracle oinstall   34 Aug  2 10:44 db_2 -> /u01/app1/oracle/product/11.2/db_2
[oracle@database1 11.2]$ ls -ld  /u01/app1/oracle/product/11.2/db_2
drwxr-xr-x 2 oracle oinstall 4096 Aug  2 10:16 /u01/app1/oracle/product/11.2/db_2

[grid@database1 11.2.0]$ pwd
/u01/app/11.2.0
[grid@database1 11.2.0]$ ls -tlr
total 4
drwxr-xr-x 69 root oinstall 4096 Sep 26  2012 grid
lrwxrwxrwx  1 root root       23 Aug  2 10:46 grid_2 -> /u01/app1/11.2.0/grid_2
[grid@database1 11.2.0]$ ls -ld /u01/app1/11.2.0/grid_2
drwxr-xr-x 2 root oinstall 4096 Aug  2 10:15 /u01/app1/11.2.0/grid_2

-------------------------------------------
2.克隆GRID,兩個節點分別執行
-------------------------------------------
拷貝
# export ORACLE_HOME=/u01/app/11.2.0/grid_2
# cd /u01/app/11.2.0/grid;
# tar cfp - . | ( cd $ORACLE_HOME ; tar xf - )

解鎖
# /usr/bin/perl $ORACLE_HOME/OPatch/crs/patch112.pl -unlock -desthome=$ORACLE_HOME

注意許可權,免得影響
chmod 775 /u01/app/oracle/
chmod 775 /u01/app/11.2.0/grid_2
cd /u01/app/11.2.0/grid_2
ls -l |grep root|awk '{print $9}'|xargs chmod 775

克隆
database1
$ export ORACLE_HOME=/u01/app/11.2.0/grid_2
$ /usr/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE=/u01/app/oracle \
ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME=Ora11g_gridinfrahome1_2 \
INVENTORY_LOCATION=/u01/app/oraInventory \
-O'"CLUSTER_NODES={database1,database2}"' \
-O'"LOCAL_NODE=database1"' CRS=false -O"SHOW_ROOTSH_CONFIRMATION=false"

database2
$ export ORACLE_HOME=/u01/app/11.2.0/grid_2
$ /usr/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE=/u01/app/oracle \
ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME=Ora11g_gridinfrahome1_2 \
INVENTORY_LOCATION=/u01/app/oraInventory \
-O'"CLUSTER_NODES={database1,database2}"' \
-O'"LOCAL_NODE=database2"' CRS=false -O"SHOW_ROOTSH_CONFIRMATION=false"

可能報告JAVA找不到
Checking swap space: must be greater than 500 MB.   Actual 4971 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-08-02_01-45-01PM. Please wait ...The Java RunTime Environment was not found at /tmp/OraInstall2013-08-02_01-45-01PM/jre/bin/java. Hence, the Oracle Universal Installer cannot be run.
Please visit http://www.javasoft.com and install JRE version 1.3.1 or higher and try again.
: No such file or directory
修改  /u01/app1/11.2.0/grid_2/oui/oraparam.ini 中 JRE_LOCATION=/u01/app/11.2.0/grid_2/jdk/jre

可能報告NoClassDefFoundError
Exception in thread "main" java.lang.NoClassDefFoundError: %JRE_MEMORY_OPTIONS%
修改 /u01/app1/11.2.0/grid_2/oui/oraparam.ini 中 JRE_MEMORY_OPTIONS=" -mx150m"

如果以前GRID適用rds協議,那麼clone會導致其切換回udp,需要重新修改
$ export ORACLE_HOME=/u01/app/11.2.0/grid_2
$ cd $ORACLE_HOME/rdbms/lib
$ make -f ins_rdbms.mk ipc_rds ioracle

-------------------------------------------
3.對grid_2 安裝11.2.0.3.6的PSU,兩個節點分別執行
-------------------------------------------
檢查
$ export ORACLE_HOME=/u01/app/11.2.0/grid_2
$ $ORACLE_HOME/OPatch/opatch prereq \
CheckConflictAgainstOH -ph  /u01/app/oracle/admin/olm/software/112036/16315641 \
-invPtrLoc $ORACLE_HOME/oraInst.loc -oh $ORACLE_HOME
$ $ORACLE_HOME/OPatch/opatch prereq \
CheckConflictAgainstOH -ph  /u01/app/oracle/admin/olm/software/112036/16056266 \
-invPtrLoc $ORACLE_HOME/oraInst.loc -oh $ORACLE_HOME

生成ocm.rsp
$ export ORACLE_HOME=/u01/app/11.2.0/grid_2
$ cd /u01/app/oracle
$ $ORACLE_HOME/OPatch/ocm/bin/emocmrsp

回滾11.2.0.3.3 PSU,我在安裝中遇到報告其有爭用
# export ORACLE_HOME=/u01/app/11.2.0/grid_2
# /usr/bin/perl $ORACLE_HOME/OPatch/crs/patch112.pl -unlock -desthome=$ORACLE_HOME
$ export ORACLE_HOME=/u01/app/11.2.0/grid_2
$ opatch rollback -id 13919095 -oh $ORACLE_HOME -local

安裝11.2.0.3.6 PSU
# export ORACLE_HOME=/u01/app/11.2.0/grid_2
# $ORACLE_HOME/OPatch/opatch auto /u01/app/oracle/admin/olm/software/112036 -oh $ORACLE_HOME -ocmrf /u01/app/oracle/ocm.rsp

檢查
$ /u01/app/11.2.0/grid_2/OPatch/opatch lsinventory -oh /u01/app/11.2.0/grid_2


-------------------------------------------
4.克隆ORACLE,兩個節點分別執行
-------------------------------------------
拷貝
# export ORACLE_HOME=/u01/app/oracle/product/11.2/db_2
# cd /u01/app/oracle/product/11.2/db_1
# tar cfp - . | ( cd $ORACLE_HOME ; tar xf - )

克隆
$ export ORACLE_HOME=/u01/app/oracle/product/11.2/db_2
$ cd $ORACLE_HOME/clone/bin
$ ./clone.pl ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME=OraDB_home2 ORACLE_BASE=/u01/app/oracle
-- 確保HOME目錄許可權在755,否則SSH要出問題
$ $ORACLE_HOME/oui/bin/runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={database1,database2}"

如果以前ORACLE適用rds協議,那麼clone會導致其切換回udp,需要重新修改
$ cd $ORACLE_HOME/rdbms/lib;
$ make -f ins_rdbms.mk ipc_rds ioracle

執行root.sh
# export ORACLE_HOME=/u01/app/oracle/product/11.2/db_2
# $ORACLE_HOME/root.sh

安裝11.2.0.3.6 PSU
# export ORACLE_HOME=/u01/app/oracle/product/11.2/db_2
# $ORACLE_HOME/OPatch/opatch auto /u01/app/oracle/admin/olm/software/112036 -oh $ORACLE_HOME -ocmrf /u01/app/oracle/ocm.rsp

檢查
$ /u01/app1/oracle/product/11.2/db_2/OPatch/opatch lsinventory -oh /u01/app1/oracle/product/11.2/db_2
 
 
-------------------------------------------
5.切換,兩個節點分別執行
-------------------------------------------
關閉資料庫
$ export ORACLE_HOME=/u01/app/oracle/product/11.2/db_1
$ $ORACLE_HOME/bin/srvctl stop home -o $ORACLE_HOME -n database1 -s /tmp/mygi.stat

切換GRID 
注意,當前資料庫的PATCHSET是那個版本,就用那個版本的patch1120x.pl
# export ORACLE_HOME=/u01/app/11.2.0/grid_2
# /usr/bin/perl $ORACLE_HOME/OPatch/crs/patch11203.pl -patch -desthome=$ORACLE_HOME

修改環境變數
root
grid
oracle

切換資料庫
srvctl modify database -d orcl -o /u01/app/oracle/product/11.2/db_2

[grid@database1 grid]$ crsctl stat res -t

ora.orcl.db
      1        ONLINE  ONLINE       database1                Open,Running from O
                                                             ld Oracle Home     
      2        ONLINE  ONLINE       database2                Open,Running from O
                                                             ld Oracle Home 
srvctl stop instance -d orcl -i ORCL1
srvctl start instance -d orcl -i ORCL1
srvctl stop instance -d orcl -i ORCL2
srvctl start instance -d orcl -i ORCL2

啟動資料庫,跑指令碼,升級,這個一個節點跑即可

-------------------------------------------
6.如何rollback
-------------------------------------------
DB直接切換配置即可
GRID可以使用指令碼,切換回去即可,測試可行
# export ORACLE_HOME=/u01/app/11.2.0/grid
# /usr/bin/perl $ORACLE_HOME/OPatch/crs/patch11203.pl -patch -desthome=$ORACLE_HOME

 

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

相關文章