11g Rac PSU20180116手动补丁升级步骤

手动升级:
软件包解压在新建的/home/grid/update 目录下
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
GRID_HOME=/u01/app/11.2.0/grid/

一、ORACLE 11G R2 RAC 备份

DB: 11.2.0.4
OS: REDHAT 6.X
PATCH: 20170718

建议:操作前停止所有应用服务,停止所有中间件服务,关闭监听。

1.1 数据库RMAN 全备,【见备份脚本】;

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;
}
EOF


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 -showbackup

如果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 -manualbackup



1.4 备份安装软件目录
1、分别关闭实例
sqlplus / as sysdba
alter system checkpoint;
shutdown immediate;

2、分别 crsctl stop has
/u01/app/11.2.0/grid/bin/crsctl stop has

3、备份数据库所有安装目录(注意,保留权限)
先查看软件目录空间多大,再根目录空间是否足够。(root用户)

cd /
du -sm * | sort

备份安装软件目录:tar cvpzf oracle.tgz /u01
使用下面的命令来恢复系统:# tar xvpfz backup.tgz -C /

备份完后,两边开启集群资源。

/u01/app/11.2.0/grid/bin/crsctl start has

二、替换原有的grid用户和oracle用户下的Opatch

1、新建补丁包目录【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

3、预检查
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


三、手工补丁升级

Manual Steps for Apply Patch

3.1、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.2、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.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.4、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.5、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.6、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.7、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.8、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.9、检查

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.11、数据库的应用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.12、如果使用了RMAN,需要将RMAN catalog库升级一下,执行:
$ rman catalog username/password@alias
RMAN> UPGRADE CATALOG;

原文地址:https://www.cnblogs.com/hmwh/p/10450179.html