大家好,这里是公众号 Lucifer三思而后行,分享一些学习国产数据库路上的知识和经验。

前言

今天一早打开邮箱收到 Oracle 的邮件,开头内容如下:

October 15, 2024
Oracle Critical Patch Update for October 2024

Dear Oracle Customer,

Critical Patch Update October 2024 was released on October 15, 2024.

Oracle strongly recommends applying the patches as soon as possible.

原来是 Oracle 第四季度补丁发布了,Oracle 19C 补丁限时下载链接,明天删除!!!

仅开放 1 天下载,过期删除。

介绍

上班后,打开 MOS 查看了一下,果然更新了:

数据库版本补丁类型补丁版本补丁编号发布日期
Oracle 11GR2Grid**15-Oct-2024
Oracle 11GR2Database**15-Oct-2024
Oracle 11GR2OJVM11.2.0.4.241015 (Oct 2024) OJVM Component Patch Set UpdatePatch 3687878115-Oct-2024
Oracle 12CR2Grid12.2.0.1.241015 (Oct 2024) GI Release UpdatePatch 3694030515-Oct-2024
Oracle 12CR2Database12.2.0.1.241015 (Oct 2024) Database Release UpdatePatch 3694140015-Oct-2024
Oracle 12CR2OJVM12.2.0.1.241015 (Oct 2024) OJVM Release UpdatePatch 3687873715-Oct-2024
Oracle 19CGridDatabase Release Update 19.25.0Patch 3691259715-Oct-2024
Oracle 19CDatabaseGI Release Update 19.25.0Patch 3691669015-Oct-2024
Oracle 19COJVMOJVM Release Update 19.25.0Patch 3687869715-Oct-2024

老样子,11GR2 没有更新 Grid 和 DB 的补丁,其他版本补丁均正常发布。

这里顺带分享一下几个 MOS 补丁的下载链接:

有 MOS 账号的小伙伴可以直接点击链接进行下载了。

19.25 RU 补丁安装

环境信息:

角色IP地址数据库版本CDB名PDB名
源端192.168.6.13619.3orclcdbtestpdb

本文数据库环境均使用 Oracle 一键安装脚本部署:

脚本下载:Oracle一键安装脚本
作者微信:Lucifer-0622

环境准备

为了演示补丁安装,使用 Oracle 一键安装脚本快速安装一套 Oracle 19C 无补丁测试环境:

./OracleShellInstall -lf ens192 `# local ip ifname`\
-n rhel8 `# hostname`\
-op oracle `# oracle password`\
-d /u01 `# software base dir`\
-ord /oradata `# data dir`\
-o orclcdb `# dbname`\
-pdb testpdb `# pdbname`\
-dp oracle `# sys/system password`\
-ds AL32UTF8 `# database character`\
-ns AL16UTF16 `# national character`\
-redo 100 `# redo size`\
-opd Y `# optimize db`

一键安装过程如下:

   ███████                             ██          ████████ ██               ██  ██ ██                    ██              ██  ██
  ██░░░░░██                           ░██         ██░░░░░░ ░██              ░██ ░██░██                   ░██             ░██ ░██
 ██     ░░██ ██████  ██████    █████  ░██  █████ ░██       ░██       █████  ░██ ░██░██ ███████   ██████ ██████  ██████   ░██ ░██
░██      ░██░░██░░█ ░░░░░░██  ██░░░██ ░██ ██░░░██░█████████░██████  ██░░░██ ░██ ░██░██░░██░░░██ ██░░░░ ░░░██░  ░░░░░░██  ░██ ░██
░██      ░██ ░██ ░   ███████ ░██  ░░  ░██░███████░░░░░░░░██░██░░░██░███████ ░██ ░██░██ ░██  ░██░░█████   ░██    ███████  ░██ ░██
░░██     ██  ░██    ██░░░░██ ░██   ██ ░██░██░░░░        ░██░██  ░██░██░░░░  ░██ ░██░██ ░██  ░██ ░░░░░██  ░██   ██░░░░██  ░██ ░██
 ░░███████  ░███   ░░████████░░█████  ███░░██████ ████████ ░██  ░██░░██████ ███ ███░██ ███  ░██ ██████   ░░██ ░░████████ ███ ███
  ░░░░░░░   ░░░     ░░░░░░░░  ░░░░░  ░░░  ░░░░░░ ░░░░░░░░  ░░   ░░  ░░░░░░ ░░░ ░░░ ░░ ░░░   ░░ ░░░░░░     ░░   ░░░░░░░░ ░░░ ░░░ 


注意:本脚本仅用于新服务器上实施部署数据库使用,严禁在已运行数据库的主机上执行,以免发生数据丢失或者损坏,造成不可挽回的损失!!!                                                                                  

请选择安装模式 [单机(si)/单机ASM(sa)/集群(rac)] : si

数据库安装模式: single                                                                           

请选择数据库版本 [11|12|19|21|23] : 19

数据库版本:     19                                                                               

OracleShellInstall 开始安装,详细安装过程可查看日志: tail -2000f /soft/print_shell_install_20241016110850.log                                                                                  

正在进行安装前检查,请稍等......                                                                                  

正在检测安装包 /soft/LINUX.X64_193000_db_home.zip 的 MD5 值是否正确,请稍等......                                                                                  

正在配置本地软件源......已完成 (耗时: 0)
正在获取操作系统信息......已完成 (耗时: 2)
正在安装依赖包......已完成 (耗时: 130)
正在禁用防火墙......已完成 (耗时: 1)
正在禁用 selinux......已完成 (耗时: 1)
正在配置 nsyctl......已完成 (耗时: 0)
正在配置主机名和 hosts 文件......已完成 (耗时: 0)
正在创建用户和组......已完成 (耗时: 1)
正在创建安装目录......已完成 (耗时: 0)
正在配置透明大页 && NUMA && 磁盘 IO 调度器......已完成 (耗时: 4)
正在配置操作系统参数 sysctl......已完成 (耗时: 1)
正在配置 RemoveIPC......已完成 (耗时: 1)
正在配置用户限制 limit......已完成 (耗时: 1)
正在配置 shm 目录......已完成 (耗时: 1)
正在安装 rlwrap 插件......已完成 (耗时: 11)
正在配置用户环境变量......已完成 (耗时: 1)
正在解压 Oracle 安装包以及补丁......已完成 (耗时: 84)
正在安装 Oracle 软件以及补丁......已完成 (耗时: 152)
正在创建监听......已完成 (耗时: 3)
正在创建数据库......已完成 (耗时: 1260)
正在优化数据库......已完成 (耗时: 37)

恭喜!Oracle 一键安装执行完成 (耗时: 1699),现在是否重启主机:[Y/N] Y

正在重启当前节点主机......

安装好的环境为 19C 无补丁数据库版本:

[oracle@rhel8:/home/oracle]$ sqlplus -v

SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

[oracle@rhel8:/home/oracle]$ opatch lspatches
29585399;OCW RELEASE UPDATE 19.3.0.0.0 (29585399)
29517242;Database Release Update : 19.3.0.0.190416 (29517242)

OPatch succeeded.

下面演示一下 Oracle 19C RU 19.25 补丁的安装步骤。

README

首先需要查看补丁的 README 文件(解压补丁后即可获得),其中补丁的前置要求如下:

  • You must use the OPatch utility version 12.2.0.1.43 or later to apply this patch.
  • If you are using a Data Guard Physical Standby database, you must install this patch on both the primary database and the physical standby database.
  • If this is an Oracle RAC environment, install this patch using the OPatch rolling (no downtime) installation method as this patch is rolling RAC installable.
  • If this is not a RAC environment, shut down all instances and listeners associated with the Oracle home that you are updating.

翻译一下就是:

  • OPatch 版本大于 12.2.0.1.43
  • 有 DG 的环境,DG 也要打补丁
  • RAC 环境可以滚动升级
  • 单机环境需要关闭所有 oracle 相关的服务

升级 OPatch

查看当前数据库的 Opatch 版本:

[oracle@rhel8:/home/oracle]$ opatch version
OPatch Version: 12.2.0.1.17

OPatch succeeded.

opatch 版本低于 43,需要下载最新的 OPatch 补丁替换,在 Patch 6880880 下载对应版本的补丁:

下载后上传到数据库主机,解压替换即可(这一步不需要停机,可以在线操作):

## 这里我上传到 /soft 目录,所以需要对目录进行授权
[root@rhel8:/root]# chown -R oracle:oinstall /soft/

## oracle 用户静默解压 opatch 到 ORACLE_HOME 目录下
[oracle@rhel8:/home/oracle]$ cd /soft/
[oracle@rhel8:/soft]$ unzip -qo p6880880_190000_Linux-x86-64.zip -d $ORACLE_HOME

## 查看替换后的 OPatch 版本
[oracle@rhel8:/soft]$ opatch version
OPatch Version: 12.2.0.1.44

OPatch succeeded.

升级完 OPatch 版本之后,需要进行安装前补丁冲突检查。

冲突检查

首先需要上传 RU 补丁并解压:

## 这里我上传到 /soft 目录,所以需要对目录进行授权
[root@rhel8:/root]# chown -R oracle:oinstall /soft/

## oracle 用户静默解压 RU 补丁包
[oracle@rhel8:/soft]$ unzip -q p36912597_190000_Linux-x86-64.zip 
[oracle@rhel8:/soft]$ cd 36912597/

## 检查冲突,一般是没有问题的
[oracle@rhel8:/soft/36912597]$ opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.2.0.1.44
Copyright (c) 2024, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/oracle/product/19.3.0/db
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19.3.0/db/oraInst.loc
OPatch version    : 12.2.0.1.44
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3.0/db/cfgtoollogs/opatch/opatch2024-10-16_11-40-47AM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.

到这都没问题的话,就可以协商停机时间进行补丁升级了。

补丁升级

前置工作都做完之后,补丁升级步骤其实很简单,RAC 滚动升级也可以使用这种方式:

## 关闭数据库
[oracle@rhel8:/soft/36912597]$ sas

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Oct 16 11:41:14 2024
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

SYS@orclcdb SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@orclcdb SQL> 

## 关闭监听
[oracle@rhel8:/soft/36912597]$ lsnrctl stop

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 16-OCT-2024 11:42:13

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rhel8)(PORT=1521)))
The command completed successfully

## 静默安装补丁(确保没有 oracle 相关进程之后就可以安装补丁)
[oracle@rhel8:/soft/36912597]$ opatch apply -silent
Oracle Interim Patch Installer version 12.2.0.1.44
Copyright (c) 2024, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/19.3.0/db
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19.3.0/db/oraInst.loc
OPatch version    : 12.2.0.1.44
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3.0/db/cfgtoollogs/opatch/opatch2024-10-16_11-44-04AM_1.log

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

Do you want to proceed? [y|n]
Y (auto-answered by -silent)
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')


Is the local system ready for patching? [y|n]
Y (auto-answered by -silent)
User Responded with: Y
Backing up files...
Applying interim patch '36912597' to OH '/u01/app/oracle/product/19.3.0/db'
ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.crypto.rsf, 19.0.0.0.0 ] , [ oracle.pg4appc, 19.0.0.0.0 ] , [ oracle.pg4mq, 19.0.0.0.0 ] , [ oracle.precomp.companion, 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.sdo.companion, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.oid.client, 19.0.0.0.0 ] , [ oracle.xdk.companion, 19.0.0.0.0 ] , [ oracle.options.olap.api, 19.0.0.0.0 ] , [ oracle.ons.eons.bwcompat, 19.0.0.0.0 ] , [ oracle.rdbms.tg4msql, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.rdbms.tg4tera, 19.0.0.0.0 ] , [ oracle.rdbms.tg4ifmx, 19.0.0.0.0 ] , [ oracle.rdbms.tg4sybs, 19.0.0.0.0 ] , [ oracle.ldap.ztk, 19.0.0.0.0 ] , [ oracle.ons.cclient, 19.0.0.0.0 ] , [ oracle.options.olap, 19.0.0.0.0 ] , [ oracle.jdk, 1.8.0.191.0 ] , [ oracle.jdk, 1.8.0.391.11 ]  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.util, 19.0.0.0.0...

Patching component oracle.rdbms.rsf, 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.blaslapack, 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.dbdev, 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.duma, 19.0.0.0.0...

Patching component oracle.javavm.client, 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.ldap.security.osdt, 19.0.0.0.0...

Patching component oracle.marvel, 19.0.0.0.0...

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

Patching component oracle.odbc.ic, 19.0.0.0.0...

Patching component oracle.ons, 19.0.0.0.0...

Patching component oracle.ons.ic, 19.0.0.0.0...

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

Patching component oracle.perlint, 5.28.1.0.0...

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

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

Patching component oracle.rdbms.crs, 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.rdbms.oci, 19.0.0.0.0...

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

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

Patching component oracle.rhp.db, 19.0.0.0.0...

Patching component oracle.rsf, 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.sqlplus.ic, 19.0.0.0.0...

Patching component oracle.wwg.plsql, 19.0.0.0.0...

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

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

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

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

Patching component oracle.ovm, 19.0.0.0.0...

Patching component oracle.oraolap, 19.0.0.0.0...

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

Patching component oracle.rdbms.rat, 19.0.0.0.0...

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

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

Patching component oracle.xdk, 19.0.0.0.0...

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

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

Patching component oracle.install.deinstalltool, 19.0.0.0.0...

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

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

Patching component oracle.dbtoolslistener, 19.0.0.0.0...

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

Patching component oracle.rdbms.hs_common, 19.0.0.0.0...

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

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

Patching component oracle.rdbms.dm, 19.0.0.0.0...

Patching component oracle.ldap.ssl, 19.0.0.0.0...

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

Patching component oracle.odbc, 19.0.0.0.0...

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

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

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

Patching component oracle.rdbms.hsodbc, 19.0.0.0.0...

Patching component oracle.network.aso, 19.0.0.0.0...

Patching component oracle.rdbms.locator, 19.0.0.0.0...

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

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

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

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

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

Patching component oracle.network.client, 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 36912597 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [36912597].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19.3.0/db/cfgtoollogs/opatch/opatch2024-10-16_11-44-04AM_1.log

OPatch succeeded.

19.25 RU 补丁安装比较慢,要耐心等待,这里安装完最后还有一个提示(这个是正常的提示,可以忽略):

Sub-set patch [29517242] has become inactive due to the application of a super-set patch [36912597].
Please refer to Doc ID 2161861.1 for any possible further required actions.

这个 29517242 补丁就是我们安装好 19C 数据库之后默认安装的补丁版本:

29517242;Database Release Update : 19.3.0.0.190416 (29517242)

通过查看相关文档可以发现:

For information about Release Updates please read Note:2285040.1 .
The new RUs will be a superset of a previous RU patches.

## Note:2285040.1 About list
It is possible to move back and forth from Updates to Revisions*. However, there are some restrictions as the new patch level must be a super set of the previous. To avoid surprises with patch conflicts, customers should aim to stick to a consistent policy of always taking the same Revision level (i.e. Release.Update.0, Release.Update.1 or Release.Update.2) for their quarterly maintenance cycles.

软件补丁安装完成后,对数据库也要执行 datapatch,需要先打开数据库:

[oracle@rhel8:/soft/36912597]$ sas

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Oct 16 12:11:41 2024
Version 19.25.0.0.0

Copyright (c) 1982, 2024, Oracle.  All rights reserved.

Connected to an idle instance.

## 打开数据库
SYS@orclcdb SQL> startup
ORACLE instance started.

Total System Global Area 5318374376 bytes
Fixed Size                  9192424 bytes
Variable Size             922746880 bytes
Database Buffers         4378853376 bytes
Redo Buffers                7581696 bytes
Database mounted.
Database opened.

SYS@orclcdb SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TESTPDB                        READ WRITE NO

## 这里是 CDB 架构,所以需要打开 PDB(如果配置了 PDB 随 CDB 自启,则跳过这一步,安装脚本默认配置了)
SQL> alter pluggable database all open;

SYS@orclcdb SQL> exit;
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.25.0.0.0

执行 datapatch:

## 这一步是可选的,执行后会运行一系列环境和数据库检查,确保 datapatch 能够安装成功
[oracle@rhel8:/home/oracle]$ datapatch -sanity_checks

## 执行 datapatch
[oracle@rhel8:/home/oracle]$ datapatch -verbose
SQL Patching tool version 19.25.0.0.0 Production on Wed Oct 16 12:15:01 2024
Copyright (c) 2012, 2024, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_7263_2024_10_16_12_15_01/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.25.0.0.0 Release_Update 241010184253: Installed
  PDB CDB$ROOT:
    Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 16-OCT-24 11.22.47.880070 AM
  PDB PDB$SEED:
    Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 16-OCT-24 11.31.48.661607 AM
  PDB TESTPDB:
    Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 16-OCT-24 11.31.48.661607 AM

Adding patches to installation queue and performing prereq checks...done
Installation queue:
  For the following PDBs: CDB$ROOT PDB$SEED TESTPDB
    No interim patches need to be rolled back
    Patch 36912597 (Database Release Update : 19.25.0.0.241015 (36912597)):
      Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.25.0.0.0 Release_Update 241010184253
    No interim patches need to be applied

Installing patches...
Patch installation complete.  Total patches installed: 3

Validating logfiles...done
Patch 36912597 apply (pdb CDB$ROOT): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/36912597/25871884/36912597_apply_ORCLCDB_CDBROOT_2024Oct16_12_17_39.log (no errors)
Patch 36912597 apply (pdb PDB$SEED): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/36912597/25871884/36912597_apply_ORCLCDB_PDBSEED_2024Oct16_12_29_25.log (no errors)
Patch 36912597 apply (pdb TESTPDB): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/36912597/25871884/36912597_apply_ORCLCDB_TESTPDB_2024Oct16_12_29_25.log (no errors)

Automatic recompilation incomplete; run utlrp.sql to revalidate.
  PDBs: PDB$SEED TESTPDB

SQL Patching tool complete on Wed Oct 16 12:38:40 2024

查看补丁版本:

[oracle@rhel8:/home/oracle]$ sqlplus -v

SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.25.0.0.0

[oracle@rhel8:/home/oracle]$ opatch lspatches
36912597;Database Release Update : 19.25.0.0.241015 (36912597)
29585399;OCW RELEASE UPDATE 19.3.0.0.0 (29585399)

OPatch succeeded.

至此,数据库 19.25 补丁安装完成。

一键安装补丁

如果你是新安装一套数据库,需要安装最新补丁 19.25,使用 Oracle 一键安装脚本可以轻松完成。

脚本下载:Oracle一键安装脚本
作者微信:Lucifer-0622

《❓关于Oracle一键安装脚本的 21 个疑问与解答》

Oracle 一键安装脚本实操合集,持续更新中!!!

这里演示一下 19C 一键安装,同时安装 DB 和 OJVM 补丁的命令:

# 提前上传好安装包和安装脚本即可
[root@KeyarchOS soft]# ll
-rwx------ 1 root root 3059705302 1016 10:35 LINUX.X64_193000_db_home.zip
-rwxr-xr-x 1 root root     243175 1016 10:33 OracleShellInstall
-rwxr-xr-x 1 root root  127601834 1016 10:29 p36878697_190000_Linux-x86-64.zip
-rwxr-xr-x 1 root root 1776391552 1016 10:28 p36912597_190000_Linux-x86-64.zip
-rwxr-xr-x 1 root root  134583311 1016 10:27 p6880880_190000_Linux-x86-64.zip

# 执行一键安装命令
./OracleShellInstall -lf ens33 `# local ip ifname`\
-n KeyarchOS `# hostname`\
-op oracle `# oracle password`\
-d /u01 `# software base dir`\
-ord /oradata `# data dir`\
-o orclcdb `# dbname`\
-pdb lucifer `# pdbname`\
-dp oracle `# sys/system password`\
-ds AL32UTF8 `# database character`\
-ns AL16UTF16 `# national character`\
-redo 100 `# redo size`\
-opa 36912597 `# oracle PSU/RU`\
-jpa 36878697 `# OJVM PSU/RU`\
-opd Y `# optimize db`

安装过程如下:

   ███████                             ██          ████████ ██               ██  ██ ██                    ██              ██  ██
  ██░░░░░██                           ░██         ██░░░░░░ ░██              ░██ ░██░██                   ░██             ░██ ░██
 ██     ░░██ ██████  ██████    █████  ░██  █████ ░██       ░██       █████  ░██ ░██░██ ███████   ██████ ██████  ██████   ░██ ░██
░██      ░██░░██░░█ ░░░░░░██  ██░░░██ ░██ ██░░░██░█████████░██████  ██░░░██ ░██ ░██░██░░██░░░██ ██░░░░ ░░░██░  ░░░░░░██  ░██ ░██
░██      ░██ ░██ ░   ███████ ░██  ░░  ░██░███████░░░░░░░░██░██░░░██░███████ ░██ ░██░██ ░██  ░██░░█████   ░██    ███████  ░██ ░██
░░██     ██  ░██    ██░░░░██ ░██   ██ ░██░██░░░░        ░██░██  ░██░██░░░░  ░██ ░██░██ ░██  ░██ ░░░░░██  ░██   ██░░░░██  ░██ ░██
 ░░███████  ░███   ░░████████░░█████  ███░░██████ ████████ ░██  ░██░░██████ ███ ███░██ ███  ░██ ██████   ░░██ ░░████████ ███ ███
  ░░░░░░░   ░░░     ░░░░░░░░  ░░░░░  ░░░  ░░░░░░ ░░░░░░░░  ░░   ░░  ░░░░░░ ░░░ ░░░ ░░ ░░░   ░░ ░░░░░░     ░░   ░░░░░░░░ ░░░ ░░░ 


注意:本脚本仅用于新服务器上实施部署数据库使用,严禁在已运行数据库的主机上执行,以免发生数据丢失或者损坏,造成不可挽回的损失!!!                                                                                  

请选择安装模式 [单机(si)/单机ASM(sa)/集群(rac)] : si

数据库安装模式: single                                                                           

请选择数据库版本 [11|12|19|21|23] : 19

数据库版本:     19                                                                               

!!! 免责声明:当前操作系统版本是 [ kos 5.8sp2 ] 不在 Oracle 官方支持列表,本脚本只负责安装,请确认是否继续安装 (Y/N): [Y] 

OracleShellInstall 开始安装,详细安装过程可查看日志: tail -2000f /soft/print_shell_install_20241016103558.log                                                                                  

正在进行安装前检查,请稍等......                                                                                  

正在检测安装包 /soft/LINUX.X64_193000_db_home.zip 的 MD5 值是否正确,请稍等......                                                                                  

正在配置本地软件源......已完成 (耗时: 1)
正在获取操作系统信息......已完成 (耗时: 1)
正在安装依赖包......已完成 (耗时: 95)
正在禁用防火墙......已完成 (耗时: 1)
正在禁用 selinux......已完成 (耗时: 1)
正在配置 nsyctl......已完成 (耗时: 1)
正在配置主机名和 hosts 文件......已完成 (耗时: 0)
正在创建用户和组......已完成 (耗时: 2)
正在创建安装目录......已完成 (耗时: 0)
正在配置 Avahi-daemon 服务......已完成 (耗时: 1)
正在配置透明大页 && NUMA && 磁盘 IO 调度器......已完成 (耗时: 2)
正在配置操作系统参数 sysctl......已完成 (耗时: 1)
正在配置 RemoveIPC......已完成 (耗时: 1)
正在配置用户限制 limit......已完成 (耗时: 1)
正在配置 shm 目录......已完成 (耗时: 0)
正在安装 rlwrap 插件......已完成 (耗时: 11)
正在配置用户环境变量......已完成 (耗时: 1)
正在解压 Oracle 安装包以及补丁......已完成 (耗时: 172)
正在安装 Oracle 软件以及补丁......已完成 (耗时: 1591)
正在创建监听......已完成 (耗时: 5)
正在创建数据库......已完成 (耗时: 2792)
正在优化数据库......已完成 (耗时: 36)

恭喜!Oracle 一键安装执行完成 (耗时: 4722),现在是否重启主机:[Y/N] Y

正在重启当前节点主机...... 

打补丁 + CDB 架构安装还是比较慢的,查看安装后的版本信息:

[oracle@KeyarchOS:/home/oracle]$ sqlplus -v

SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.25.0.0.0

[oracle@KeyarchOS:/home/oracle]$ opatch lspatches
36878697;OJVM RELEASE UPDATE: 19.25.0.0.241015 (36878697)
36912597;Database Release Update : 19.25.0.0.241015 (36912597)
29585399;OCW RELEASE UPDATE 19.3.0.0.0 (29585399)

OPatch succeeded.

可以看到数据库补丁以及 OJVM 补丁均已成功安装,数据库内部也可以查看补丁安装记录:

set line2222 pages1000 tab off
col comments for a80
col version for a30
col action for a20
SELECT con_id,
       comments,
       version,
       action,
       action_time
  FROM cdb_registry_history
 ORDER BY con_id;

    CON_ID COMMENTS                                                                         VERSION                        ACTION               ACTION_TIME
---------- -------------------------------------------------------------------------------- ------------------------------ -------------------- ---------------------------------------------------------------------------
         1 RDBMS_19.25.0.0.0DBRU_LINUX.X64_241010                                           19                             BOOTSTRAP
         1 Patch applied from 19.3.0.0.0 to 19.25.0.0.0: Release_Update - 241010184253      19.0.0.0.0                     RU_APPLY             16-OCT-24 11.30.41.374179 AM
         1 OJVM RU post-install                                                             19.25.0.0.241015OJVMRU         APPLY                16-OCT-24 11.15.56.916741 AM
         1 RAN jvmpsu.sql                                                                   19.25.0.0.241015OJVMRU         jvmpsu.sql           16-OCT-24 11.15.56.806485 AM
         3 RDBMS_19.25.0.0.0DBRU_LINUX.X64_241010                                           19                             BOOTSTRAP
         3 Patch applied from 19.3.0.0.0 to 19.25.0.0.0: Release_Update - 241010184253      19.0.0.0.0                     RU_APPLY             16-OCT-24 11.48.46.775597 AM
         3 OJVM RU post-install                                                             19.25.0.0.241015OJVMRU         APPLY                16-OCT-24 11.38.03.969056 AM
         3 RAN jvmpsu.sql                                                                   19.25.0.0.241015OJVMRU         jvmpsu.sql           16-OCT-24 11.38.03.943917 AM

至此,Oracle 一键安装演示结束。

写在最后

Oracle 数据库补丁安装其实并不难,官方提供的 README 已经一目了然,如果大家都可以耐心好好读一读,相信一定会受益匪浅。

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐