ORACLE 19C 安装数据库补丁的详细过程
ORACLE 19c安装DB补丁:
1 确定OPatch的可用性:这里需要注意的是p6880880_190000_Linux-x86-64.zip是有版本对应区别的,需要注意你要打的补丁版本是否支持。
2 将原$ORACLE_HOME目录下的OPatch目录删除或者改名,比如说:
cd $ORACLE_HOME
mv OPatch OPatch_1
或rm -rf OPatch
3 将p6880880_190000_Linux-x86-64.zip上传到你的$ORACLE_HOME目录下并解压。
unzip p6880880_190000_Linux-x86-64.zip
解压后你就可以得到一个新的OPatch目录。
4修改环境变量添加:
export ORACLE_OPatch=$ORACLE_HOME/OPatch
在export PATH=.....这行字符最后添加:$ORACLE_OPatch
比如:
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin:$ORACLE_OPatch
然后环境变量生成
source ~/.bash_profile
5 执行opatch version
[oracle@oracle19c ~]$ opatch version
OPatch Version: 12.2.0.1.28
OPatch succeeded.
看到这样就可以了。
6 使用ORACLE用户将你的补丁文件压缩包上传到服务器上。并解压,准备打补丁。
7 解压补丁 : unzip p33515361_190000_Linux-x86-64.zip
8 关闭监听和关闭数据库:
lsnrctl stop
[oracle@oracle19c u01]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jan 23 22:22:57 2022
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
这里我们可以看到我们数据库版本为19300,关闭数据库
shutdown immediate
9 检查补丁信息:
cd 33515361/(这个33515361是刚才解压出来的,你们要根据你们的实际情况而定)
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.2.0.1.28
Copyright (c) 2022, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/oracle/product/19c/db_1
Central Inventory : /u01/oraInventory
from : /u01/app/oracle/product/19c/db_1/oraInst.loc
OPatch version : 12.2.0.1.28
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19c/db_1/cfgtoollogs/opatch/opatch2022-01-23_22-26-20PM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
没有问题,证明一切OK.
10 开始打补丁
cd 33515361/
opatch apply (这个需要在解压出来的补丁目录下执行)
Do you want to proceed? [y|n] 出这种东西的话 一律 'y'
看到这些:
Patching component oracle.jdk, 1.8.0.201.0...
Patch 33515361 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [33515361].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19c/db_1/cfgtoollogs/opatch/opatch2022-01-23_22-29-14PM_1.log
OPatch succeeded.
代表数据库补丁安装完毕。
11 启动数据库
[oracle@oracle19c 33515361]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jan 23 22:36:38 2022
Version 19.14.0.0.0(看这里)
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 733999360 bytes
Fixed Size 8900864 bytes
Variable Size 201326592 bytes
Database Buffers 520093696 bytes
Redo Buffers 3678208 bytes
Database mounted.
Database opened.
SQL>
这里应景看到了是191400而不是19300了
12 执行datapatch
datapatch -verbose (千万别再SQLPLUS下执行,要在ORACLE用户的LINUX终端上执行)
[oracle@oracle19c 33515361]$ datapatch -verbose
SQL Patching tool version 19.14.0.0.0 Production on Sun Jan 23 22:43:26 2022
Copyright (c) 2012, 2021, Oracle. All rights reserved.
Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_12364_2022_01_23_22_43_26/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:
No interim patches found
Current state of release update SQL patches:
Binary registry:
19.14.0.0.0 Release_Update 211225122123: Installed
SQL registry:
Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 18-JAN-21 02.54.27.541960 AM
Adding patches to installation queue and performing prereq checks...done
Installation queue:
No interim patches need to be rolled back
Patch 33515361 (Database Release Update : 19.14.0.0.220118 (33515361)):
Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.14.0.0.0 Release_Update 211225122123
No interim patches need to be applied
Installing patches...
看到下列信息代表成功了。
Patch installation complete. Total patches installed: 1
Validating logfiles...done
Patch 33515361 apply: SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/33515361/24589353/33515361_apply_ORCL_2022Jan23_22_43_55.log (no errors)
SQL Patching tool complete on Sun Jan 23 22:51:58 2022
13 进入到sqlplus / as sysdba下:
执行:@?/rdbms/admin/utlrp.sql
SQL> @?/rdbms/admin/utlrp.sql
@?/rdbms/admin/utlrp.sql
Session altered.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2022-01-23 22:54:50
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.
直到看到
ERRORS DURING RECOMPILATION
---------------------------
0
Function created.
PL/SQL procedure successfully completed.
Function dropped.
PL/SQL procedure successfully completed.
代表成功。
14 检查补丁是否成功
col ACTION for a8
col status for a10
set line 230
col ACTION_TIME for a30
col DESCRIPTION for a60
执行下列SQL语句
select patch_id, action,status,action_time,description from dba_registry_sqlpatch;
PATCH_ID ACTION STATUS ACTION_TIME DESCRIPTION
---------- -------- ---------- ------------------------------ ------------------------------------------------------------
29517242 APPLY SUCCESS 18-JAN-21 02.54.27.541960 AM Database Release Update : 19.3.0.0.190416 (29517242)
33515361 APPLY SUCCESS 23-JAN-22 10.51.58.754167 PM Database Release Update : 19.14.0.0.220118 (33515361)
看到SUCCESS后代表成功,我们把数据库从 19.3.0.0.190416 (29517242) 升级到 19.14.0.0.220118 (33515361)
这里的29517242代表19300的补丁编号,一旦失败,我们需要回滚我们的补丁。
到这里补丁就算成功打完了。