19C已经发布3年多了,生产环境中也使用的越来越多。随着等保要求的进一步提高,DB的补丁升级也成了很多DBA平时工作的一部分。
从12.2.0.2开始,Oracle Database开始采用RU(Release Update)和RUR(Release Update Revision)的方式发布补丁。关于RU和RUR,网上也有很多博主做了详细说明,今天的重点也不是这一块。下面列出了官方的链接说明,有兴趣的同学可以自行前往查阅
https://support.oracle.com/knowledge/Oracle%20Database%20Products/19202110_9.html
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=177576139684538&id=2289879.1&_adf.ctrl-state=10zxif4dm7_55
节点名 | 操作系统 | 数据库版本 |
---|---|---|
db1 | rhel7.6 | 19.3 |
db2 | rhel7.6 | 19.3 |
RU版本
p32895426_190000_Linux-x86-64.zip
p32876380_190000_Linux-x86-64.zip
下载地址
MOS ID 2118136.2
p32876380_190000_Linux-x86-64.zip --OJVM
p32895426_190000_Linux-x86-64.zip --GI
p6880880_190000_Linux-x86-64.zip --Opatch
grid用户解压RU和更新Opatch,2个节点都需要执行下面步骤
[grid@db1:/soft]$ unzip p32895426_190000_Linux-x86-64.zip[grid@db1:/u01/app/19.3.0/grid]$ opatch version
OPatch Version: 12.2.0.1.17
OPatch succeeded.[root@db1:/u01/app/19.3.0/grid]$ mv OPatch/ OPatch_old
[root@db1:/soft]$ unzip p6880880_190000_Linux-x86-64.zip -d /u01/app/19.3.0/grid/
[root@db1:/u01/app/19.3.0/grid]$ chown -R grid:oinstall OPatch
[root@db1:/u01/app/19.3.0/grid]$ ll -d OPatch*
drwxr-x--- 15 grid oinstall 4096 Jul 30 22:36 OPatch
drwxr-x--- 14 grid oinstall 4096 Jan 18 10:45 OPatch_old[root@db1:/u01/app/oracle/product/19.3.0/db]$ mv OPatch/ OPatch_old
[root@db1:/soft]$ unzip p6880880_190000_Linux-x86-64.zip -d /u01/app/oracle/product/19.3.0/db/
[root@db1:/u01/app/oracle/product/19.3.0/db]$ chown -R oracle:oinstall OPatch
[root@db1:/u01/app/oracle/product/19.3.0/db]$ ll -d OPatch*
drwxr-x--- 15 oracle oinstall 4096 Jul 30 22:36 OPatch
drwxr-x--- 14 oracle oinstall 4096 Jan 18 11:22 OPatch_old[grid@db1:/home/grid]$ opatch version
OPatch Version: 12.2.0.1.27
OPatch succeeded.[oracle@db1:/home/oracle]$ opatch version
OPatch Version: 12.2.0.1.27
OPatch succeeded.
🔉 注意:UNZIPPED_PATCH_LOCATION目录应具有ORA_INSTALL
组的读取权限;更新Opatch时注意目录权限;RU32895426需要12.2.0.1.25
或更高版本的Opatch
在所有节点校验是否存在与32895426冲突的补丁
[grid@db1:/home/grid]$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/32895426/32904851/
[grid@db1:/home/grid]$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/32895426/32916816/
[grid@db1:/home/grid]$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/32895426/32915586/
[grid@db1:/home/grid]$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/32895426/32918050/
[oracle@db1:/home/oracle]$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/32895426/32904851/
[oracle@db1:/home/oracle]$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/32895426/32916816/
补丁应用顺序:节点1GI ⏩节点2GI⏩节点1DB⏩节点2DB
[root@db1:/soft]$ /u01/app/19.3.0/grid/OPatch/opatchauto apply -oh /u01/app/19.3.0/grid/ /soft/32895426/
[root@db2:/soft]$ /u01/app/19.3.0/grid/OPatch/opatchauto apply -oh /u01/app/19.3.0/grid/ /soft/32895426/
[root@db1:/soft]$ /u01/app/oracle/product/19.3.0/db/OPatch/opatchauto apply -oh /u01/app/oracle/product/19.3.0/db/ /soft/32895426/
先看一下节点1和节点2的oui-patch.xml
文件权限
[root@db1:/u01/app/oraInventory/ContentsXML]$ ls -l oui-patch.xml
-rw-rw---- 1 grid oinstall 174 Jan 20 11:01 oui-patch.xml
[root@db2:/u01/app/oraInventory/ContentsXML]$ ls -l oui-patch.xml
-rw-r--r-- 1 grid oinstall 174 Jan 19 22:37 oui-patch.xml
🐱这里Eason先不做调整,将错就错,看看坑到底有多深
[root@db2:/root]$ /u01/app/oracle/product/19.3.0/db/OPatch/opatchauto apply -oh /u01/app/oracle/product/19.3.0/db/ /soft/32895426/
报错信息:apply failed: java.io.IOException: oracle.sysman.oui.patch.PatchException: java.io.FileNotFoundException: /u01/app/oraInventory/ContentsXML/oui-patch.xml (Permission denied)
[root@db2:/u01/app/oraInventory/ContentsXML]$ ll oui-patch.xml*
-rw-r--r-- 1 grid oinstall 174 Jan 19 22:37 oui-patch.xml
-rw-r--r-- 1 oracle oinstall 174 Jan 19 22:37 oui-patch.xml.back#按照节点1的权限修改oui-patch.xml,重新applyauto resume
[root@db2:/u01/app/oraInventory/ContentsXML]$ chmod 664 oui-patch.xml
[root@db2:/u01/app/oraInventory/ContentsXML]$ ll oui-patch.xml*
-rw-rw-r-- 1 grid oinstall 174 Jan 19 22:37 oui-patch.xml
-rw-r--r-- 1 oracle oinstall 174 Jan 19 22:37 oui-patch.xml.back
[root@db2:/u01/app/oraInventory/ContentsXML]$ /u01/app/oracle/product/19.3.0/db/OPatch/opatchauto resume
💣又出错了。不要慌,继续按照提示修复错误:ORACLE_HOME/inventory/oneoffs/32904851 is corrupted. PatchObject constructor: Input file “/u01/app/oracle/product/19.3.0/db/inventory/oneoffs/32904851/etc/config/actions” or “/u01/app/oracle/product/19.3.0/db/inventory/oneoffs/32904851/etc/config/inventory” does not exist.
[root@db2:/u01/app/oracle/product/19.3.0/db/inventory/oneoffs]$ ll
total 0
drwxr-x--- 4 oracle oinstall 29 Jan 18 11:23 29517242
drwxr-x--- 4 oracle oinstall 29 Jan 18 11:24 29585399
💊 缺少对应的文件包,怎么办?从1号节点拷贝
[oracle@db1:/u01/app/oracle/product/19.3.0/db/inventory/oneoffs]$ scp -r 329* oracle@db2:/u01/app/oracle/product/19.3.0/db/inventory/oneoffs/
inventory.xml 100% 647KB 43.2MB/s 00:00
actions.xml 100% 5981KB 47.6MB/s 00:00
inventory.xml 100% 139KB 7.0MB/s 00:00
actions.xml 100% 98KB 17.1MB/s 00:00 [root@db2:/u01/app/oracle/product/19.3.0/db/inventory/oneoffs]$ ll
total 0
drwxr-x--- 4 oracle oinstall 29 Jan 18 11:23 29517242
drwxr-x--- 4 oracle oinstall 29 Jan 18 11:24 29585399
drwxr-xr-x 4 oracle oinstall 29 Jan 20 16:12 32904851
drwxr-xr-x 4 oracle oinstall 29 Jan 20 16:12 32916816
继续应用补丁
[root@db2:/u01/app/oracle/product/19.3.0/db/inventory/oneoffs]$ /u01/app/oracle/product/19.3.0/db/OPatch/opatchauto resume
如果在应用补丁过程中一直resume不成,你也可以opatchaotu rollback RU,修改好oui-patch.xml文件权限后重新opatchauto apply
RAC环境只需要在一个节点运行。non-cdb的库直接在数据库中运行即可;cdb的数据库需要将所有PDB open后运行。
[oracle@db1:/home/oracle]$ cd /u01/app/oracle/product/19.3.0/db/OPatch
[oracle@db1:/u01/app/oracle/product/19.3.0/db/OPatch]$ ./datapatch -verbose
[oracle@db1:/home/oracle]$ cd /u01/app/oracle/product/19.3.0/db/rdbms/admin/
[oracle@db1:/u01/app/oracle/product/19.3.0/db/rdbms/admin]$ sqlplus / as sysdbaSQL*Plus: Release 19.0.0.0.0 - Production on Fri Jan 21 15:47:01 2022
Version 19.12.0.0.0Copyright (c) 1982, 2021, Oracle. All rights reserved.Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.12.0.0.0sys@ORCL 15:47:01> @utlrp.sql
sys@ORCL 15:47:26> alter session set container=pdborcl;Session altered.Elapsed: 00:00:00.00
sys@ORCL 15:54:38> @utlrp.sql
OJVM补丁更新与前面的GI和DB的步骤大致相同,这里不做过多说明,具体查阅RU中的README.html,
#1节点
[oracle@db1:/soft]$ srvctl stop instance -d orcl -n db1
[oracle@db1:/soft]$ srvctl stop listener -node db1
[oracle@db1:/soft]$ cd 32876380/
[oracle@db1:/soft/32876380]$ opatch apply
[oracle@db1:/soft/32876380]$ srvctl start listener -node db1
[oracle@db1:/soft/32876380]$ srvctl start instance -d orcl -n db1
#2节点
[oracle@db2:/soft]$ srvctl stop instance -d orcl -n db2
[oracle@db2:/soft]$ srvctl stop listener -node db2
[oracle@db2:/soft]$ cd 32876380/
[oracle@db2:/soft/32876380]$ opatch apply
[oracle@db2:/soft/32876380]$ srvctl start listener -node db2
[oracle@db2:/soft/32876380]$ srvctl start instance -d orcl -n db2
#安装后应用脚本
[oracle@db1:/soft/32876380]$ sqlplus / as sysdba
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.12.0.0.0
sys@ORCL 17:35:10> alter system set cluster_database=false scope=spfile;
System altered.
Elapsed: 00:00:00.40
sys@ORCL 17:35:20> exit[oracle@db1:/soft/32876380]$ srvctl stop database -d orcl
[oracle@db1:/soft/32876380]$ sqlplus / as sysdba
sConnected to an idle instance.
idle 21-JAN-22>startup
ORACLE instance started.
Total System Global Area 2449472392 bytes
Fixed Size 9141128 bytes
Variable Size 1644167168 bytes
Database Buffers 788529152 bytes
Redo Buffers 7634944 bytes
Database mounted.
Database opened.
idle 21-JAN-22> show pdbsCON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------2 PDB$SEED READ ONLY NO3 PDBORCL READ WRITE NO
idle 21-JAN-22> exit
[oracle@db1:/soft/32876380]$ cd /u01/app/oracle/product/19.3.0/db/OPatch
[oracle@db1:/u01/app/oracle/product/19.3.0/db/OPatch]$ ./datapatch -verbose[oracle@db1:/u01/app/oracle/product/19.3.0/db/OPatch]$ sqlplus / as sysdba
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.12.0.0.0sys@ORCL 17:44:08> alter system set cluster_database=true scope=spfile;
System altered.Elapsed: 00:00:00.06
sys@ORCL 17:44:11> shutdown immediate.
sys@ORCL 17:44:42> exit[oracle@db1:/u01/app/oracle/product/19.3.0/db/OPatch]$ srvctl start database -d orcl
[oracle@db1:/u01/app/oracle/product/19.3.0/db/OPatch]$ cd /u01/app/oracle/product/19.3.0/db/rdbms/admin/
[oracle@db1:/u01/app/oracle/product/19.3.0/db/rdbms/admin]$ sqlplus / as sysdba
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.12.0.0.0
sys@ORCL 17:49:40> @utlrp.sql
[grid@db1:/home/grid]$ opatch lspatches
32918050;TOMCAT RELEASE UPDATE 19.0.0.0.0 (32918050)
32916816;OCW RELEASE UPDATE 19.12.0.0.0 (32916816)
32915586;ACFS RELEASE UPDATE 19.12.0.0.0 (32915586)
32904851;Database Release Update : 19.12.0.0.210720 (32904851)
32585572;DBWLM RELEASE UPDATE 19.0.0.0.0 (32585572)
OPatch succeeded.[grid@db2:/home/grid]$ opatch lspatches
32918050;TOMCAT RELEASE UPDATE 19.0.0.0.0 (32918050)
32916816;OCW RELEASE UPDATE 19.12.0.0.0 (32916816)
32915586;ACFS RELEASE UPDATE 19.12.0.0.0 (32915586)
32904851;Database Release Update : 19.12.0.0.210720 (32904851)
32585572;DBWLM RELEASE UPDATE 19.0.0.0.0 (32585572)
OPatch succeeded.[oracle@db1:/home/oracle]$ opatch lspatches
32876380;OJVM RELEASE UPDATE: 19.12.0.0.210720 (32876380)
32916816;OCW RELEASE UPDATE 19.12.0.0.0 (32916816)
32904851;Database Release Update : 19.12.0.0.210720 (32904851)
OPatch succeeded.[oracle@db2:/home/oracle]$ opatch lspatches
32876380;OJVM RELEASE UPDATE: 19.12.0.0.210720 (32876380)
32916816;OCW RELEASE UPDATE 19.12.0.0.0 (32916816)
32904851;Database Release Update : 19.12.0.0.210720 (32904851)
OPatch succeeded.
看完文章,你现在应该知道在节点2应用DB补丁时为了避免踩坑,提前修改好oui-patch.xml
文件的权限,可以让你更加顺利的完整整个RU补丁更新过程