opatch on-line patch and standby-fisrt patch

opatch on-line patch and standby-fisrt patch


on-line patch 有缺陷,不建议使用,standby-fisrt patch 可以考虑使用

#######sample 1
Oracle Patch Assurance - Data Guard Standby-First Patch Apply (文档 ID 1265700.1)

step 1.Perform Patch Binary Installation on Standby Only , (11.2.0.4.0 apply the patch 14368995) 
step 2.Evaluate Patch on Standby Database 
step 3.Data Guard Switchover and Apply Patch to New Physical Standby (11.2.0.4.0 apply the patch 14368995 ) 

so step 1 and step3 intervals can have maximum 31 day

#########standby DG Standby First Patch 安装

实际操作中碰到一个补丁  Bug 22241601 要求同时 停下所有的主库和备库,再 进行安装,而且必须先patching 安装备库,最后在patching 安装主库。

官方解释如下:个人理解,DG first 补丁只要是修复DG功能模块的,所以要先安装DG 部分,在安装主库,防止主库的同步会影响到DG

0.Oracle Data Guard Standby First Patch
Oracle Database - Enterprise Edition - Version 11.2.0.1 and later

1.
Data Guard长期支持在主系统和备用系统之间运行不同的配置。 Data Guard完全独立于数据库下的任何内容,因此您可以跨不同站点运行不同版本的操作系统,Oracle Clusterware,硬件或存储软件,而不受版本或时间的限制。 这包括对以下内容的支持:

硬件差异(例如X3 Exadata数据库云服务器和X4 Exadata数据库云服务器)
操作系统的差异(例如Oracle Linux 5.7与Oracle Linux 5.8)
数据库存储的差异(例如,基于Oracle ASM的存储与基于NFS的存储,或Exadata 11.2与Exadata 12.1)
Oracle Clusterware版本和补丁级别的差异(例如11.2.0.3 GIPSU4和11.2.0.3 GIPSU5)

2.
Oracle Data Guard Standby First Patch Apply为主数据库与其物理备用数据库之间的不同数据库主软件提供支持,以滚动方式应用和验证Oracle补丁和补丁包,对主数据库的风险最小。例如,对于data guard standby first补丁应用,首先将数据库主补丁应用到物理备用数据库。
备用服务器用于运行只读工作负载,或者读写工作负载(如果它是快照备用服务器),用于测试和评估补丁程序。通过评估后,补丁将安装在主系统上,从而更好地保证数据库主补丁的有效性和稳定性。


3.
Steps to Perform Data Guard Standby-First Patch Apply
To accomplish Data Guard Standby-First Patch Apply, do the following:

阶段1 - Perform Patch Binary Installation on Standby Only
阶段2 - Evaluate Patch on Standby Database
阶段3 - Complete Patch Installation or Rollback
Option 1: Apply Patch to Primary Database
Option 2: Data Guard Switchover, Apply Patch to New Standby
Option 3: Rollback Patch on Standby System.
NOTE :If Primary and Standby are RAC then follow RAC Patching methods

OPatch supports 3 different patch methods on a RAC environment:

Patching RAC as a single instance (All-Node Patch)
Patching RAC using a minimum down-time strategy (Min. Downtime Patch)
Patching RAC using a rolling strategy - No down time (Rolling Patch)


####
阶段1
1.1.Shutdown all standby instances on the standby database using the following commands (if Patch is not RAC Rolling):

Data Guard configuration managed by SQL*Plus or Data Guard broker:
SQL> shutdown immediate

1.2.Perform binary installation of the patch on the standby according to the patch README.
此时不要为修补程序执行SQL安装(例如,不要运行catbundle.sql或datapatch)。 在主数据库和所有备用数据库将其数据库主目录二进制文件修补到阶段3中的相同级别之后执行SQL安装。

以滚动Data Guard备用优先方式将Oracle Database Proactive Bundle Patch 12.1.0.2.170418安装到数据库软件主目录时,必须在12.1.0.2.170418之上安装补丁26112084。 有关详细信息,请参见文档2267842.1。

1.3.Restart the standby instances after the patch has been applied to all standby database ORACLE_HOME, as follows:

If Active Data Guard is used, then start all standby instances using the following command:

Data Guard configuration managed by SQL*Plus or the Data Guard broker:
SQL> startup

If Active Data Guard is not used, then mount all standby instances using the following command:

Data Guard configuration managed by SQL*Plus or the Data Guard broker:
SQL> startup mount
Restart the media recovery using the following command:

Data Guard configuration managed by SQL*Plus:
SQL> alter database recover managed standby database using current logfile disconnect;

Data Guard configuration managed by Data Guard broker:
The Data Guard broker will automatically restart the media recovery.

###########
第2阶段: 评估备用数据库上的修补程序
Oracle 建议的最佳做法和最全面的评估方法是以以下方式使用快照待机和 Oracle 实际应用程序测试:


可通过以下方式进行不太全面的评价:

如果使用 "活动数据保护" 选项, 请在只读模式下打开备用数据库, 并通过运行只读工作负载来强调备用数据库。
将备用数据库保持在装载状态的托管恢复模式, 并监视备用警报日志和跟踪文件中的任何问题。
复制到剪贴板


###############

阶段3:完成补丁安装或回滚
此时补丁仅应用于备用系统二进制文件; 因此,它只是部分安装。 环境可能保持混合版本状态最多31天。 要完成修补程序安装,必须在主系统上完成二进制安装,并且必须执行SQL安装(如果需要修补程序)。

一共有3个选项:

-》 阶段3选项1
中的主要步骤是将修补程序应用于主数据库,其中包括在主数据库主目录中执行二进制安装,以及对主数据库执行SQL安装。 SQL安装期间对主数据库所做的更改将通过重做传播到备用数据库。 选项1要求停机或完全停止主数据库,具体取决于补丁选择和支持的安装方法。


If the patch is not RAC Rolling Installable, then restart standby database recovery with the standby in mounted mode. Patches that are listed as RAC Rolling Installable in the patch README can be applied on the primary with the standby performing recovery in read only mode. However, patches that are not RAC Rolling Installable must stop read only recovery on the standby, bring the standby database to the mount state, and restart recovery prior to applying the patch to the primary database. For example, run the following command on the standby instance that performs media recovery:

但是,非RAC Rolling Installable的修补程序必须停止备用数据库上的只读恢复,将备用数据库置于装入状态,并在将修补程序应用于主数据库之前重新启动恢复。

3.1.1重启standby 到mount 状态,并开启mrp 服务
Data Guard configuration managed by SQL*Plus:
SQL> shutdown immediate
SQL> startup mount
SQL> alter database recover managed standby database using current logfile disconnect;


3.1.2.根据readme 在主库进行安装
Perform binary installation of the patch to the database home on the primary according to the patch README.

3.1.3.这个时候才可以开启SQL安装,只有在修补了主数据库和所有备用数据库以使用相同的软件之后,才能执行此步骤。
If required, perform SQL installation of the patch according to the patch README. This step may be performed only after the primary and all standby databases have been patched to use the same software.

3.1.4.如果是ADG ,可以开启ADG 模式,可选If using Active Data Guard, then restart into Active Data Guard mode:

Data Guard configuration managed by SQL*Plus:
SQL> alter database recover managed standby database cancel;
SQL> alter database open;
SQL> alter database recover managed standby database using current logfile disconnect;


-》 阶段3选项2

选项2中的主要步骤是执行Data Guard切换,在新的备用数据库主目录中执行二进制安装,以及对新的主数据库执行SQL安装。 在Data Guard切换期间,选项2对主数据库有短暂影响,但在完成补丁安装时对主数据库没有影响。


*注意:对于切换选项2,需要在切换到备用数据库(原始主数据库)之后立即开始修补,然后在主数据库上运行后续的Sql。

3.2.1
执行以下步骤,执行Data Guard切换,完成补丁安装:
按照“Data Guard概念和管理指南”中的说明执行Data Guard切换。
由SQL * Plus管理的Data Guard配置:

主数据库:
SQL> alter database commit to switchover to physical standby with session shutdown;
Standby Database:


Standby Database:
SQL> alter database commit to switchover to primary with session shutdown;
SQL> alter database open;

New Standby Database (Old Primary Database):
SQL> shutdown immediate
SQL> startup mount
SQL> alter database recover managed standby database using current logfile disconnect;


3.2.2但是,非RAC Rolling Installable的修补程序必须停止备用数据库上的只读恢复,将备用数据库置于装入状态,并在将修补程序应用于主数据库之前重新启动恢复。

Data Guard configuration managed by SQL*Plus:
SQL> shutdown immediate
SQL> startup mount
SQL> alter database recover managed standby database using current logfile disconnect;

3.2.3
根据补丁自述文件,在备用系统上对补丁进行二进制安装。

3.2.4
如果需要,请根据补丁自述文件在主数据库上执行补丁的SQL安装。 只有在修补了主数据库和所有备用数据库以使用相同的软件之后,才能执行此步骤。


3.2.5.如果是ADG ,可以开启ADG 模式,可选If using Active Data Guard, then restart into Active Data Guard mode:

Data Guard configuration managed by SQL*Plus:
SQL> alter database recover managed standby database cancel;
SQL> alter database open;
SQL> alter database recover managed standby database using current logfile disconnect;


#######sample 2

on-line patch 有缺陷,不建议使用

注意:
- 如果无法安排停机时间,并且需要紧急应用补丁,则建议使用在线补丁。

- 在线补丁消耗额外的内存,如果永久保留,内存消耗会随着系统中进程数量的增加而增加。

- 强烈建议回滚所有在线修补程序,并在下一个实例关闭或最早的维护时段使用常规(脱机)修补程序替换它们。

###sample 3  Rolling Patch (号称没有downtime)

OPatch supports 3 different patch methods on a RAC environment:

Patching RAC as a single instance (All-Node Patch)
Patching RAC using a minimum down-time strategy (Min. Downtime Patch)
Patching RAC using a rolling strategy - No down time (Rolling Patch)

原文地址:https://www.cnblogs.com/feiyun8616/p/10563009.html