手動升級:
軟件包解壓在新建的/home/grid/update 目錄下
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
GRID_HOME=/u01/app/11.2.0/grid/sql
1、ORACLE 11G R2 RAC 備份數據庫
DB: 11.2.0.4
OS: REDHAT 6.X
PATCH: 20170718
建議:操做前中止全部應用服務,中止全部中間件服務,關閉監聽。oracle
1.1 數據庫RMAN 全備,【見備份腳本】;app
rman target / nocatalog log /home/oracle/rman_full.log <<EOF
run
{crosscheck backup;
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt expired backup;
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup filesperset 6 database format '/backup/full_%d_%T_%s_%p.dbf';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup archivelog from time 'sysdate-1/24' format '/backup/arch_%d_%T_%s_%p.arc';
backup current controlfile format '/backup/ctl_%d_%T_%s_%p.ctl';
backup spfile format '/backup/spfile_%d_%U';
restore database validate;
restore controlfile validate;
}
EOFpost
1.2 OCR 備份 【root用戶執行備份】
OCR的自動備份:使用ocrconfig -showbackup查看ocr備份所在節點及路徑
/u01/app/11.2.0/grid/bin/ocrconfig -showbackup
OCR的手動備份:
/u01/app/11.2.0/grid/bin/ocrconfig -manualbackup
備份完後查看新的備份:
/u01/app/11.2.0/grid/bin/ocrconfig -showbackupthis
若是OCR須要改變路徑,建議導出這種方式:
/u01/app/11.2.0/grid/bin/ocrconfig -export /u01/ocr_20180124.ocr
1.3 OLR 備份
查看路徑: /u01/app/11.2.0/grid/bin/ocrcheck -local
手工備份OLR: /u01/app/11.2.0/grid/bin/ocrconfig -local -manualbackuprest
1.4 備份安裝軟件目錄
一、分別關閉實例
sqlplus / as sysdba
alter system checkpoint;
shutdown immediate;
二、分別 crsctl stop has
/u01/app/11.2.0/grid/bin/crsctl stop has日誌
三、備份數據庫全部安裝目錄(注意,保留權限)
先查看軟件目錄空間多大,再根目錄空間是否足夠。(root用戶)
cd /
du -sm * | sort
備份安裝軟件目錄:tar cvpzf oracle.tgz /u01
使用下面的命令來恢復系統:# tar xvpfz backup.tgz -C /
備份完後,兩邊開啓集羣資源。
/u01/app/11.2.0/grid/bin/crsctl start hascomponent
2、替換原有的grid用戶和oracle用戶下的Opatchorm
一、新建補丁包目錄【2個節點都執行,都須要補丁包和opatch軟件包】
mkdir -p /home/grid/update
chown -R grid:oinstall /home/grid/update
chmod 777 /home/grid/update
軟件包解壓在/home/grid/update 目錄下
解壓補丁包(root 用戶)
unzip p27107360_112040_Linux-x86-64.zip
把解壓的目錄命名爲:27107360
chown -R grid:oinstall /home/grid/update/27107360
unzip p6880880_112000_Linux-x86-64.zip
備份原有Opatch
mv /u01/app/11.2.0/grid/OPatch/ /u01/app/11.2.0/grid/OPatch.bak
mv /u01/app/oracle/product/11.2.0/dbhome_1/OPatch /u01/app/oracle/product/11.2.0/dbhome_1/OPatch.bak
copy新的OPatch到相應用戶路徑下
cp -R /home/grid/update/OPatch /u01/app/11.2.0/grid/OPatch
cp -R /home/grid/update/OPatch /u01/app/oracle/product/11.2.0/dbhome_1/OPatch
賦予新的OPatch文件權限。
chown -R grid:oinstall /u01/app/11.2.0/grid/OPatch
chmod 755 /u01/app/11.2.0/grid/OPatch
chown -R oracle:oinstall /u01/app/oracle/product/11.2.0/dbhome_1/OPatch
chmod 755 /u01/app/oracle/product/11.2.0/dbhome_1/OPatch
查看替換後的 OPatch
ls -lh /u01/app/11.2.0/grid/
ls -lh /u01/app/oracle/product/11.2.0/dbhome_1
三、預檢查
grid:
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/update/27107360/26609929
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/update/27107360/22502505
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/update/27107360/26925576
oracle:
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/update/27107360/26925576
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/update/27107360/26609929/custom/server/26609929
3、手工補丁升級
Manual Steps for Apply Patch
3.一、Stop the CRS managed resources running from DB homes. If this is a GI Home environment, as the database home owner execute:
oracle 兩個節點執行:
$ORACLE_HOME/bin/srvctl stop home -o $ORACLE_HOME -s /home/oracle/update/1.txt -n rac1
$ORACLE_HOME/bin/srvctl stop home -o $ORACLE_HOME -s /home/oracle/update/2.txt -n rac2
3.二、Run the pre root script. If this is a GI Home, as the root user execute:
root 兩節點執行:
/u01/app/11.2.0/grid/crs/install/rootcrs.pl -unlock
3.三、Apply the CRS patch using. As the GI home owner execute:
grid 兩節點執行:
$ORACLE_HOME/OPatch/opatch napply -oh $ORACLE_HOME -local /home/grid/update/27107360/26609929
$ORACLE_HOME/OPatch/opatch napply -oh $ORACLE_HOME -local /home/grid/update/27107360/22502505
$ORACLE_HOME/OPatch/opatch apply -oh $ORACLE_HOME -local /home/grid/update/27107360/26925576
3.四、Run the pre script for DB component of the patch. As the database home owner execute:
oracle 兩節點執行:
/home/grid/update/27107360/26609929/custom/server/26609929/custom/scripts/prepatch.sh -dbhome $ORACLE_HOME
3.五、Apply the DB patch. As the database home owner execute:
oracle 兩節點執行:
$ORACLE_HOME/OPatch/opatch napply -oh $ORACLE_HOME -local /home/grid/update/27107360/26609929/custom/server/26609929
$ORACLE_HOME/OPatch/opatch apply -oh $ORACLE_HOME -local /home/grid/update/27107360/26925576
3.六、Run the post script for DB component of the patch. As the database home owner execute:
oracle 兩節點執行:
/home/grid/update/27107360/26609929/custom/server/26609929/custom/scripts/postpatch.sh -dbhome $ORACLE_HOME
3.七、Run the post script. As the root user execute:
root:
/u01/app/11.2.0/grid/rdbms/install/rootadd_rdbms.sh
/u01/app/11.2.0/grid/crs/install/rootcrs.pl -patch
3.八、Start the CRS managed resources that were earlier running from DB homes. If this is a GI Home environment, as the database home owner execute:
oracle 兩節點執行:
$ORACLE_HOME/bin/srvctl start home -o $ORACLE_HOME -s /home/oracle/update/1.txt -n rac1
$ORACLE_HOME/bin/srvctl start home -o $ORACLE_HOME -s /home/oracle/update/2.txt -n rac2
3.九、檢查
As the Oracle Grid Infrastructure owner, run the following command:
grid:
/u01/app/11.2.0/grid/OPatch/opatch lsinventory
oracle:
/u01/app/oracle/product/11.2.0/dbhome_1/OPatch/opatch lsinventory
3.十一、數據庫的應用PSU
在任意一臺節點用oracle用戶鏈接到數據庫上(只需在一臺節點執行一次,不須要全部節點都執行):
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> @?/rdbms/admin/catbundle.sql psu apply
查看應用的psu
set line 150
col ACTION_TIME for a30
col ACTION for a8
col NAMESPACE for a8
col VERSION for a10
col BUNDLE_SERIES for a5
col COMMENTS for a20
select * from dba_registry_history;
編譯無效的對象:
SQL>@?/rdbms/admin/utlrp.sql
若是升級的補丁有報錯,查看一下日誌:
cd $ORACLE_BASE/cfgtoollogs/catbundle
catbundle_PSU_<database SID>_APPLY_<TIMESTAMP>.log
catbundle_PSU_<database SID>_GENERATE_<TIMESTAMP>.log
3.十二、若是使用了RMAN,須要將RMAN catalog庫升級一下,執行:$ rman catalog username/password@aliasRMAN> UPGRADE CATALOG;