Menu Close

Oracle 19c 单实例 RU 从19.3.0 升级到19.10.0

关于Oracle 19c 的RU和RUR的说明,请参考:https://www.cndba.cn/dave/article/4063

1. 当前环境

1.1. 操作系统

~]$ cat /etc/os-release

NAME="Oracle Linux Server"
VERSION="7.9"

1.2. 数据库版本

SQL>
SET LINES 300 PAGES 999
COL PRODUCT FOR A40
COL VERSION FOR A20
COL VERSION_FULL FOR A20
COL STATUS FOR A30

SELECT * FROM product_component_version;

PRODUCT                                   VERSION         VERSION_FULL         STATUS
---------------------------------------- -------------- ----------------- ----------------
Oracle Database 19c Enterprise Edition    19.0.0.0.0      19.3.0.0.0          Production

2. 安装补丁p32218454

由于升级的时间过于漫长(大约3~4小时),强烈建议在VNC中完成以下操作

2.1. 从MOS上下载补丁

下载地址:https://support.oracle.com/epmos/faces/PatchSearchResults?_adf.ctrl-state=6ar51xzdp_4&_afrLoop=975901772498635

2.2. 检查OPatch工具版本

要安装补丁 p32218454 ,OPatch 工具的版本需要 12.2.0.1.23 。 在Oracle 19.3的版本中,OPatch版本是 12.2.0.1.17,所以需要更新OPatch。

cd $ORACLE_HOME/OPatch/
./opatch version

OPatch Version: 12.2.0.1.17

OPatch succeeded.

2.3. 更新OPatch

具体可参考:How To Download And Install The Latest OPatch(6880880) Version (Doc ID 274526.1)
https://updates.oracle.com/download/6880880.html
我们下载到OPatch 12.2.0.1.24,文件名为: p6880880_180000_Linux-x86-64.zip

unzip p6880880_180000_Linux-x86-64.zip -d $ORACLE_HOME
  replace /u01/app/oracle/product/19.3.0/db_1/OPatch/emdpatch.pl? [y]es, [n]o, [A]ll, [N]one, [r]ename: 输入:A  # 覆盖文件

$ORACLE_HOME/OPatch/opatch version

OPatch Version: 12.2.0.1.24

OPatch succeeded.

2.4. 验证 Oracle Inventory

在开始打补丁之前,检查 GI home 和每个要打补丁的数据库home的库存信息的一致性。 以各自的 Oracle 主目录所有者身份运行以下命令以检查一致性。

$ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME

Oracle Interim Patch Installer version 12.2.0.1.24
Copyright (c) 2021, Oracle Corporation.  All rights reserved.

Oracle Home       : /u01/app/oracle/product/19.3.0/db_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19.3.0/db_1/oraInst.loc
OPatch version    : 12.2.0.1.24
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3.0/db_1/cfgtoollogs/opatch/opatch2021-09-23_21-55-49PM_1.log

Lsinventory Output file location : /u01/app/oracle/product/19.3.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2021-09-23_21-55-49PM.txt
--------------------------------------------------------------------------------
Local Machine Information::
Hostname: internalntp.lzu.edu.cn
ARU platform id: 226
ARU platform description:: Linux x86-64

Installed Top-level Products (1):

Oracle Database 19c                                                  19.0.0.0.0
There are 1 products installed in this Oracle Home.

Installed Products (128):

2.5. 检查Patch 是否冲突

 cd /home/oracle/software/
unzip p32218454_190000_Linux-x86-64_19.10.zip
cd 32218454/
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./

Oracle Interim Patch Installer version 12.2.0.1.17
Copyright (c) 2021, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/oracle/product/19.3.0/db_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19.3.0/db_1/oraInst.loc
OPatch version    : 12.2.0.1.24
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3.0/db_1/cfgtoollogs/opatch/opatch2021-09-23_20-36-48PM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.

2.6. 停止数据库

这里有几点注意事项:

  1. 如果是物理DG,那么主备库都需要安装Patch,可以先在备库安装,再安装主库,操作步骤可以参考:Document 278641.1。
  2. 对于RAC 环境,可以使用OPatch rolling 方式来安装,这样没有停机时间,具体操作可以参考:Document 244241.1。
  3. 对于单实例,必须关闭待升级ORACLE HOME关联的所有实例和监听,并且包括退出所有的sqlplus窗口。

关闭实例和监听,并退出sqlplus

lsnrctl stop
sqlplus / as sysdba
SQL> shutdown immediate;
SQL> exit;

2.7. 应用patch

整个过程大约需要 30 分钟。

pwd
  /home/oracle/software/32218454

$ORACLE_HOME/OPatch/opatch apply

Oracle Interim Patch Installer version 12.2.0.1.24
Copyright (c) 2021, Oracle Corporation.  All rights reserved.

Oracle Home       : /u01/app/oracle/product/19.3.0/db_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19.3.0/db_1/oraInst.loc
OPatch version    : 12.2.0.1.24
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3.0/db_1/cfgtoollogs/opatch/opatch2021-09-23_22-04-52PM_1.log

Verifying environment and performing prerequisite checks...
OPatch continues with these patches:   32218454

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/db_1')

Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '32218454' to OH '/u01/app/oracle/product/19.3.0/db_1'
ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.rdbms.tg4db2, 19.0.0.0.0 ] , [ oracle.tfa, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.oid.client, 19.0.0.0.0 ] , [ oracle.options.olap.api, 19.0.0.0.0 ] , [ oracle.options.olap, 19.0.0.0.0 ] , [ oracle.xdk.companion, 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, 19.0.0.0.0...

Patching component oracle.rdbms.rsf, 19.0.0.0.0...

Patching component oracle.rdbms.util, 19.0.0.0.0...

Patching component oracle.assistants.acf, 19.0.0.0.0...

Patching component oracle.assistants.deconfig, 19.0.0.0.0...

Patching component oracle.assistants.server, 19.0.0.0.0...

Patching component oracle.buildtools.rsf, 19.0.0.0.0...

Patching component oracle.ctx, 19.0.0.0.0...

Patching component oracle.dbjava.ic, 19.0.0.0.0...

Patching component oracle.dbjava.jdbc, 19.0.0.0.0...

Patching component oracle.dbjava.ucp, 19.0.0.0.0...

Patching component oracle.dbtoolslistener, 19.0.0.0.0...

Patching component oracle.ldap.owm, 19.0.0.0.0...

Patching component oracle.ldap.rsf, 19.0.0.0.0...

Patching component oracle.network.rsf, 19.0.0.0.0...

Patching component oracle.oracore.rsf, 19.0.0.0.0...

Patching component oracle.rdbms.dbscripts, 19.0.0.0.0...

Patching component oracle.rdbms.deconfig, 19.0.0.0.0...

Patching component oracle.sdo, 19.0.0.0.0...

Patching component oracle.sdo.locator.jrf, 19.0.0.0.0...

Patching component oracle.sqlplus, 19.0.0.0.0...

Patching component oracle.xdk, 19.0.0.0.0...

Patching component oracle.marvel, 19.0.0.0.0...

Patching component oracle.xdk.rsf, 19.0.0.0.0...

Patching component oracle.ctx.atg, 19.0.0.0.0...

Patching component oracle.rdbms.scheduler, 19.0.0.0.0...

Patching component oracle.rdbms.lbac, 19.0.0.0.0...

Patching component oracle.duma, 19.0.0.0.0...

Patching component oracle.ldap.rsf.ic, 19.0.0.0.0...

Patching component oracle.odbc, 19.0.0.0.0...

Patching component oracle.ctx.rsf, 19.0.0.0.0...

Patching component oracle.oraolap.api, 19.0.0.0.0...

Patching component oracle.xdk.parser.java, 19.0.0.0.0...

Patching component oracle.oraolap, 19.0.0.0.0...

Patching component oracle.sdo.locator, 19.0.0.0.0...

Patching component oracle.sqlplus.ic, 19.0.0.0.0...

Patching component oracle.mgw.common, 19.0.0.0.0...

Patching component oracle.ons, 19.0.0.0.0...

Patching component oracle.dbdev, 19.0.0.0.0...

Patching component oracle.network.listener, 19.0.0.0.0...

Patching component oracle.nlsrtl.rsf, 19.0.0.0.0...

Patching component oracle.ovm, 19.0.0.0.0...

Patching component oracle.oraolap.dbscripts, 19.0.0.0.0...

Patching component oracle.xdk.xquery, 19.0.0.0.0...

Patching component oracle.precomp.rsf, 19.0.0.0.0...

Patching component oracle.javavm.client, 19.0.0.0.0...

Patching component oracle.precomp.common.core, 19.0.0.0.0...

Patching component oracle.ldap.security.osdt, 19.0.0.0.0...

Patching component oracle.rdbms.oci, 19.0.0.0.0...

Patching component oracle.rdbms.rman, 19.0.0.0.0...

Patching component oracle.rdbms.crs, 19.0.0.0.0...

Patching component oracle.rdbms.install.common, 19.0.0.0.0...

Patching component oracle.javavm.server, 19.0.0.0.0...

Patching component oracle.rdbms.drdaas, 19.0.0.0.0...

Patching component oracle.rdbms.install.plugins, 19.0.0.0.0...

Patching component oracle.rdbms.dv, 19.0.0.0.0...

Patching component oracle.ldap.client, 19.0.0.0.0...

Patching component oracle.network.client, 19.0.0.0.0...

Patching component oracle.rdbms.rsf.ic, 19.0.0.0.0...

Patching component oracle.precomp.common, 19.0.0.0.0...

Patching component oracle.precomp.lang, 19.0.0.0.0...

Patching component oracle.jdk, 1.8.0.201.0...
Patch 32218454 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [32218454].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19.3.0/db_1/cfgtoollogs/opatch/opatch2021-09-23_22-04-52PM_1.log

OPatch succeeded.

2.8. 加载变化的SQL到数据库

OPatchAuto 自动调用 datapatch 完成安装数据库的二进制补丁并自动开始 post patch 的操作。
安装前仔细阅读 README.html, 以下过程从 22:36:40 到 00:38:32 总共持续了 2 个小时。
安装补丁之后,还需要将有变化的SQL加载到数据库中,这里可以直接运行Datapatch工具将这些修改的SQL重新加载到数据库中,如果是RAC环境,只需要在一个节点执行就可以了。
根据readme的说明,操作步骤如下:

sqlplus /nolog
SQL> Connect / as sysdba
SQL> startup
SQL> alter pluggable database all open;
SQL> quit
cd $ORACLE_HOME/OPatch
./datapatch -verbose

SQL Patching tool version 19.10.0.0.0 Production on Thu Sep 23 22:36:40 2021
Copyright (c) 2012, 2020, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_12580_2021_09_23_22_36_41/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.10.0.0.0 Release_Update 210108185017: Installed
  PDB CATPDB:
    Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 20-SEP-21 06.31.48.813994 PM
  PDB CDB$ROOT:
    Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 20-SEP-21 05.49.42.337503 PM
  PDB EMCCDB:
    Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 20-SEP-21 06.31.48.813994 PM
  PDB PDB$SEED:
    Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 20-SEP-21 06.31.48.813994 PM

Adding patches to installation queue and performing prereq checks...done
Installation queue:
  For the following PDBs: CDB$ROOT EMCCDB
    No interim patches need to be rolled back
    Patch 32218454 (Database Release Update : 19.10.0.0.210119 (32218454)):
      Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.10.0.0.0 Release_Update 210108185017
    No interim patches need to be applied
  For the following PDBs: PDB$SEED CATPDB
    No interim patches need to be rolled back
    Patch 32218454 (Database Release Update : 19.10.0.0.210119 (32218454)):
      Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.10.0.0.0 Release_Update 210108185017
    No interim patches need to be applied

Installing patches...

Patch installation complete.  Total patches installed: 4

Validating logfiles...done
Patch 32218454 apply (pdb CDB$ROOT): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/32218454/24018797/32218454_apply_CATALOGD_CDBROOT_2021Sep23_22_40_56.log (no errors)
Patch 32218454 apply (pdb EMCCDB): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/32218454/24018797/32218454_apply_CATALOGD_EMCCDB_2021Sep23_23_23_45.log (no errors)
Patch 32218454 apply (pdb PDB$SEED): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/32218454/24018797/32218454_apply_CATALOGD_PDBSEED_2021Sep24_00_06_13.log (no errors)
Patch 32218454 apply (pdb CATPDB): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/32218454/24018797/32218454_apply_CATALOGD_CATPDB_2021Sep24_00_06_13.log (no errors)
SQL Patching tool complete on Fri Sep 24 00:38:32 2021

datapatch 命令只对打开的数据库生效,所有Oracle建议在执行该命令之前将CDB和所有的PDB都打开,一次更新掉。 但如果有部分PDB没有打开,也可以在打开之后,重新运行 datapatch 命令并制定pdb实例名,比如: ./datapatch -pdbs catpdb

检查 $ORACLE_HOME/sqlpatch/32218454/ 中的以下日志文件是否有错误

32218454_apply_<database SID>_<CDB name>_<timestamp>.log
# 其中,database SID是数据库 SID,CDBname 是多租户容器数据库的名称,时间戳是 YYYYMMMDD_HH_MM_SS 形式。

处理无效对象
任何在执行datapatch后有无效对象的数据库都应该运行utlrp.sql来重新验证这些对象。 例如:

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

2.9. Upgrade Oracle Recovery Manager Catalog

如果您使用的是 Oracle Recovery Manager,则需要升级目录。 输入以下命令进行升级。 UPGRADE CATALOG 命令必须输入两次以确认升级。

rman catalog '"rco/Hz571!xy00yz@172.16.36.168/catpdb"'

RMAN> UPGRADE CATALOG;
RMAN> UPGRADE CATALOG;
RMAN> EXIT;

至此,整个数据库补丁安装完成,再次查看数据库版本:

参考:安装包中的 README.html