Linux 7.7 平台 Oracle 19c Data Guard 环境 升级RU 19.3 到19.6 操作手册
在之前的博客我们学习了Oracle 19.3 版本的DG 搭建,以及19.3 到19.6 的RU升级,如下:
Linux 7.7 平台 Oracle 19.3 物理Data Guard 搭建手册
https://www.cndba.cn/dave/article/4067
Oracle 19c 单实例 RU 从19.3.0 升级到19.6.0 操作手册
https://www.cndba.cn/dave/article/4065
本篇博客我们学习下DG 环境下将RU 从19.3 升级到19.6 的步骤。
1 升级RU说明
根据19.6 Patch 的readme 文件,对于物理DG的升级, 先升级备库,再升级主库。 而在打Patch的过程,实例是需要关闭的,也就意味着有停机时间。 并且提供的参考文档:278641.1, 也确实是停机后操作的。
一般对于这种操作,我们需要考虑的是尽可能缩短停机时间。 对于Data Guard 环境,无法做到RAC 环境的滚动升级,所以必然存在一个停机窗口的问题。 一般对于大的升级,向Oracle 11g的大版本升级,执行脚本可能需要40分钟,这个停机窗口是偏长的。
所以对于11g 中的这种情况,我们可以按如下步骤进行:
1.升级备库
2.进行switchover 切换
3.原主库被备库
4.升级新备库。Oracle 18c Data Guard 切换保护模式 和 主备库角色操作手册
https://www.cndba.cn/dave/article/2996
但根据单实例升级19.6 RU的经验,这个时间不长,十来分钟就结束了,所以对于Oracle 19c DG 环境RU的升级,完全没有必要进行switchover 操作。
除了switchover切换需要业务侧的配合之外,还有另一个问题,就是12.2之后升级RU使用的datapatch 工具,该工具必须在实例读写状态下才能进行工作。 而备库是只读的,所以无法执行datapatch工具。
因此,在19c 的Data Guard 环境,我们RU的升级可以直接按照Patch readme中的步骤进行,如下:
1.停备库
2.升级备库(RU)
3.启动备库
4.停主库
5.升级主库(RU+datapatch+utlrp)
6.启动主库
这样,Data Guard 环境的RU 升级就变成了2个单实例的RU升级,升级步骤和之前差不多了。 只需要注意备库只需要升级RU,不需要执行datapatch工具。 修改的SQL 会从主库同步到备库中。
2具体操作
2.1 搭建19.3 的Data Guard 环境
这里之前参考之前的博客。 本文不再描述。
Linux 7.7 平台 Oracle 19.3 物理Data Guard 搭建手册
https://www.cndba.cn/dave/article/4067
检查主库:
[oracle@www.cndba.cn1 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 10 22:16:03 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select DEST_NAME,STATUS,ERROR from v$archive_dest where DEST_ID=2;
DEST_NAME STATUS ERROR
------------------------------ --------------------------- -----------------------------------------------------------------
LOG_ARCHIVE_DEST_2 VALID
SQL> select process,status,sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
--------------------------- ------------------------------------ ----------
DGRD ALLOCATED 0
ARCH CLOSING 19
DGRD ALLOCATED 0
ARCH CLOSING 19
ARCH CLOSING 15
ARCH CLOSING 18
DGRD ALLOCATED 0
LGWR WRITING 20
8 rows selected.
SQL>
检查备库:
SQL> select process,status,sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
--------------------------- ------------------------------------ ----------
DGRD ALLOCATED 0
ARCH CONNECTED 0
DGRD ALLOCATED 0
ARCH CLOSING 19
ARCH CONNECTED 0
ARCH CLOSING 18
RFS IDLE 0
RFS IDLE 0
RFS IDLE 20
RFS IDLE 0
MRP0 APPLYING_LOG 20
11 rows selected.
SQL>
2.2 升级备库RU (此时主库正常运行)
在升级之前还有一些辅助工作,比如下载Patch,检查OPatch版本,检查Patch是否冲突,这些我们之前在单实例里都测试过,所以这里直接升级RU。 如果有同学不清楚,可以参考之前单实例的19.6 的RU升级。
2.2.1关闭备库
关闭备库实例,监听,退出所有的sqlplus 窗口。 这点尤其重要,容易忽略。
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@www.cndba.cn2 ~]$
[oracle@www.cndba.cn2 ~]$ lsnrctl stop
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 10-MAR-2020 22:24:01
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg2)(PORT=1521)))
The command completed successfully
[oracle@www.cndba.cn2 ~]$
2.2.2升级RU
[oracle@www.cndba.cn2 ~]$ cd /u01/software/30557433/
[oracle@www.cndba.cn2 30557433]$ $ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.17
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.3.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.3.0/dbhome_1/oraInst.loc
OPatch version : 12.2.0.1.17
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3.0/dbhome_1/cfgtoollogs/opatch/opatch2020-03-10_22-25-09PM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 30557433
Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/19.3.0/dbhome_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '30557433' to OH '/u01/app/oracle/product/19.3.0/dbhome_1'
ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.xdk.parser.java.jaxb2, 19.0.0.0.0 ] , [ oracle.assistants.asm, 19.0.0.0.0 ] , [ oracle.tfa, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.oraolap.mgmt, 19.0.0.0.0 ] , [ oracle.assistants.usm, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.options.olap.awm, 19.0.0.0.0 ] , [ oracle.jdk, 1.8.0.191.0 ] not present in the Oracle Home or a higher version is found.
Patching component oracle.rdbms.rsf, 19.0.0.0.0...
Patching component oracle.rdbms.util, 19.0.0.0.0...
Patching component oracle.rdbms, 19.0.0.0.0...
……
Patching component oracle.precomp.common, 19.0.0.0.0...
Patching component oracle.jdk, 1.8.0.201.0...
Patch 30557433 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [30557433].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19.3.0/dbhome_1/cfgtoollogs/opatch/opatch2020-03-10_22-25-09PM_1.log
OPatch succeeded.
[oracle@www.cndba.cn2 30557433]$
2.2.3启动备库
按照正常的流程,升级RU 后还需要执行datapatch工具来将变化的SQL加到实例中,但因为备库是只读的,所以是无法执行datapatch工具的。 这里我们只需要将备库正常启动即可。 待主库升级完成之后,会自动将变化的数据,同步到备库。
关于这一点,在MOS文档中有验证:
Oracle Patch Assurance - Data Guard Standby-First Patch Apply (Doc ID 1265700.1)
Patches that require SQL installation in order to be fully installed (e.g. catbundle.sql or datapatch as part of PSU installation) must delay SQL installation until the primary database and all standby databases have the database home binaries patched to the same level。
The SQL installation step required by some patches requires a read-write database and is performed only on the primary database. Changes made to the primary database by SQL installation are replicated via the redo stream to physical standby databases.
注意这里同步的一个大前提,就是所有主备库的RU版本要支持。
[oracle@www.cndba.cn2 30557433]$ lsnrctl start
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 10-MAR-2020 22:29:38
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/dg2/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg2)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg2)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 10-MAR-2020 22:29:38
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/dg2/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg2)(PORT=1521)))
Services Summary...
Service "cndba" has 1 instance(s).
Instance "cndba", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@www.cndba.cn2 30557433]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 10 22:29:48 2020
Version 19.6.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1962932472 bytes
Fixed Size 9136376 bytes
Variable Size 1124073472 bytes
Database Buffers 822083584 bytes
Redo Buffers 7639040 bytes
Database mounted.
Database opened.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 DAVE READ ONLY NO
SQL>
SQL> alter database recover managed standby database disconnect;
Database altered.
2.3 升级主库RU
2.3.1关闭主库
关闭主库实例,监听,退出所有的sqlplus 窗口。 这点尤其重要,容易忽略。
[oracle@www.cndba.cn1 software]$ lsnrctl stop
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 10-MAR-2020 22:50:29
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg1)(PORT=1521)))
The command completed successfully
[oracle@www.cndba.cn1 software]$
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@www.cndba.cn1 dbs]$
2.3.2升级RU
[oracle@www.cndba.cn1 dbs]$ cd /u01/software/30557433/
[oracle@www.cndba.cn1 30557433]$ $ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.17
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.3.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.3.0/dbhome_1/oraInst.loc
OPatch version : 12.2.0.1.17
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3.0/dbhome_1/cfgtoollogs/opatch/opatch2020-03-10_22-52-24PM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 30557433
Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/19.3.0/dbhome_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '30557433' to OH '/u01/app/oracle/product/19.3.0/dbhome_1'
ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.xdk.parser.java.jaxb2, 19.0.0.0.0 ] , [ oracle.assistants.asm, 19.0.0.0.0 ] , [ oracle.tfa, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.oraolap.mgmt, 19.0.0.0.0 ] , [ oracle.assistants.usm, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.options.olap.awm, 19.0.0.0.0 ] , [ oracle.jdk, 1.8.0.191.0 ] not present in the Oracle Home or a higher version is found.
Patching component oracle.rdbms.rsf, 19.0.0.0.0...
……
Patching component oracle.precomp.common, 19.0.0.0.0...
Patching component oracle.jdk, 1.8.0.201.0...
Patch 30557433 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [30557433].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19.3.0/dbhome_1/cfgtoollogs/opatch/opatch2020-03-10_22-52-24PM_1.log
OPatch succeeded.
[oracle@www.cndba.cn1 30557433]$
2.3.3启动主库
[oracle@www.cndba.cn1 30557433]$ lsnrctl start
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 10-MAR-2020 22:55:50
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/dg1/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 10-MAR-2020 22:55:50
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/dg1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg1)(PORT=1521)))
Services Summary...
Service "cndba" has 1 instance(s).
Instance "cndba", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@www.cndba.cn1 30557433]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 10 22:56:09 2020
Version 19.6.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1962932472 bytes
Fixed Size 9136376 bytes
Variable Size 1107296256 bytes
Database Buffers 838860800 bytes
Redo Buffers 7639040 bytes
Database mounted.
Database opened.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 DAVE READ WRITE NO
SQL>
2.3.4执行Datapatch工具
安装补丁之后,还需要将有变化的SQL加载到数据库中,这里可以直接运行Datapatch工具将这些修改的SQL重新加载到数据库中,在DG 环境中,只需要在主库执行,备库不需要执行。
datapatch 工具在我的虚拟机上执行了12分钟(5G内存,2c),生产环境速度应该可以更快一些。
[oracle@www.cndba.cn1 30557433]$ $ORACLE_HOME/OPatch/datapatch -verbose
SQL Patching tool version 19.6.0.0.0 Production on Tue Mar 10 23:01:32 2020
Copyright (c) 2012, 2019, Oracle. All rights reserved.
Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_73760_2020_03_10_23_01_32/sqlpatch_invocation.log
Connecting to database...OK
Gathering database info...done
Note: Datapatch will only apply or rollback SQL fixes for PDBs
that are in an open state, no patches will be applied to closed PDBs.
Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
(Doc ID 1585822.1)
Bootstrapping registry and package to current versions...done
Determining current state...done
Current state of interim SQL patches:
No interim patches found
Current state of release update SQL patches:
Binary registry:
19.6.0.0.0 Release_Update 191217155004: Installed
PDB CDB$ROOT:
Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 10-MAR-20 04.52.10.836368 PM
PDB DAVE:
Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 10-MAR-20 04.59.12.154487 PM
PDB PDB$SEED:
Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 10-MAR-20 04.59.12.154487 PM
Adding patches to installation queue and performing prereq checks...done
Installation queue:
For the following PDBs: CDB$ROOT PDB$SEED DAVE
No interim patches need to be rolled back
Patch 30557433 (Database Release Update : 19.6.0.0.200114 (30557433)):
Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.6.0.0.0 Release_Update 191217155004
No interim patches need to be applied
Installing patches...
Patch installation complete. Total patches installed: 3
Validating logfiles...done
Patch 30557433 apply (pdb CDB$ROOT): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/30557433/23305305/30557433_apply_CNDBA_CDBROOT_2020Mar10_23_04_39.log (no errors)
Patch 30557433 apply (pdb PDB$SEED): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/30557433/23305305/30557433_apply_CNDBA_PDBSEED_2020Mar10_23_08_14.log (no errors)
Patch 30557433 apply (pdb DAVE): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/30557433/23305305/30557433_apply_CNDBA_DAVE_2020Mar10_23_08_14.log (no errors)
SQL Patching tool complete on Tue Mar 10 23:13:42 2020
[oracle@www.cndba.cn1 30557433]$
2.3.5处理无效对象
只需要在主库执行,备库不需要执行。
[oracle@www.cndba.cn1 admin]$ cd $ORACLE_HOME/rdbms/admin
[oracle@www.cndba.cn1 admin]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 10 23:15:21 2020
Version 19.6.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.6.0.0.0
SQL> @utlrp.sql
Session altered.
……
2.4 验证RU
主库:
col status for a10
col action for a10
col action_time for a30
col description for a60
col version for a25
col comments for a80
SQL> select patch_id,patch_type,action,status,action_time,description from dba_registry_sqlpatch;
PATCH_ID PATCH_TYPE ACTION STATUS ACTION_TIME
---------- ------------------------------ ---------- ---------- ------------------------------
DESCRIPTION
------------------------------------------------------------
29517242 RU APPLY SUCCESS 10-MAR-20 04.52.10.836368 PM
Database Release Update : 19.3.0.0.190416 (29517242)
30557433 RU APPLY SUCCESS 10-MAR-20 11.13.26.904142 PM
Database Release Update : 19.6.0.0.200114 (30557433)
SQL>
SQL> select ACTION_TIME,VERSION,COMMENTS from dba_registry_history;
ACTION_TIME VERSION COMMENTS
------------------------------ ------------------------- --------------------------------------------------------------------------------
19 RDBMS_19.6.0.0.0DBRU_LINUX.X64_191217
10-MAR-20 04.52.04.255690 PM 19.0.0.0.0 Patch applied on 19.3.0.0.0: Release_Update - 190410122720
10-MAR-20 11.07.50.763372 PM 19.0.0.0.0 Patch applied from 19.3.0.0.0 to 19.6.0.0.0: Release_Update - 191217155004
SQL>
备库:
SQL> select patch_id,patch_type,action,status,action_time,description from dba_registry_sqlpatch;
PATCH_ID PATCH_TYPE ACTION STATUS ACTION_TIME DESCRIPTION
---------- ------------------------------ ---------- ---------- ------------------------------ ------------------------------------------------------------
29517242 RU APPLY SUCCESS 10-MAR-20 04.52.10.836368 PM Database Release Update : 19.3.0.0.190416 (29517242)
30557433 RU APPLY SUCCESS 10-MAR-20 11.13.26.904142 PM Database Release Update : 19.6.0.0.200114 (30557433)
SQL> select ACTION_TIME,VERSION,COMMENTS from dba_registry_history;
ACTION_TIME VERSION COMMENTS
------------------------------ ------------------------- --------------------------------------------------------------------------------
19 RDBMS_19.6.0.0.0DBRU_LINUX.X64_191217
10-MAR-20 04.52.04.255690 PM 19.0.0.0.0 Patch applied on 19.3.0.0.0: Release_Update - 190410122720
10-MAR-20 11.07.50.763372 PM 19.0.0.0.0 Patch applied from 19.3.0.0.0 to 19.6.0.0.0: Release_Update - 191217155004
SQL>
2.5 验证DG 同步
主库:
SQL> alter system switch logfile;
System altered.
SQL> select sequence#,applied from v$archived_log order by 1 desc;
SEQUENCE# APPLIED
---------- ---------------------------
31 NO
31 NO
30 NO
30 YES
29 NO
29 YES
28 YES
28 NO
27 NO
27 YES
26 YES
备库:
SQL> select sequence#,applied from v$archived_log order by 1 desc;
SEQUENCE# APPLIED
---------- ---------------------------
31 IN-MEMORY
30 YES
29 YES
28 YES
27 YES
26 YES
25 YES
24 YES
23 YES
22 YES
21 YES
同步正常。
版权声明:本文为博主原创文章,未经博主允许不得转载。