Opatching PSU in Oracle Database 11g Release 2(11.2.0.4) RAC on RHEL6
1) 升级opatch工具
1.1) For GI home su - root export GI_HOME=$(grep '^+ASM' /etc/oratab |awk -F: '{ print $2 }') [[ -d "${GI_HOME}/OPatch" ]] && mv ${GI_HOME}/OPatch ${GI_HOME}/OPatch_$(date +%Y%m%d) .zip -d ${GI_HOME} ls -ld ${GI_HOME}/OPatch* chown -R grid:oinstall ${GI_HOME}/OPatch chmod -R +x ${GI_HOME}/OPatch ls -ld ${GI_HOME}/OPatch* su - grid ${ORACLE_HOME}/OPatch/opatch version # --创建响应文件 (;;echo -e 'Y\n')|${ORACLE_HOME}/OPatch/ocm/bin/emocmrsp -no_banner -output /tmp/ocm.rsp 1.2) For DB home su - oracle [[ -d "${ORACLE_HOME}/OPatch" ]] && mv ${ORACLE_HOME}/OPatch ${ORACLE_HOME}/OPatch_$(date +%Y%m%d) ls -ld ${ORACLE_HOME}/OPatch* .zip -d ${ORACLE_HOME} ls -ld ${ORACLE_HOME}/OPatch* ${ORACLE_HOME}/OPatch/opatch version
2) 安装GI PSU补丁
su - root export GI_HOME=$(grep '^+ASM' /etc/oratab |awk -F: '{ print $2 }') export DB_HOME=$(grep -Ev '^#|^$|+ASM' /etc/oratab |awk -F: '{ print $2 }') # su - grid -c "(sleep 3;echo -e '\n';sleep 3;echo -e 'Y\n')|${GI_HOME}/OPatch/ocm/bin/emocmrsp -no_banner -output /tmp/ocm.rsp" su - grid -c "unzip -oq p28317141_112040_Linux-x86-64.zip -d /apps/soft" export UNZIPPED_PATCH_LOCATION=/apps/soft/ export LANG=C ${GI_HOME}/OPatch/opatch auto ${UNZIPPED_PATCH_LOCATION}/ -ocmrf /tmp/ocm.rsp -- 检查确认 su - grid -c "${GI_HOME}/bin/crsctl status res -t" su - grid -c "${GI_HOME}/OPatch/opatch lspatches;${GI_HOME}/OPatch/opatch lsinventory" su - oracle -c "${DB_HOME}/OPatch/opatch lspatches;${DB_HOME}/OPatch/opatch lsinventory"
3) 升级数据字典
su - oracle sqlplus /nolog << EOF connect / as sysdba @?/rdbms/admin/catbundle.sql psu apply @?/rdbms/admin/utlrp.sql set lines pages col action_time for a20 col action for a15 col namespace for a12 col version for a18 col col bundle_series for a15 col comments for a28 prompt db version select to_char(t1.action_time,'yyyy-mm-dd hh24:mi:ss') action_time,t1.action,t1.namespace,t1.version,id,t1.bundle_series,t1.comments from dba_registry_history t1 order by t1.action_time; prompt prompt comp info col comp_name for a48 col comp_id for a12 col version for a16 col status for a12 col modified for a20 select t2.comp_id, t2.comp_name, t2.version, t2.status, to_char(to_date(t2.modified,'dd-mm-yyyy hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') modified from dba_registry t2 order by t2.modified,t2.comp_id; quit; EOF
4) 安装OJVM PSU
su - oracle # 关闭db home的所有服务 srvctl stop database -d orcl # 冲突检查 PATCH_TOP_DIR=/apps/soft/ cd ${PATCH_TOP_DIR}/ opatch prereq CheckConflictAgainstOHWithDetail -ph ./ # 安装补丁 (;;;;echo -e 'Y\n')|${ORACLE_HOME}/OPatch/opatch apply # 结果检查确认 ${ORACLE_HOME}/OPatch/opatch lspatches;${ORACLE_HOME}/OPatch/opatch lsinventory
5) 升级数据字典
sqlplus /nolog << EOF host srvctl start instance -d orcl -i orcl1 connect / as sysdba alter system set cluster_database=false scope=spfile; host srvctl stop instance -d orcl -i orcl1 connect / as sysdba startup upgrade @?/sqlpatch//postinstall.sql alter system set cluster_database=true scope=spfile; host srvctl stop instance -d orcl -i orcl1 host srvctl start database -d orcl connect / as sysdba @?/rdbms/admin/utlrp.sql set lines pages col action_time for a20 col action for a15 col namespace for a12 col version for a24 col col bundle_series for a15 col comments for a28 prompt db version select to_char(t1.action_time,'yyyy-mm-dd hh24:mi:ss') action_time,t1.action,t1.namespace,t1.version,id,t1.bundle_series,t1.comments from dba_registry_history t1 order by t1.action_time; prompt prompt comp info col comp_name for a48 col comp_id for a12 col version for a16 col status for a12 col modified for a20 select t2.comp_id, t2.comp_name, t2.version, t2.status, to_char(to_date(t2.modified,'dd-mm-yyyy hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') modified from dba_registry t2 order by t2.modified,t2.comp_id; quit; EOF