27282436 = 27107360 (PSU) + 26925532 (OJVM)


0.为了避免安装补丁运行数据字典脚本时与系统后台作业冲突,查看AutoTask,如果有Enabled的,先Disable,打完补丁后再Enable.

su - oracle
sqlplus "/as sysdba"
set lin 180 pages 10000
COL CLIENT_NAME FORMAT A40
COL CONSUMER_GROUP FORMAT A30
COL WINDOW_GROUP FORMAT A30
select CLIENT_NAME,STATUS,CONSUMER_GROUP,WINDOW_GROUP from dba_autotask_client;

CLIENT_NAME                              STATUS   CONSUMER_GROUP                 WINDOW_GROUP
---------------------------------------- -------- ------------------------------ ------------------------------
auto optimizer stats collection          ENABLED  ORA$AUTOTASK_STATS_GROUP       ORA$AT_WGRP_OS
auto space advisor                       DISABLED ORA$AUTOTASK_SPACE_GROUP       ORA$AT_WGRP_SA
sql tuning advisor                       DISABLED ORA$AUTOTASK_SQL_GROUP         ORA$AT_WGRP_SQ

BEGIN
DBMS_AUTO_TASK_ADMIN.DISABLE(
client_name => 'auto optimizer stats collection', 
operation => NULL, 
window_name => NULL);
END;
/

BEGIN
DBMS_AUTO_TASK_ADMIN.DISABLE(
client_name => 'auto space advisor', 
operation => NULL, 
window_name => NULL);
END;
/

BEGIN
DBMS_AUTO_TASK_ADMIN.DISABLE(
client_name => 'sql tuning advisor', 
operation => NULL, 
window_name => NULL);
END;
/

再确认当前的数据库组件状态是否都正常,并记录当前状态:

set lin 170 pages 10000
select comp_id,status,version from dba_registry;

COMP_ID                        STATUS                 VERSION
------------------------------ ---------------------- ------------------------------
OWB                            VALID                  11.2.0.4.0
APEX                           VALID                  3.2.1.00.12
EM                             VALID                  11.2.0.4.0
AMD                            VALID                  11.2.0.4.0
SDO                            VALID                  11.2.0.4.0
ORDIM                          VALID                  11.2.0.4.0
XDB                            VALID                  11.2.0.4.0
CONTEXT                        VALID                  11.2.0.4.0
EXF                            VALID                  11.2.0.4.0
RUL                            VALID                  11.2.0.4.0
OWM                            VALID                  11.2.0.4.0
CATALOG                        VALID                  11.2.0.4.0
CATPROC                        VALID                  11.2.0.4.0
JAVAVM                         VALID                  11.2.0.4.0
XML                            VALID                  11.2.0.4.0
CATJAVA                        VALID                  11.2.0.4.0
APS                            VALID                  11.2.0.4.0
XOQ                            VALID                  11.2.0.4.0
RAC                            VALID                  11.2.0.4.0

19 rows selected.

1.以grid用户停止listener,并kill数据库会话进程

su - grid
srvctl stop listener
srvctl stop scan_listener
kill -9 `ps -ef|grep LOCAL=NO|grep -v grep|grep -iv ASM|awk '{print $2}'`

2.以oracle用户禁用db自动启动,然后停止db

su - oracle
srvctl disable db -d pubdb
srvctl stop db -d pubdb

3.(该步骤已经提前执行完成)以root用户替换opatch工具到最新版本

su - root
cat /home/oracle/.profile | grep HOME
export PATCH_DIR=/oracle/software
export PATCH_GRID_HOME=/grid/app/11.2.0.4/grid
export PATCH_ORACLE_HOME=/oracle/app/oracle/11.2.0.4/db_1
mv $PATCH_GRID_HOME/OPatch $PATCH_GRID_HOME/Opatch.orig`date +%Y%m%d`
mv $PATCH_ORACLE_HOME/OPatch $PATCH_ORACLE_HOME/OPatch.orig`date +%Y%m%d`

cd $PATCH_DIR
unzip p6880880_112000_HPUX-IA64.zip
cp -r ./OPatch $PATCH_GRID_HOME/
cp -r ./OPatch $PATCH_ORACLE_HOME/
cd $PATCH_GRID_HOME/; chown -R grid:oinstall ./OPatch
cd $PATCH_ORACLE_HOME/; chown -R oracle:oinstall ./OPatch

4.按照下面的步骤安装补丁


su - oracle
export PATCH_DIR=/oracle/software

cd $ORACLE_HOME/OPatch/ocm/bin
./emocmrsp -output /tmp/ocm.rsp

cd $PATCH_DIR
unzip p27282436_112040_HPUX-IA64.zip

su - root

a.检查root用户的环境变量,如果有ORACLE_HOME,ORA_GRID_HOME,GRID_HOME等设置,需要注销这些环境变量,然后重新登录系统;
b.检查安装crs和db的文件系统空间是否足够,打补丁前至少要保证50G空闲空间;
c.检查root/grid/oracle用户的crontab作业,打补丁前先注销访问$ORACLE_HOME和$GRID_HOME的作业,打完补丁后再启用
d.查看是否有未注册到OCR里的grid/oracle独立进程,例如其他的listener,通过kill -9 杀掉这些进程;如果不确定哪些进程是独立的
,可以考虑先停止CRS后再重新拉起来,然后执行后续的步骤


su - root
export PATCH_DIR=/oracle/software
export PATCH_GRID_HOME=/grid/app/11.2.0.4/grid
export PATCH_ORACLE_HOME=/oracle/app/oracle/11.2.0.4/db_1
export PSU_PATCH_ID=27282436/27107360
# $PATCH_GRID_HOME/OPatch/opatch auto $PATCH_DIR/$PSU_PATCH_ID -oh $PATCH_GRID_HOME -ocmrf /tmp/ocm.rsp
# $PATCH_ORACLE_HOME/OPatch/opatch auto $PATCH_DIR/$PSU_PATCH_ID -oh $PATCH_ORACLE_HOME -ocmrf /tmp/ocm.rsp

报错处理

Opatch version check failed for oracle home /grid/app/11.2.0.4/grid
Opatch version check failed
ERROR: update the opatch version for the failed homes and retry

UtilSession failed: IPMRWServices::verifyPatchStorageDirectory() cannot read or write to /grid/app/11.2.0.4/grid/.patch_storage

OPatch failed with error code 73

CRMAPP3#[/]#cd /grid/app/11.2.0.4/grid/
CRMAPP3#[/grid/app/11.2.0.4/grid]#mkdir .patch_storage
CRMAPP3#[/grid/app/11.2.0.4/grid]#chown grid:oinstall .patch_storage

----------以下脚本用于补丁回滚操作----------

######### $PATCH_GRID_HOME/OPatch/opatch auto $PATCH_DIR/$PSU_PATCH_ID -rollback -oh $PATCH_GRID_HOME -ocmrf /tmp/ocm.rsp
######### $PATCH_ORACLE_HOME/OPatch/opatch auto $PATCH_DIR/$PSU_PATCH_ID -rollback -oh $PATCH_ORACLE_HOME -ocmrf /tmp/ocm.rsp

su - grid
$ORACLE_HOME/OPatch/opatch lsinv

su - oracle
$ORACLE_HOME/OPatch/opatch lsinv