Bootstrap

openEuler操作系统下Oracle 19c 从19.3补丁更新到19.17

Oracle 19c 从补丁19.3更新到19.17的过程涉及到多个步骤,包括备份、下载补丁、替换OPatch、验证清单信息、冲突检测、空间检测、应用补丁等。以下是一个概括性的流程,但请注意,具体步骤可能会根据实际的Oracle环境、补丁内容和Oracle的官方指导文档有所不同。

一、准备工作

  1. 备份当前环境

    • 在开始更新之前,务必备份当前的Oracle环境和相关配置文件,以便在出现问题时能够恢复。
    • 停止Oracle服务和监听程序,并备份$ORACLE_HOME目录。
  2. 下载补丁

    • 从Oracle官方网站或支持渠道下载所需的补丁文件,包括Oracle Grid Infrastructure (GI) 和Database (DB) 的补丁。
    • 补丁文件名可能类似于p34449117_190000_Linux-x86-64.zip,其中包含了特定版本的更新。
  3. 下载并替换OPatch

    • OPatch是Oracle用于应用补丁的工具,需要确保使用的是与Oracle版本兼容的OPatch版本。
    • 下载最新的OPatch版本,并替换现有版本的OPatch。
  4. 停止监听和数据库

lsnrctl stop

[oracle@openEuler u01]$ sqlplus / as sysdba

SYS@orcl> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

二、验证和准备

  1. 验证Oracle清单信息

    • 使用OPatch工具检查当前已安装的补丁和Oracle环境的信息。
    • 执行类似opatch lsinventory的命令来列出所有已安装的补丁。
  2. 冲突检测

    • 在应用新补丁之前,检查新补丁是否与当前安装的补丁存在冲突。
    • 使用OPatch的冲突检查功能来执行此操作。
  3. 空间检测

    • 确保系统上有足够的空间来应用新补丁。
    • 使用OPatch的空间检查功能来验证。

三、应用补丁

  1. 解压补丁

    • 将下载的补丁文件解压到适当的目录。
  2. 应用补丁

    • 使用OPatch的apply命令来应用补丁。
    • 根据提示执行必要的操作,如关闭正在运行的Oracle实例等。
  3. 验证补丁应用

    • 应用补丁后,使用OPatch的lsinventory命令来验证补丁是否已成功应用。

四、后续步骤

  1. 启动Oracle服务

    • 在确认补丁应用无误后,重新启动Oracle服务和监听程序。
  2. 测试和验证

    • 对更新后的Oracle环境进行彻底的测试和验证,以确保一切功能正常。

五、注意事项

  • 在整个过程中,请确保遵循Oracle的官方文档和指导原则。
  • 如果遇到任何问题,请及时联系Oracle的技术支持团队。
  • 请注意,Oracle的补丁策略可能会随着时间的推移而发生变化,因此请务必查阅最新的Oracle官方文档以获取最准确的信息。

六、参考示例

以下是一个简化的示例,展示了如何应用一个名为p34449117_190000_Linux-x86-64.zip的补丁:

  1. 下载并解压补丁

    cd /u01
    unzip p6880880_122010_Linux-x86-64.zip
    unzip p34449117_190000_Linux-x86-64.zip
    -- 替换OPatch
    mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch_Bak
    mv OPatch $ORACLE_HOME/OPatch
    
  2. 检查冲突

    $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/34449117/34416665/34419443
    
  3. 应用补丁

    [oracle@openEuler u01]$ $ORACLE_HOME/OPatch/opatch apply /u01/34449117/34416665/34419443
    

在这里插入图片描述
4. 验证补丁

$ORACLE_HOME/OPatch/opatch lsinvertory

$ORACLE_HOME/OPatch/opatch lsinv
  1. 启动数据库
[oracle@openEuler u01]$ sqlplus /nolog

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jul 21 00:32:42 2024
Version 19.17.0.0.0

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

@> conn sys as sysdba
Enter password: 
Connected to an idle instance.
SYS@orcl> startup
ORACLE instance started.

Total System Global Area 1728050048 bytes
Fixed Size                  8897408 bytes
Variable Size             520093696 bytes
Database Buffers         1191182336 bytes
Redo Buffers                7876608 bytes
Database mounted.
Database opened.
SYS@orcl> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.17.0.0.0
  1. 运行datapatch工具 datapatch -verbose
  • 安装补丁之后,还需要将有变化的SQL加载到数据库中,这里可以直接运行Datapatch工具将这些修改的SQL重新加载到数据库中
  • 如果是RAC集群环境,只需要在一个节点执行就可以了
[oracle@openEuler u01]$ $ORACLE_HOME/OPatch/datapatch -verbose
SQL Patching tool version 19.17.0.0.0 Production on Sun Jul 21 00:33:55 2024
Copyright (c) 2012, 2022, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_58222_2024_07_21_00_33_55/sqlpatch_invocation.log

Connecting to database...OK
Gathering database info...done
Bootstrapping registry and package to current versions...done
Determining current state...done

Current state of interim SQL patches:
Interim patch 34411846 (OJVM RELEASE UPDATE: 19.17.0.0.221018 (34411846)):
  Binary registry: Installed
  SQL registry: Applied successfully on 20-JUL-24 11.15.52.871563 PM

Current state of release update SQL patches:
  Binary registry:
    19.17.0.0.0 Release_Update 220924224051: Installed
  SQL registry:
    Applied 19.7.0.0.0 Release_Update 200404035018 successfully on 21-JUL-24 12.11.41.183647 AM

Adding patches to installation queue and performing prereq checks...done
Installation queue:
  No interim patches need to be rolled back
  Patch 34419443 (Database Release Update : 19.17.0.0.221018 (34419443)):
    Apply from 19.7.0.0.0 Release_Update 200404035018 to 19.17.0.0.0 Release_Update 220924224051
  No interim patches need to be applied

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

Validating logfiles...done
Patch 34419443 apply: SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/34419443/24972075/34419443_apply_ORCL_2024Jul21_00_34_32.log (no errors)
SQL Patching tool complete on Sun Jul 21 00:39:46 2024
  1. 编译处理无效对象
    For example:
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SYS@orcl> CONNECT / AS SYSDBA
SYS@orcl> @utlrp.sql

或者

  • @?/rdbms/admin/utlrp.sql
[oracle@openEuler u01]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jul 21 00:40:35 2024
Version 19.17.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.17.0.0.0

SYS@orcl> @?/rdbms/admin/utlrp.sql

Session altered.


TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN              2024-07-21 00:40:39

DOC>   The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC>   objects in the database. Recompilation time is proportional to the
DOC>   number of invalid objects in the database, so this command may take
DOC>   a long time to execute on a database with a large number of invalid
DOC>   objects.
DOC>
DOC>   Use the following queries to track recompilation progress:
DOC>
DOC>   1. Query returning the number of invalid objects remaining. This
DOC>      number should decrease with time.
DOC>         SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC>   2. Query returning the number of objects compiled so far. This number
DOC>      should increase with time.
DOC>         SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC>   This script automatically chooses serial or parallel recompilation
DOC>   based on the number of CPUs available (parameter cpu_count) multiplied
DOC>   by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC>   On RAC, this number is added across all RAC nodes.
DOC>
DOC>   UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC>   recompilation. Jobs are created without instance affinity so that they
DOC>   can migrate across RAC nodes. Use the following queries to verify
DOC>   whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC>   1. Query showing jobs created by UTL_RECOMP
DOC>         SELECT job_name FROM dba_scheduler_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC>   2. Query showing UTL_RECOMP jobs that are running
DOC>         SELECT job_name FROM dba_scheduler_running_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#

PL/SQL procedure successfully completed.


TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END              2024-07-21 00:40:40

DOC> The following query reports the number of invalid objects.
DOC>
DOC> If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#

OBJECTS WITH ERRORS
-------------------
                  1

DOC> The following query reports the number of exceptions caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC> Note: Typical compilation errors (due to coding errors) are not
DOC>       logged into this table: they go into DBA_ERRORS instead.
DOC>#

ERRORS DURING RECOMPILATION
---------------------------
                          0


Function created.


PL/SQL procedure successfully completed.


Function dropped.


PL/SQL procedure successfully completed.
  1. 查看版本变化
SYS@orcl> select banner_full from v$version;

BANNER_FULL
--------------------------------------------------------------------------------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.17.0.0.0


SYS@orcl> select open_mode,name from v$database;

OPEN_MODE            NAME
-------------------- ---------
READ WRITE           ORCL

SYS@orcl> 
SYS@orcl> set linesize 300
SYS@orcl> col status for a10
SYS@orcl> col action for a10
SYS@orcl> col action_time for a30
SYS@orcl> col description for a60
SYS@orcl> 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    18-JUN-24 02.58.24.451519 PM   Database Release Update : 19.3.0.0.190416 (29517242)
  34411846 INTERIM    APPLY      SUCCESS    20-JUL-24 11.15.52.871563 PM   OJVM RELEASE UPDATE: 19.17.0.0.221018 (34411846)
  34419443 RU         APPLY      SUCCESS    21-JUL-24 12.39.45.639286 AM   Database Release Update : 19.17.0.0.221018 (34419443)

  1. Upgrade Oracle Recovery Manager Catalog
    If you are using the Oracle Recovery Manager, the catalog needs to be upgraded. Enter the following command to upgrade it. The UPGRADE CATALOG command must be entered twice to confirm the upgrade.
$ rman catalog username/password@orcl
RMAN> UPGRADE CATALOG;
RMAN> UPGRADE CATALOG;
RMAN> EXIT;
  1. OJVM 补丁更新操作步骤如下
-- 检查冲突
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/34449117/34411846/

-- 关闭数据库
sqlplus / as sysdba
shutdown immediate

-- 应用补丁
$ORACLE_HOME/OPatch/opatch apply -silent /u01/34449117/34411846/

-- 验证补丁
$ORACLE_HOME/OPatch/opatch lsinv

$ORACLE_HOME/OPatch/opatch lsinventory

-- 启动数据库及监听
sqlplus / as sysdba
startup

lsnrctl start

-- 直接运行Datapatch工具将这些修改的SQL重新加载到数据库
$ORACLE_HOME/OPatch/datapatch -verbose

请注意,上述示例中的命令和路径可能需要根据您的实际环境进行调整。

。。提示 。。

如果需要补丁包,请评论区留言。感谢点赞,转发!。。。

openEuler操作系统下Oracle 19c,可参考我的文档openEuler操作系统下静默安装Oracle19c,地址如下

https://blog.csdn.net/zxrhhm/article/details/139774799?spm=1001.2014.3001.5501

;