环境介绍: rhel7.3 x64 Oracle12.2.0.1
首先,我们看一下当前数据库环境:
-
SQL> select NAME, DECODE(CDB, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option ?" , OPEN_MODE, CON_ID from V$DATABASE;
-
-
NAME Multitenant Option ? OPEN_MODE CON_ID
-
-------------------- -------------------------- -------------------- ----------
-
FIRSOUL Multitenant Option enabled READ WRITE 0
-
-
SQL> col open_time for a40
-
SQL> select con_id,dbid,name,open_mode,open_time,creation_time from v$pdbs;
-
-
CON_ID DBID NAME OPEN_MODE OPEN_TIME CREATION_TIME
-
---------- ---------- -------------------- ---------- ---------------------------------------- -------------------
-
2 1858591033 PDB$SEED READ ONLY 13-AUG-17 03.04.04.538 PM +08:00 2017-03-09 21:22:34
-
3 839809039 FIRSOULDBPDB MOUNTED 2017-03-09 21:26:54
-
4 4175248251 FIRSOUL01 READ WRITE 13-AUG-17 03.04.12.357 PM +08:00 2017-03-14 10:18:37
我们可以使用一下命令去检查一下数据库是否更新过补丁:
-
SQL> col action_time format a30
-
SQL> col namespace for a15
-
SQL> col comments for a40
-
SQL> col version for a15
-
SQL> col action for a10
-
SQL> select action_time,action,namespace,version,comments from dba_registry_history;
-
-
ACTION_TIME ACTION NAMESPACE VERSION COMMENTS
-
------------------------------ ---------- --------------- --------------- ----------------------------------------
-
BOOTSTRAP DATAPATCH 12.2.0.1 RDBMS_12.2.0.1.0_LINUX.X64_170125
-
-
SQL> select patch_id,patch_uid,version,flags,action,status,action_time,description,bundle_series from dba_registry_sqlpatch;
-
-
no rows selected -- 请注意,12c之后多了这个视图,而且12.2.0.1 之后,补丁跟新后,也会更新到该视图中
再次通过opatch命令检查:
-
[oracle@test12 OPatch]$ ./opatch lsinventory
-
Oracle Interim Patch Installer version 12.2.0.1.6
-
Copyright (c) 2017, Oracle Corporation. All rights reserved.
-
-
-
Oracle Home : /oracle/app/oracle/product/12.2.0/dbhome_1
-
Central Inventory : /oracle/app/oraInventory
-
from : /oracle/app/oracle/product/12.2.0/dbhome_1/oraInst.loc
-
OPatch version : 12.2.0.1.6 --版本太低,需要下载安装在
-
OUI version : 12.2.0.1.4
-
Log file location : /oracle/app/oracle/product/12.2.0/dbhome_1/cfgtoollogs/opatch/opatch2017-08-13_15-22-54PM_1.log
-
-
Lsinventory Output file location : /oracle/app/oracle/product/12.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2017-08-13_15-22-54PM.txt
-
-
--------------------------------------------------------------------------------
-
Local Machine Information::
-
Hostname: test12
-
ARU platform id: 226
-
ARU platform description:: Linux x86-64
-
-
Installed Top-level Products (1):
-
-
Oracle Database 12c 12.2.0.1.0
-
There are 1 products installed in this Oracle Home.
-
-
-
There are no Interim patches installed in this Oracle Home.
-
-
-
--------------------------------------------------------------------------------
-
-
OPatch succeeded.
-
[oracle@test12 OPatch]$ ./opatch version
-
OPatch Version: 12.2.0.1.6
-
-
OPatch succeeded.
检查完毕,开始折腾
下载并上传相关补丁包,此处忽略
更新
OPatch目录 ,也就是更新它的版本
产品清单检查,及冲突检查
-
$ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME
-
-
create a.txt
-
/home/oracle/soft/26129945/25983138
-
$ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /home/oracle/soft/a.txt
停止数据库及相关服务,开始应用补丁,这里的补丁集 也有GI的,单机环境,所以只选择数据库的即可
-
cd /home/oracle/soft/26129945/25983138
-
-
$ORACLE_HOME/OPatch/opatch apply
应用完毕后,我们查看一下数据库字典信息,发现什么都没有……
opatch检查显示更新完毕,但对于数据库来说,没用……
-
[oracle@test12 25983138]$ $ORACLE_HOME/OPatch/opatch lsinventory
-
Oracle Interim Patch Installer version 12.2.0.1.9
-
Copyright (c) 2017, Oracle Corporation. All rights reserved.
-
-
-
Oracle Home : /oracle/app/oracle/product/12.2.0/dbhome_1
-
Central Inventory : /oracle/app/oraInventory
-
from : /oracle/app/oracle/product/12.2.0/dbhome_1/oraInst.loc
-
OPatch version : 12.2.0.1.9
-
OUI version : 12.2.0.1.4
-
Log file location : /oracle/app/oracle/product/12.2.0/dbhome_1/cfgtoollogs/opatch/opatch2017-08-13_15-37-24PM_1.log
-
-
Lsinventory Output file location : /oracle/app/oracle/product/12.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2017-08-13_15-37-24PM.txt
-
-
--------------------------------------------------------------------------------
-
Local Machine Information::
-
Hostname: test12
-
ARU platform id: 226
-
ARU platform description:: Linux x86-64
-
-
Installed Top-level Products (1):
-
-
Oracle Database 12c 12.2.0.1.0
-
There are 1 products installed in this Oracle Home.
-
-
-
Interim patches (1) :
-
-
Patch 25983138 : applied on Sun Aug 13 15:35:57 CST 2017
-
Unique Patch ID: 21358214
-
Patch description: "DATABASE BUNDLE PATCH: 12.2.0.1.170620 (25983138)"
-
Created on 18 Jun 2017, 23:01:52 hrs PST8PDT
-
Bugs fixed:
-
23026585, 24336249, 24929210, 24942749, 25036474, 25110233, 25410877
-
25417050, 25427662, 25459958, 25547901, 25569149, 25600342, 25600421
-
25606091, 25655390, 25662088, 24385983, 24923215, 25099758, 25429959
-
25662101, 25728085, 25823754, 22594071, 23665623, 23749454, 24326846
-
24334708, 24560906, 24573817, 24578797, 24609996, 24624166, 24668398
-
24674955, 24744686, 24811725, 24827228, 24831514, 24908321, 24976007
-
25184555, 25210499, 25211628, 25223839, 25262869, 25316758, 25337332
-
25455795, 25457409, 25539063, 25546608, 25612095, 25643931, 25410017
-
-
-
-
--------------------------------------------------------------------------------
-
-
OPatch succeeded.
其实等于修改后没有将sql文件 更新到数据库中
下面开始更新sql文本
-
首先打开所有pdb,当然你不想也没办法
-
alter pluggable database all open;
-
-
开始应用sql
-
[oracle@test12 OPatch]$ ./datapatch -verbose
-
SQL Patching tool version 12.2.0.1.0 Production on Sun Aug 13 15:41:24 2017
-
Copyright (c) 2012, 2017, Oracle. All rights reserved.
-
-
Log file for this invocation: /oracle/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_6995_2017_08_13_15_41_24/sqlpatch_invocation.log
-
-
Connecting to database...OK
-
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 SQL patches:
-
Bundle series DBBP:
-
ID 170620 in the binary registry and not installed in any PDB
-
-
Adding patches to installation queue and performing prereq checks...
-
Installation queue:
-
For the following PDBs: CDB$ROOT PDB$SEED FIRSOULDBPDB FIRSOUL01
-
Nothing to roll back
-
The following patches will be applied:
-
25983138 (DATABASE BUNDLE PATCH 12.2.0.1.170620)
-
-
Installing patches...
-
Patch installation complete. Total patches installed: 4
-
-
Validating logfiles...
-
Patch 25983138 apply (pdb CDB$ROOT): SUCCESS
-
logfile: /oracle/app/oracle/cfgtoollogs/sqlpatch/25983138/21358214/25983138_apply_FIRSOUL_CDBROOT_2017Aug13_15_41_45.log (no errors)
-
Patch 25983138 apply (pdb PDB$SEED): SUCCESS
-
logfile: /oracle/app/oracle/cfgtoollogs/sqlpatch/25983138/21358214/25983138_apply_FIRSOUL_PDBSEED_2017Aug13_15_42_16.log (no errors)
-
Patch 25983138 apply (pdb FIRSOULDBPDB): SUCCESS
-
logfile: /oracle/app/oracle/cfgtoollogs/sqlpatch/25983138/21358214/25983138_apply_FIRSOUL_FIRSOULDBPDB_2017Aug13_15_42_16.log (no errors)
-
Patch 25983138 apply (pdb FIRSOUL01): SUCCESS
-
logfile: /oracle/app/oracle/cfgtoollogs/sqlpatch/25983138/21358214/25983138_apply_FIRSOUL_FIRSOUL01_2017Aug13_15_42_16.log (no errors)
-
SQL Patching tool complete on Sun Aug 13 15:48:33 2017
下次查看数据库字典
-
SQL> col action_time format a30
-
SQL> col namespace for a15
-
SQL> col comments for a40
-
SQL> col version for a15
-
SQL> col action for a10
-
SQL> select action_time,action,namespace,version,comments from dba_registry_history;
-
-
-
ACTION_TIME ACTION NAMESPACE VERSION COMMENTS
-
------------------------------ ---------- --------------- --------------- ----------------------------------------
-
BOOTSTRAP DATAPATCH 12.2.0.1 RDBMS_12.2.0.1.0_LINUX.X64_170125
-
-
依然不显示…… 什么情况
哦,对了,Oracle12c还有一个视图…… 补丁已更新:
DATABASE BUNDLE PATCH 12.2.0.1.170620
-
SQL>
-
SQL> col status for a8
-
SQL> col description for a40
-
SQL> col version for a10
-
SQL> select patch_id,patch_uid,version,action,status,action_time,description from dba_registry_sqlpatch;
-
-
PATCH_ID PATCH_UID VERSION ACTION STATUS ACTION_TIME DESCRIPTION
-
---------- ---------- ---------- ---------- -------- ------------------------------ ----------------------------------------
-
25983138 21358214 12.2.0.1 APPLY SUCCESS 13-AUG-17 03.48.32.294218 PM DATABASE BUNDLE PATCH 12.2.0.1.170620
-
-
1 row selected.
不错,不错,收尾工作
如果
OJVM PSU,OJVM PSU 也安装
需要执行下面脚本
-
cd $ORACLE_HOME/rdbms/admin
-
sqlplus /nolog
-
SQL> CONNECT / AS SYSDBA
-
SQL> @utlrp.sql
-
-
SQL > @dbmsjdev.sql
-
SQL > exec dbms_java_dev.disable
后记:一定要看readme文件 ,关于集群的 后续找时间测试,当然,首先需要测试安装Oracle12c RAC……