欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

oracle12c单机12.1.0.1版本打补丁实例

程序员文章站 2022-07-01 18:46:05
1、 下载最新的12.1.0.1的db psu 与 opatch p23054354_121010_linux-x86-64.zip p6880880_121010_linux-x86-64.zip...

1、 下载最新的12.1.0.1的db psu 与 opatch

p23054354_121010_linux-x86-64.zip

p6880880_121010_linux-x86-64.zip

2. 检查当前opatch版本

[oracle@host-172-16-3-132 ~]$ $oracle_home/opatch/opatch version

opatch version: 12.1.0.1.0

opatch 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/opatch

4、 检查opatch

[oracle@host-172-16-3-132 u01]$ $oracle_home/opatch/opatch version

opatch version: 12.2.0.1.9

opatch 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]# ls

23054354 patchsearch.xml

[root@host-172-16-3-132 db_psu]# cd 23054354/

[root@host-172-16-3-132 23054354]# ls

19769486 20831107 21951844 23054354 readme.txt

20299016 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 session

oracle home : /u01/app/oracle/product/12.1.0/dbhome_1

central inventory : /u01/app/orainventory

from : /u01/app/oracle/product/12.1.0/dbhome_1/orainst.loc

opatch version : 12.2.0.1.9

oui version : 12.1.0.1.0

log file location : /u01/app/oracle/product/12.1.0/dbhome_1/cfgtoollogs/opatch/opatch2017-09-13_10-14-32am_1.log

invoking 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 sysdba

sql> shutdown immediate;

[oracle]$ netstat -an |grep 1158

9、 手动更新补丁

[oracle@host-172-16-3-132 23054354]$ $oracle_home/opatch/opatch apply

oracle interim patch installer version 12.2.0.1.9

copyright (c) 2017, oracle corporation. all rights reserved.

oracle home : /u01/app/oracle/product/12.1.0/dbhome_1

central inventory : /u01/app/orainventory

from : /u01/app/oracle/product/12.1.0/dbhome_1/orainst.loc

opatch version : 12.2.0.1.9

oui version : 12.1.0.1.0

log file location : /u01/app/oracle/product/12.1.0/dbhome_1/cfgtoollogs/opatch/opatch2017-09-13_12-21-10pm_1.log

verifying environment and performing prerequisite checks...

opatch continues with these patches: 19769486 20299016 20831107 21352619 21951844 22291141 23054354

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/12.1.0/dbhome_1')

is the local system ready for patching [y|n]

y

user responded with: y

backing 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.log

opatch succeeded.

sql> startup;

oracle instance started.

total system global area 2371719168 bytes

fixed size 2853264 bytes

variable size 654313072 bytes

database buffers 1694498816 bytes

redo buffers 20054016 bytes

database 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 -verbose

connecting to database...ok

determining 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 2017

11、 验证是否打补丁成功

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.0

14-sep-17 04.28.21.213333 am psu psu 12.1.0.1.160719

14-sep-17 04.28.32.004194 am psu psu 12.1.0.1.160719

14-sep-17 04.28.42.435304 am psu psu 12.1.0.1.160719

14-sep-17 04.28.53.797447 am psu psu 12.1.0.1.160719

14-sep-17 04.29.03.854827 am psu psu 12.1.0.1.160719

14-sep-17 04.29.14.465123 am psu psu 12.1.0.1.160719

14-sep-17 04.29.25.696294 am psu psu 12.1.0.1.160719

8 rows selected

[oracle@12 opatch]$ $oracle_home/opatch/opatch lsinventory

patch 23054354 : applied on thu sep 14 04:12:25 cst 2017

unique patch id: 20238050

sql> select count(*) from dba_objects where status<>'valid';

count(*)

----------

0

12、 启动监听

[oracle@12 opatch]$ lsnrctl start

[oracle@12 opatch]$ lsnrctl status