1、 下载最新的12.1.0.1的DB PSU 与 OPatch
p23054354_121010_Linux-x86-64.zipp6880880_121010_Linux-x86-64.zip2. 检查数据库当前OPatch版本
[oracle@host-172-16-3-132 ~]$ $ORACLE_HOME/OPatch/opatch versionOPatch Version: 12.1.0.1.0OPatch succeeded.3. 更新OPatch
[oracle@host-172-16-3-132 ~]$ echo $ORACLE_HOME/u01/app/oracle/product/12.1.0/dbhome_1-- root用户执行,/u01/app/oracle/product/12.1.0/dbhome_1/为oracle用户下的$ORACLE_HOME路径
[root@host-172-16-3-132 ~]# mv /u01/app/oracle/product/12.1.0/dbhome_1/OPatch /u01/app/oracle/product/12.1.0/dbhome_1/OPatch_bak[root@host-172-16-3-132 u01]# ll p6880880_121010_Linux-x86-64.zip-rw-r--r-- 1 oracle oinstall 80276058 Sep 12 18:16 p6880880_121010_Linux-x86-64.zi[root@host-172-16-3-132 u01]# unzip p6880880_121010_Linux-x86-64.zip -d /u01/app/oracle/product/12.1.0/dbhome_1/[root@host-172-16-3-132 u01]# chown -R oracle:oinstall /u01/app/oracle/product/12.1.0/dbhome_1/OPatch4、 检查OPatch
[oracle@host-172-16-3-132 u01]$ $ORACLE_HOME/OPatch/opatch versionOPatch Version: 12.2.0.1.9OPatch succeeded.5. 解压补丁文件
[root@host-172-16-3-132 u01]# unzip p23054354_121010_Linux-x86-64.zip -d /u01/db_psu/[root@host-172-16-3-132 u01]# chown -R oracle:oinstall /u01/db_psu/6. 检查补丁之间有无冲突
[root@host-172-16-3-132 u01]# cd db_psu/[root@host-172-16-3-132 db_psu]# ls23054354 PatchSearch.xml[root@host-172-16-3-132 db_psu]# cd 23054354/[root@host-172-16-3-132 23054354]# ls19769486 20831107 21951844 23054354 README.txt20299016 21352619 22291141 README.html[oracle@host-172-16-3-132 23054354]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/db_psu/23054354 -oh $ORACLE_HOME
Oracle Interim Patch Installer version 12.2.0.1.9
Copyright (c) 2017, Oracle Corporation. All rights reserved.PREREQ sessionOracle Home : /u01/app/oracle/product/12.1.0/dbhome_1Central Inventory : /u01/app/oraInventory from : /u01/app/oracle/product/12.1.0/dbhome_1/oraInst.locOPatch version : 12.2.0.1.9OUI version : 12.1.0.1.0Log file location : /u01/app/oracle/product/12.1.0/dbhome_1/cfgtoollogs/opatch/opatch2017-09-13_10-14-32AM_1.logInvoking prereq "checkconflictagainstohwithdetail"Prereq "checkConflictAgainstOHWithDetail" passed.OPatch succeeded.7. 为数据库做冷备份 (如果不考虑安全性,这步可以省略,有点点风险)
使用root用户备份oracle_home (将#ORACLE_HOME上级目录整个备份)
tar -zcvpf db_20170913.tar.gz dbhome_1/8. 关闭实例和监听 (注意静态监听与oem)
[oracle@host-172-16-3-132 23054354]$ lsnrctl stop[oracle@host-172-16-3-132 23054354]$ lsnrctl status[root]#ps -ef|grep -v grep |grep LOCAL=NO|awk '{print $2}'|xargs kill -9[oracle@host-172-16-3-132 23054354]$ sqlplus / as sysdbaSQL> shutdown immediate;[oracle]$ netstat -an |grep 11589、 手动更新补丁
[oracle@host-172-16-3-132 23054354]$ $ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.9Copyright (c) 2017, Oracle Corporation. All rights reserved. Oracle Home : /u01/app/oracle/product/12.1.0/dbhome_1Central Inventory : /u01/app/oraInventory from : /u01/app/oracle/product/12.1.0/dbhome_1/oraInst.locOPatch version : 12.2.0.1.9OUI version : 12.1.0.1.0Log file location : /u01/app/oracle/product/12.1.0/dbhome_1/cfgtoollogs/opatch/opatch2017-09-13_12-21-10PM_1.logVerifying environment and performing prerequisite checks...
OPatch continues with these patches: 19769486 20299016 20831107 21352619 21951844 22291141 23054354Do you want to proceed? [y|n]
yUser Responded with: YAll checks passed.Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/12.1.0/dbhome_1') Is the local system ready for patching? [y|n]yUser Responded with: YBacking up files...Applying sub-patch '19769486' to OH '/u01/app/oracle/product/12.1.0/dbhome_1'ApplySession: Optional component(s) [ oracle.network.cman, 12.1.0.1.0 ] not present in the Oracle Home or a higher version is found.Composite patch 23054354 successfully applied.
Log file location: /u01/app/oracle/product/12.1.0/dbhome_1/cfgtoollogs/opatch/opatch2017-09-13_12-21-10PM_1.logOPatch succeeded. SQL> startup;ORACLE instance started.Total System Global Area 2371719168 bytes
Fixed Size 2853264 bytesVariable Size 654313072 bytesDatabase Buffers 1694498816 bytesRedo Buffers 20054016 bytesDatabase mounted.Database opened.SQL> alter pluggable database all open;Pluggable database altered.
10、 将补丁注册到数据字典中:
注意:12C的补丁注册改成了用datapatch工具,而不是以前版本的 @$ORACLE_HOME/rdbms/admin/catbundle.sql psu apply
[oracle@host-172-16-3-132 OPatch]$ cd $ORACLE_HOME/OPatch[oracle@host-172-16-3-132 OPatch]$ ./datapatch -verboseConnecting to database...OKDetermining current state...Currently installed SQL Patches: PDB CDB$ROOT: PDB PDB$SEED: PDB PDB01: ..... logfile: /u01/app/oracle/product/12.1.0/dbhome_1/sqlpatch/23054354/23054354_apply_ANDYCDB_PDB01_2017Sep14_04_41_10.log (no errors) catbundle generate logfile: /u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_ANDYCDB_PDB01_GENERATE_2017Sep14_04_41_11.log (no errors) catbundle apply logfile: /u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_ANDYCDB_PDB01_APPLY_2017Sep14_04_41_13.log (no errors)SQL Patching tool complete on Thu Sep 14 04:41:53 201711、 验证是否打补丁成功
col ACTION_TIME for a30;col COMMENTS for a20;col BUNDLE_SERIES for a10;select ACTION_TIME,BUNDLE_SERIES,COMMENTS from dba_registry_history;ACTION_TIME BUNDLE_SER COMMENTS
------------------------------ ---------- --------------------14-SEP-17 03.46.47.445096 AM PSU Patchset 12.1.0.0.014-SEP-17 04.28.21.213333 AM PSU PSU 12.1.0.1.16071914-SEP-17 04.28.32.004194 AM PSU PSU 12.1.0.1.16071914-SEP-17 04.28.42.435304 AM PSU PSU 12.1.0.1.16071914-SEP-17 04.28.53.797447 AM PSU PSU 12.1.0.1.16071914-SEP-17 04.29.03.854827 AM PSU PSU 12.1.0.1.16071914-SEP-17 04.29.14.465123 AM PSU PSU 12.1.0.1.16071914-SEP-17 04.29.25.696294 AM PSU PSU 12.1.0.1.1607198 rows selected[oracle@12 OPatch]$ $ORACLE_HOME/OPatch/opatch lsinventory
Patch 23054354 : applied on Thu Sep 14 04:12:25 CST 2017Unique Patch ID: 20238050SQL> select count(*) from dba_objects where status<>'VALID';
COUNT(*)
---------- 012、 启动监听
[oracle@12 OPatch]$ lsnrctl start
[oracle@12 OPatch]$ lsnrctl status