成都网站建设设计

将想法与焦点和您一起共享

OJVM+GIPSU补丁升级

先在DataGuard上执行,DataGuard所有节点升级成功后,在生产上执行,dg不需要执行升级后跑脚本操作,只需当主备库补丁都打完后在主库一个节点执行即可;
当升级前主库需要停止日志传输到备库,备库需要停止日志应用;
当升级完成后注意检查主备库应用情况;


核心步骤如下:
1.主库禁用日志传送到备库
2.关闭备库,应用补丁,但不执行脚本(catpatch.sql等),启动到mount,不启用日志恢复
3.关闭主库,应用补丁,执行脚本(run catpatch/catbundle/catcpu等)
4.启动主库,重新开启日志传送到备库
5.备库开启日志恢复
6.检查补丁应用情况



************************************************
*     一、主备库升级前检查及相关操作           *
************************************************
This patch is Data Guard Standby First Installable - See My Oracle Support Document 1265700.1 Oracle Patch Assurance - Data Guard Standby-First Patch Apply for details on how to remove risk and reduce downtime when applying this patch.

---升级前主库/DG备库执行----
先主库停止传输日志
alter system set log_archive_dest_state_2=defer;

--备库见检查数据库状态,角色;然后备库修改,停止日志应用,并关闭所有节点(根据所打补丁看是否需要停数据库)
select inst_id,host_name,instance_name,status from gv$instance;
select inst_id,database_role,switchover_status from gv$database;

recover managed standby database cancel;

shutdown immediate;     --根据所打补丁看是否需要停数据库



--主/备应用补丁如下列一二三四五步骤所述进行,注意:备库的补丁升级后注册操作不需要做:

************************************************
*     二、以下步骤依次在RAC的所有节点执行      *
************************************************
1. 确认opatch版本
   su - oracle
   opatch version   ——11.2.0.3.6或以上
   su - grid
   opatch version   ——11.2.0.3.6或以上

2. 升级opatch(如果第1步不满足,则执行此步,否则忽略)
   su - oracle
   unzip p6880880_112000_Linux-x86-64.zip -d $ORACLE_HOME
   opatch version
   su - grid
   unzip p6880880_112000_Linux-x86-64.zip -d $GI_HOME
   opatch version



************************************************
*     三、以下步骤依次在RAC的所有节点执行      *
************************************************
打GI PSU
How to Create an OCM Response file to Apply a Patch in Silent Mode - opatch silent (文档 ID 966023.1)
2.1. 创建OCM文件
   su - oracle
   $ORACLE_HOME/OPatch/ocm/bin/emocmrsp -no_banner -output /home/oracle/ocm.rsp
   chmod 775 /home/oracle/ocm.rsp

-- Validation of Oracle Inventory(以GI和DB用户分别运行)
/OPatch/opatch lsinventory -detail -oh
$ORACLE_HOME/OPatch/opatch lsinventory -detail -oh  $ORACLE_HOME


2.2 停止EM进程(如果没有安装EM,则忽略)
   su - oracle
   emctl stop dbconsole
   
--One-off Patch Conflict Detection and Resolution补丁冲突检测
How to Use the My Oracle Support Conflict Checker Tool for Patches Installed with OPatch [Video] (文档 ID 1091294.1)

2.3 升级PSU (As root user, execute the following command on each node of the cluster:不能并行执行)
   su - root
   cd /tmp/patch
   unzip p26030870_112040_Linux-x86-64.zip
   opatch auto /tmp/patch/26030870/26030799 -ocmrf /home/oracle/ocm.rsp

使用GI下的opatch工具


*****************************************************
*     四、OJVM补丁升级                              *
*****************************************************

3. OJVM补丁升级(db下执行)

3.1 检查补丁冲突
    $ cd /tmp/patch/26030870/26027154
    $ opatch prereq CheckConflictAgainstOHWithDetail -ph ./
    
3.2 检查数据库连接数、关闭监听、最后关闭crs(所有节点都执行)
--检查pmon进程:
    ps -ef|grep pmon

--检查连接数、杀连接、关监听
    ps -ef|grep LOCAL=NO|grep -v grep |wc -l
    
    ps -ef|grep LOCAL=NO|grep -v grep|awk '{print $2}'|xargs kill -9    
    
    lsnrctl stop
    
--停crs:
    crsctl stop crs   
   
3.3 应用补丁:
    cd /tmp/patch/26030870/26027154
    opatch apply -local
    
3.4 确认补丁数据库是否应用
    opatch lsinventory
    opatch lspatches  
    
3.5 启所有已经打完补丁的节点的crs
    crsctl start crs


***************************************************************************************
*     五、升级成功后,在生产的一个节点上执行(且在主库的一个节点打就行,备库不打      *
***************************************************************************************
--For an Oracle RAC environment, perform these steps on only one node.(在主库一个节点执行即可,备库不用执行,且主备库的补丁都已经应用成功)
SQL installation is performed after the primary database and all standby databases have the database home binaries patched to the same level。

4.1 大GI PSU升级后脚本
-- 执行catbundle.sql文件
   cd $ORACLE_HOME/rdbms/admin
   sqlplus /nolog
   SQL> CONNECT / AS SYSDBA
   SQL> STARTUP
   SQL> @catbundle.sql psu apply
   SQL> QUIT
   
 --执行重编译
   cd $ORACLE_HOME/rdbms/admin
   sqlplus /nolog
   SQL> CONNECT / AS SYSDBA
   SQL> @utlrp.sql
   
 -- Check the following log files in $ORACLE_BASE/cfgtoollogs/catbundle for any errors:
   catbundle_PSU__APPLY_.log
   catbundle_PSU__GENERATE_.log
 
 
-- 升级RMAN CATALOG(如果没有用到Oracle Recovery Manager,则忽略)
   su - oracle
   rman catalog username/password@alias
   RMAN> UPGRADE CATALOG;
   
-- 验证:DB和GI下都执行
   opatch lspatches
       
4.2 OJVM补丁升级后注册操作

-- 通过针对单个实例环境运行以下命令来安装修补程序的SQL部分。
注意:此步骤适用于单实例打OJVM PSU
cd $ORACLE_HOME/sqlpatch/26027154
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> startup upgrade
SQL> @postinstall.sql
SQL> shutdown
SQL> startup    

-- 对于Oracle RAC环境,请使用以下命令重新加载其中一个节点上的软件包。 确保远程节点上没有其他数据库实例处于启动状态。
注意:此步骤需要关闭rac上非跑脚本的其他实例

cd $ORACLE_HOME/sqlpatch/26027154
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> alter system set cluster_database=false scope=spfile;
SQL> SHUTDOWN
SQL> STARTUP UPGRADE
SQL> @postinstall.sql
SQL> alter system set cluster_database=true scope=spfile;
SQL> SHUTDOWN
SQL> STARTUP

-- 在安装补丁的SQL部分之后,一些软件包可能变为无效。 这将在访问时得到重新编译,或者你可以运行utlrp.sql让它们回到有效状态。
注意:RAC或者单实例都需要执行

cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> @utlrp.sql


*****************************************************
*     六、如果出现异常,回滚并停止升级,分析原因    *
*****************************************************
   回滚(GI PUS)
   su - root
   opatch auto /tmp/patch/26030799 -rollback -ocmrf /home/oracle/ocm.rsp

   回滚注册:注意需要在当时打补丁完成后注册的那个rac节点上操作
   step 1:Start all database instances running from the Oracle home. (For more information, see Oracle Database Administrator's Guide.)
   step 2:For each database instance running out of the ORACLE_HOME, connect to the database using SQL*Plus as SYSDBA and run the rollback script as follows:

    cd $ORACLE_HOME/rdbms/admin
    sqlplus /nolog
    SQL> CONNECT / AS SYSDBA
    SQL> STARTUP
    SQL> @catbundle_PSU__ROLLBACK.sql
    SQL> QUIT
    In an Oracle RAC environment, the name of the rollback script will have the format catbundle_PSU__ROLLBACK.sql.

   step 3:If the OJVM PSU was applied for a previous GI PSU patch, you may see invalid Java classes after execution of the catbundle.sql script in the previous step. If this is the case, run utlrp.sql to re-validate these Java classes.

    cd $ORACLE_HOME/rdbms/admin
    sqlplus /nolog
    SQL> CONNECT / AS SYSDBA
    SQL> @utlrp.sql
   
   step 4:check

    $ opatch lsinventory
   
   
   回滚(OJVM 补丁)
   crsctl stop crs
   opatch rollback -id 26027154
   crsctl start crs
   opatch lsinventory
 
   回滚后注册:
   The following steps load modified SQL files into the database. For an Oracle RAC environment, perform these steps on only one node.

   step 1:Install the SQL portion of the patch by running the following command for a single instance environment.

   cd $ORACLE_HOME/sqlpatch/26027154
   sqlplus /nolog
   SQL> CONNECT / AS SYSDBA
   SQL> startup upgrade
   SQL> @postdeinstall.sql
   SQL> shutdown
   SQL> startup

   For an Oracle RAC environment, reload the packages on one of the nodes using the following commands. Make sure no other instance of the database is up on the remote nodes.
   注意:此步骤需要关闭rac上非跑脚本的其他实例

   cd $ORACLE_HOME/sqlpatch/26027154
   sqlplus /nolog
   SQL> CONNECT / AS SYSDBA
   SQL> STARTUP
   SQL> alter system set cluster_database=false scope=spfile;
   SQL> SHUTDOWN
   SQL> STARTUP UPGRADE
   SQL> @postdeinstall.sql
   SQL> alter system set cluster_database=true scope=spfile;
   SQL> SHUTDOWN
   SQL> STARTUP
   
   step 2:After installing the SQL portion of the patch, some packages could become INVALID. This will get recompiled upon access or you can run utlrp.sql to get them back into a VALID state.

   cd $ORACLE_HOME/rdbms/admin
   sqlplus /nolog
   SQL> CONNECT / AS SYSDBA
   SQL> @utlrp.sql


*****************************************************
*     七、主备库升级成功后启用备库,并查看同步情况  *
*****************************************************   
--主库日志应用成功后,修改主库参数及备库应用日志,同时检查同步情况:

先主库启用传输日志
alter system set log_archive_dest_state_2=enable;

备库启动,并应用日志
startup

recover managed standby database using current logfile;

最后检查同步情况:
 select process, sequence#, status, delay_mins from v$managed_standby;

========================================================================
*************************************************************
*                                GI PSU补丁升级示例操作步骤                                           *                       
*************************************************************

GI PSU补丁可以以滚动方式应用GI HOME和DB HOME。注意下载补丁的存放位置应该是GI和db共享的目录;

一、检查rac没法节点的opatch工具版本大于或等于11.2.0.3.6:

更新db和GI下的opatch工具:
$ unzip -d
$ /OPatch/opatch version

二、配置响应文件
su - oracle
$ORACLE_HOME/OPatch/ocm/bin/emocmrsp -no_banner -output /home/oracle/ocm.rsp
chmod 775 /home/oracle/ocm.rsp

三、验证有效期
-- Validation of Oracle Inventory(以GI和DB用户分别运行)
$ORACLE_HOME/OPatch/opatch lsinventory -detail -oh  $ORACLE_HOME

四、打补丁或回滚补丁前应停止EM进程(如果没有安装EM,则忽略)
su - oracle
/bin/emctl stop dbconsole

五、升级PSU(As root user, execute the following command on each node of the cluster:不能并行执行)
--As root user, execute the following command on each node of the cluster:
以root用户身份,在集群的每个节点上执行以下命令:

注意:PSU补丁的存放位置应该是GI和db共享的目录,并以GI下的opatch工具去执行

$ cd
$ unzip p27107360_112040_.zip
# opatch auto /27107360 -ocmrf

六、升级后数据库注册,跑脚本:对于rac只需在一个节点上操作即可
--执行脚本catbundle.sql
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle.sql psu apply
SQL> QUIT

The catbundle.sql execution is reflected in the dba_registry_history view by a row associated with bundle series PSU.

--编译失效对象
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> @utlrp.sql

--检查日志有无报错
catbundle_PSU__APPLY_.log
catbundle_PSU__GENERATE_.log

--如果在使用rman恢复目录,则执行如下:
$ rman catalog username/password@alias
RMAN> UPGRADE CATALOG;


七、回滚PSU:
--root身份执行:
As root user, execute the following command on each node of the cluster.

# opatch auto /27107360 -rollback -ocmrf

八、回滚后注册:在执行打补丁注册后的节点上执行回滚后注册
8.1 Start all database instances running from the Oracle home

8.2 执行脚本

cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle_PSU__ROLLBACK.sql
SQL> QUIT

8.3 编译失效对象

cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> @utlrp.sql

8.4 Check the log file for any errors.

The log file is found in $ORACLE_BASE/cfgtoollogs/catbundle and is named catbundle_PSU__ROLLBACK_.log where TIMESTAMP is of the form YYYYMMMDD_HH_MM_SS. If there are error.

8.5 检查

$ opatch lsinventory



本文标题:OJVM+GIPSU补丁升级
文章链接:http://chengdu.cdxwcx.cn/article/goiepj.html