在之前的博客里我们看了2片RUR的升级,这篇我们看下RU的升级。
Oracle 18c RAC 集群 RUR 从18.3.0 升级到18.3.1 操作手册
https://www.cndba.cn/dave/article/3142Oracle 18c 单实例 RUR 从18.3.0 升级到18.3.1 操作手册
https://www.cndba.cn/dave/article/3138
1. 18c 补丁版本说明
Oracle 从18c 开始,版本号和补丁结构发生了明显的变化,新的补丁体系里只有RU和RUR的概念。版本号也只有前三位有效,如下图:
- 第一位数字是Oracle数据库的主版本号,比如Oracle 18c,12c。 从Oracle 18c开始,第一个数字表示Oracle数据库版本发布的最初的年份,比如2018年是Oracle 18c(18.0.0.0.0)的最初发布年份。
- 第二位数字是Oracle RU(Release Update)的发布季度。比如18.3。
- 第三位数字是Oracle RUR(release updates revision)的发布季度,比如18.1.1,18.2.1,18.3.0。
所以从18c 开始,我们打补丁,实际上打的RU或者RUR。 本文档我们看Oracle 18c中如何打RUR的补丁。 即从18.3.0 升级到18.3.1。 具体的Patch可以从MOS上下载。
RU如下:
RUR如下:
2. 当前DB环境
[dave@www.cndba.cn ~]$ lsnrctl status
LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 14-NOV-2018 08:33:43
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=18cDG1)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Start Date 14-NOV-2018 07:17:12
Uptime 0 days 1 hr. 16 min. 30 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/18.3.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/18cDG1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=18cDG1)(PORT=1522)))
Services Summary...
Service "cndba" has 1 instance(s).
Instance "cndba", status UNKNOWN, has 1 handler(s) for this service...
Service "dave" has 1 instance(s).
Instance "cndba", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[dave@www.cndba.cn ~]$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Wed Nov 14 08:33:50 2018
Version 18.3.1.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.1.0.0
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 DAVE READ WRITE NO
SQL>
3 开始打RU
Oracle patch的压缩包里都会有一个readme 文件,可以查看该文件,了解打Patch的步骤。
3.1 检查OPatch工具版本
在Oracle 18c的RUR,OPatch的版本必须大于12.2.0.1.14. 最新版本的Opatch可以从MOS 6880880上下载。 目前最新版是OPatch 12.2.0.1.16 for DB 18.x releases (OCT 2018)。
[dave@www.cndba.cn OPatch]$ pwd
/u01/app/oracle/product/18.3.0/db_1/OPatch
[dave@www.cndba.cn OPatch]$ ./opatch version
OPatch Version: 12.2.0.1.14
OPatch succeeded.
[dave@www.cndba.cn OPatch]$
18c中默认版本就是12.2.0.1.14,所以不用升级Opatch,如果要申请,可以参考我的博客:
Oracle 更新 OPatch 工具版本 的方法 说明
https://www.cndba.cn/cndba/dave/article/1353
3.2 检查Patch 是否冲突
[dave@www.cndba.cn ~]$ cd /u01/software/
[dave@www.cndba.cn software]$ ls
28655784 p28655784_180000_Linux-x86-64--DB.zip PatchSearch.xml
[dave@www.cndba.cn software]$ cd 28655784/
[dave@www.cndba.cn 28655784]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.2.0.1.14
Copyright (c) 2018, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/oracle/product/18.3.0/db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/18.3.0/db_1/oraInst.loc
OPatch version : 12.2.0.1.14
OUI version : 12.2.0.4.0
Log file location : /u01/app/oracle/product/18.3.0/db_1/cfgtoollogs/opatch/opatch2018-11-14_09-11-08AM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
[dave@www.cndba.cn 28655784]$
3.3 应用patch
对于DG环境可以先应用备库,在应用主库,对于RAC环境,可以每次应用一个节点,这样可以避免停机时间,但如果是单实例,那么在应用之前,必须关闭数据库和监听,退出所有sqlplus 窗口。
[dave@www.cndba.cn 28655784]$ lsnrctl stop
LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 14-NOV-2018 09:12:41
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=18cDG1)(PORT=1522)))
The command completed successfully
[dave@www.cndba.cn 28655784]$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Wed Nov 14 09:13:10 2018
Version 18.3.1.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.1.0.0
SQL>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
[dave@www.cndba.cn 28655784]$ pwd
/u01/software/28655784
[dave@www.cndba.cn 28655784]$ $ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.14
Copyright (c) 2018, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/18.3.0/db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/18.3.0/db_1/oraInst.loc
OPatch version : 12.2.0.1.14
OUI version : 12.2.0.4.0
Log file location : /u01/app/oracle/product/18.3.0/db_1/cfgtoollogs/opatch/opatch2018-11-14_09-15-08AM_1.log
Verifying environment and performing prerequisite checks...
Prerequisite check "CheckActiveFilesAndExecutables" failed.
The details are:
Following executables are active :
/u01/app/oracle/product/18.3.0/db_1/lib/libclntsh.so.18.1
/u01/app/oracle/product/18.3.0/db_1/lib/libsqlplus.so
UtilSession failed: Prerequisite check "CheckActiveFilesAndExecutables" failed.
Log file location: /u01/app/oracle/product/18.3.0/db_1/cfgtoollogs/opatch/opatch2018-11-14_09-15-08AM_1.log
OPatch failed with error code 73
[dave@www.cndba.cn 28655784]$
执行报错,这里实际上是因为还有sqlplus窗口没有导出导致的,退出后在执行即可:
/u01/app/oracle/product/18.3.0/db_1/lib/libsqlplus.so
[dave@www.cndba.cn 28655784]$ pwd
/u01/software/28655784
[dave@www.cndba.cn 28655784]$ $ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.14
Copyright (c) 2018, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/18.3.0/db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/18.3.0/db_1/oraInst.loc
OPatch version : 12.2.0.1.14
OUI version : 12.2.0.4.0
Log file location : /u01/app/oracle/product/18.3.0/db_1/cfgtoollogs/opatch/opatch2018-11-14_09-15-08AM_1.log
Verifying environment and performing prerequisite checks...
Prerequisite check "CheckActiveFilesAndExecutables" failed.
The details are:
Following executables are active :
/u01/app/oracle/product/18.3.0/db_1/lib/libclntsh.so.18.1
/u01/app/oracle/product/18.3.0/db_1/lib/libsqlplus.so
UtilSession failed: Prerequisite check "CheckActiveFilesAndExecutables" failed.
Log file location: /u01/app/oracle/product/18.3.0/db_1/cfgtoollogs/opatch/opatch2018-11-14_09-15-08AM_1.log
OPatch failed with error code 73
[dave@www.cndba.cn 28655784]$ $ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.14
Copyright (c) 2018, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/18.3.0/db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/18.3.0/db_1/oraInst.loc
OPatch version : 12.2.0.1.14
OUI version : 12.2.0.4.0
Log file location : /u01/app/oracle/product/18.3.0/db_1/cfgtoollogs/opatch/opatch2018-11-14_09-18-02AM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 28655784
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/18.3.0/db_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '28655784' to OH '/u01/app/oracle/product/18.3.0/db_1'
ApplySession: Optional component(s) [ oracle.assistants.asm, 18.0.0.0.0 ] , [ oracle.ons.daemon, 18.0.0.0.0 ] , [ oracle.crs, 18.0.0.0.0 ] , [ oracle.net.cman, 18.0.0.0.0 ] , [ oracle.network.cman, 18.0.0.0.0 ] , [ oracle.assistants.usm, 18.0.0.0.0 ] , [ oracle.tfa, 18.0.0.0.0 ] , [ oracle.assistants.server.oui, 18.0.0.0.0 ] , [ oracle.has.crs, 18.0.0.0.0 ] not present in the Oracle Home or a higher version is found.
Patching component oracle.rdbms.rsf.ic, 18.0.0.0.0...
Patching component oracle.oracore.rsf, 18.0.0.0.0...
Patching component oracle.ctx.atg, 18.0.0.0.0...
Patching component oracle.rdbms.rman, 18.0.0.0.0...
Patching component oracle.rdbms.rsf, 18.0.0.0.0...
Patching component oracle.sdo.locator.jrf, 18.0.0.0.0...
Patching component oracle.rdbms.oci, 18.0.0.0.0...
Patching component oracle.xdk.rsf, 18.0.0.0.0...
Patching component oracle.server, 18.0.0.0.0...
Patching component oracle.ctx.rsf, 18.0.0.0.0...
Patching component oracle.rdbms.dbscripts, 18.0.0.0.0...
Patching component oracle.assistants.deconfig, 18.0.0.0.0...
Patching component oracle.dbjava.ucp, 18.0.0.0.0...
Patching component oracle.network.client, 18.0.0.0.0...
Patching component oracle.dbjava.ic, 18.0.0.0.0...
Patching component oracle.rdbms.crs, 18.0.0.0.0...
Patching component oracle.sqlplus, 18.0.0.0.0...
Patching component oracle.dbjava.jdbc, 18.0.0.0.0...
Patching component oracle.rdbms.install.plugins, 18.0.0.0.0...
Patching component oracle.ons, 18.0.0.0.0...
Patching component oracle.assistants.server, 18.0.0.0.0...
Patching component oracle.network.listener, 18.0.0.0.0...
Patching component oracle.install.deinstalltool, 18.0.0.0.0...
Patching component oracle.oraolap.dbscripts, 18.0.0.0.0...
Patching component oracle.sdo, 18.0.0.0.0...
Patching component oracle.assistants.acf, 18.0.0.0.0...
Patching component oracle.sqlplus.ic, 18.0.0.0.0...
Patching component oracle.rdbms, 18.0.0.0.0...
Patching component oracle.rdbms.util, 18.0.0.0.0...
Patching component oracle.xdk.parser.java, 18.0.0.0.0...
Patching component oracle.nlsrtl.rsf, 18.0.0.0.0...
Patching component oracle.network.rsf, 18.0.0.0.0...
Patching component oracle.nlsrtl.rsf.core, 18.0.0.0.0...
Patching component oracle.ctx, 18.0.0.0.0...
Patching component oracle.sdo.locator, 18.0.0.0.0...
Patching component oracle.xdk, 18.0.0.0.0...
Patching component oracle.rdbms.deconfig, 18.0.0.0.0...
Patching component oracle.precomp.rsf, 18.0.0.0.0...
Patching component oracle.javavm.client, 18.0.0.0.0...
Patching component oracle.ldap.owm, 18.0.0.0.0...
Patching component oracle.ldap.security.osdt, 18.0.0.0.0...
Patching component oracle.rdbms.install.common, 18.0.0.0.0...
Patching component oracle.precomp.lang, 18.0.0.0.0...
Patching component oracle.precomp.common, 18.0.0.0.0...
Patch 28655784 successfully applied.
Sub-set patch [28507480] has become inactive due to the application of a super-set patch [28655784].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/18.3.0/db_1/cfgtoollogs/opatch/opatch2018-11-14_09-18-02AM_1.log
OPatch succeeded.
[dave@www.cndba.cn 28655784]$
3.4 加载修改后的SQL到数据库
打补丁后会修改一下SQL,这些SQL还没有加载到数据库中,需要运行Datapatch工具将这些修改后的SQL重新加载到数据库中,如果是RAC环境,只需要在一个节点执行就可以了。
对于18c的CDB架构,执行如下步骤:
- sqlplus /nolog
- SQL> Connect / as sysdba
- SQL> startup
- SQL> alter pluggable database all open;
- SQL> quit
- cd $ORACLE_HOME/OPatch
- ./datapatch -verbose
datapatch命令只对打开的数据库生效,所有Oracle建议在执行该命令之前将CDB和所有的PDB都打开,一次更新掉。 但如果有部分PDB没有打开,也可以在打开之后,重新运行datapatch命令。
我们这里把所有PDB都打开,如果没有打开,可以参考如下博客:
Oracle 18c 单实例 RUR 从18.3.0 升级到18.3.1 操作手册
https://www.cndba.cn/dave/article/3138
[dave@www.cndba.cn 28655784]$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Wed Nov 14 09:36:21 2018
Version 18.4.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1191181104 bytes
Fixed Size 8895280 bytes
Variable Size 822083584 bytes
Database Buffers 83886080 bytes
Redo Buffers 7880704 bytes
In-Memory Area 268435456 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
[dave@www.cndba.cn 28655784]$ $ORACLE_HOME/OPatch/datapatch -verbose
SQL Patching tool version 18.0.0.0.0 Production on Wed Nov 14 09:37:50 2018
Copyright (c) 2012, 2018, Oracle. All rights reserved.
Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_6680_2018_11_14_09_37_50/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:
Interim patch 27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415)):
Binary registry: Installed
PDB CDB$ROOT: Applied successfully on 26-AUG-18 03.46.12.362385 AM
PDB DAVE: Applied successfully on 26-AUG-18 03.52.38.519926 AM
PDB PDB$SEED: Applied successfully on 26-AUG-18 03.52.38.519926 AM
Current state of release update SQL patches:
Binary registry:
18.4.0.0.0 Release_Update 1809251743: Installed
PDB CDB$ROOT:
Applied 18.3.1.0.0 Release_Update_Revision 1809111630 successfully on 14-NOV-18 07.05.00.089098 AM
PDB DAVE:
Applied 18.3.1.0.0 Release_Update_Revision 1809111630 successfully on 14-NOV-18 07.42.42.340186 AM
PDB PDB$SEED:
Applied 18.3.1.0.0 Release_Update_Revision 1809111630 successfully on 14-NOV-18 07.05.07.215895 AM
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 28507480 (Database Release Update Revision : 18.3.1.0.181016 (28507480)):
Rollback from 18.3.1.0.0 Release_Update_Revision 1809111630 to 18.3.0.0.0 Release_Update 1806280943
Patch 28655784 (Database Release Update : 18.4.0.0.181016 (28655784)):
Apply from 18.3.0.0.0 Release_Update 1806280943 to 18.4.0.0.0 Release_Update 1809251743
No interim patches need to be applied
Installing patches...
Patch installation complete. Total patches installed: 6
Validating logfiles...done
Patch 28507480 rollback (pdb CDB$ROOT): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/28507480/22444948/28507480_rollback_CNDBA_CDBROOT_2018Nov14_09_40_12.log (no errors)
Patch 28655784 apply (pdb CDB$ROOT): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/28655784/22509982/28655784_apply_CNDBA_CDBROOT_2018Nov14_09_44_13.log (no errors)
Patch 28507480 rollback (pdb PDB$SEED): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/28507480/22444948/28507480_rollback_CNDBA_PDBSEED_2018Nov14_09_47_30.log (no errors)
Patch 28655784 apply (pdb PDB$SEED): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/28655784/22509982/28655784_apply_CNDBA_PDBSEED_2018Nov14_09_49_22.log (no errors)
Patch 28507480 rollback (pdb DAVE): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/28507480/22444948/28507480_rollback_CNDBA_DAVE_2018Nov14_09_47_30.log (no errors)
Patch 28655784 apply (pdb DAVE): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/28655784/22509982/28655784_apply_CNDBA_DAVE_2018Nov14_09_49_24.log (no errors)
SQL Patching tool complete on Wed Nov 14 09:51:08 2018
[dave@www.cndba.cn 28655784]$
注意这里的过程:
Rollback from 18.3.1.0.0 Release_Update_Revision 1809111630 to 18.3.0.0.0 Release_Update 1806280943
Patch 28655784 (Database Release Update : 18.4.0.0.181016 (28655784)):
Apply from 18.3.0.0.0 Release_Update 1806280943 to 18.4.0.0.0 Release_Update 1809251743
首先是将RUR从18.3.1 回退到18.3.0。 然后在RU从18.3.0 升级到18.4.0。
3.5 查看版本变化
datapatch 工具加载修改的SQL之后会将patch添加到dba_registry_sqlpatch试图中,以反应patch的应用情况。 查询试图可以看到patch的APPLY状态为”SUCCESS”。
[dave@www.cndba.cn ~]$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Wed Nov 14 09:53:08 2018
Version 18.4.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
SQL> set lines 170
SQL> select patch_id,patch_type,action,status,action_time,description from dba_registry_sqlpatch;
PATCH_ID PATCH_TYPE ACTION STATUS ACTION_TIME DESCRIPTION
---------- -------------------- ------------ ------------ ----------------------------------- -----------------------------------------------------------------
28090523 RU APPLY SUCCESS 26-AUG-18 03.46.12.351709 AM Database Release Update : 18.3.0.0.180717 (28090523)
27923415 INTERIM APPLY SUCCESS 26-AUG-18 03.46.12.362385 AM OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415)
28507480 RUR APPLY SUCCESS 14-NOV-18 07.05.00.089098 AM Database Release Update Revision : 18.3.1.0.181016 (28507480)
28507480 RUR ROLLBACK SUCCESS 14-NOV-18 09.50.29.767179 AM Database Release Update Revision : 18.3.1.0.181016 (28507480)
28655784 RU APPLY SUCCESS 14-NOV-18 09.50.33.707857 AM Database Release Update : 18.4.0.0.181016 (28655784)
#这里可以看到回退RUR的过程。
SQL> col version for a30
SQL> select ACTION_TIME,VERSION,COMMENTS from dba_registry_history;
ACTION_TIME VERSION COMMENTS
----------------------------------- ------------------------------ ------------------------------------------------------------
18 RDBMS_18.4.0.0.0DBRU_LINUX.X64_180925
26-AUG-18 03.45.08.480341 AM 18.0.0.0.0 Patch applied from 18.1.0.0.0 to 18.3.0.0.0
26-AUG-18 03.46.09.656019 AM 18.3.0.0.180717OJVMRU RAN jvmpsu.sql
26-AUG-18 03.46.09.749574 AM 18.3.0.0.180717OJVMRU OJVM RU post-install
14-NOV-18 07.01.57.566558 AM 18.0.0.0.0 Patch applied from 18.3.0.0.0 to 18.3.1.0.0
14-NOV-18 09.44.13.291266 AM 18.0.0.0.0 Patch rolled back from 18.3.1.0.0 to 18.3.0.0.0
14-NOV-18 09.46.12.351457 AM 18.0.0.0.0 Patch applied from 18.3.0.0.0 to 18.4.0.0.0
7 rows selected.
3.6 处理无效对象
最后一步就是处理无效对象,因为之前datapatch命令会加载SQL,这个过程可能会产生无效对象。 可以执行@utlrp.sql脚本处理这些无效对象:
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> @utlrp.sql
至此RU升级完成。注意一点,升级RU是先回退RUR,在升级RU. 我们这里是先是将RUR从18.3.1 回退到18.3.0。 然后在RU从18.3.0 升级到18.4.0。
版权声明:本文为博主原创文章,未经博主允许不得转载。