ITPub博客

首页 > 数据库 > Oracle > 单机实验 补丁

单机实验 补丁

原创 Oracle 作者:s相濡以沫y 时间:2019-01-31 11:35:35 0 删除 编辑

实验 版本

centos 6.5 

数据库:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit 

所需工具及软件:

opatch: p6880880_112000_Linux-x86-64.zip

DB SCU: p28729262_112040_Linux-x86-64.zip

[oracle@oracle01 ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 17 09:16:01 2019


Copyright (c) 1982, 2013, Oracle.  All rights reserved.



Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> set linesize 500 pagesize 600

col COMP_NAME for a30

select COMP_ID,COMP_NAME,VERSION,STATUS from DBA_REGISTRY;            #查看当前所以组件的信息


COMP_ID       COMP_NAME                  VERSION     STATUS         

------------------------------ ------------------------------ ------------------------------ --------------------------------------------

OWB OWB                       11.2.0.4.0      VALID

APEX        Oracle Application Express     3.2.1.00.12      VALID

EM        Oracle Enterprise Manager      11.2.0.4.0              VALID

AMD       OLAP Catalog                 11.2.0.4.0             VALID

SDO        Spatial                   11.2.0.4.0      VALID

ORDIM         Oracle Multimedia             11.2.0.4.0             VALID

XDB        Oracle XML Database           11.2.0.4.0      VALID

CONTEXT    Oracle Text                 11.2.0.4.0      VALID

EXF        Oracle Expression Filter       11.2.0.4.0      VALID

RUL        Oracle Rules Manager           11.2.0.4.0      VALID

OWM        Oracle Workspace Manager       11.2.0.4.0      VALID

CATALOG    Oracle Database Catalog Views  11.2.0.4.0      VALID

CATPROC    Oracle Database Packages and T 11.2.0.4.0      VALID

       ypes


JAVAVM    JServer JAVA Virtual Machine   11.2.0.4.0      VALID

XML        Oracle XDK                   11.2.0.4.0      VALID

CATJAVA    Oracle Database Java Packages  11.2.0.4.0      VALID

APS        OLAP Analytic Workspace       11.2.0.4.0      VALID

XOQ        Oracle OLAP API             11.2.0.4.0      VALID


18 rows selected.


SQL> set linesize 500 pagesize 600

col ACTION_TIME for a30

col COMMENTS for a30

select ACTION_TIME, ACTION,version, COMMENTS from sys.DBA_REGISTRY_HISTORY;SQL> SQL> SQL> 


ACTION_TIME        ACTION       VERSION      COMMENTS

------------------------------ ------------------------------ ------------------------------ ------------------------------

24-AUG-13 12.03.45.119862 PM   APPLY       11.2.0.4      Patchset 11.2.0.2.0

03-DEC-18 11.30.45.641934 AM   APPLY       11.2.0.4      Patchset 11.2.0.2.0


SQL> select count(*) from dba_objects where status<>'VALID';        #所以无效的信息


  COUNT(*)

----------

0


SQL> quit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@oracle01 ~]$ 

[oracle@oracle01 ~]$ mkdir opatch

[oracle@oracle01 ~]$ cd opatch/

[oracle@oracle01 opatch]$ ls

[oracle@oracle01 opatch]$ pwd

/home/oracle/opatch

[oracle@oracle01 opatch]$ ll

total 251420

-rw-r--r-- 1 oracle oinstall 144375808 Jan 17 09:27 p28729262_112040_Linux-x86-64.zip

-rw-r--r-- 1 oracle oinstall 113078049 Jan 17 09:27 p6880880_112000_Linux-x86-64.zip

[oracle@oracle01 opatch]$ su root

Password: 

[root@oracle01 opatch]#  mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch.old.opatch

[root@oracle01 opatch]# pwd

/home/oracle/opatch

[root@oracle01 opatch]# su - oracle

[oracle@oracle01 ~]$ ls

Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  database  opatch  p13390677_112040_Linux-x86-64_1of7.zip  p13390677_112040_Linux-x86-64_2of7.zip

[oracle@oracle01 ~]$ cd /home/oracle/opatch/

[oracle@oracle01 opatch]$ ls

p28729262_112040_Linux-x86-64.zip  p6880880_112000_Linux-x86-64.zip

[oracle@oracle01 opatch]$ ll

total 313092

-rw-r--r-- 1 oracle oinstall 207527203 Jan 17 09:28 p28729262_112040_Linux-x86-64.zip

-rw-r--r-- 1 oracle oinstall 113078049 Jan 17 09:27 p6880880_112000_Linux-x86-64.zip

[oracle@oracle01 opatch]$ 

[oracle@11g opatch]$ pwd

/home/oracle/opatch

[oracle@11g opatch]$ unzip p21352635_112040_Linux-x86-64.zip

[oracle@11g opatch]$ unzip p6880880_112000_Linux-x86-64.zip

[oracle@oracle01 opatch]$ su root

Password: 

[root@oracle01 opatch]# pwd

/home/oracle/opatch

[root@oracle01 opatch]# 

[root@oracle01 opatch]# cd

[root@oracle01 ~]# cd /home/oracle/opatch/

[root@oracle01 opatch]# ls

28729262  OPatch  PatchSearch.xml  p28729262_112040_Linux-x86-64.zip  p6880880_112000_Linux-x86-64.zip

[root@oracle01 opatch]# [root@oracle01 opatch]# cd $ORACLE_HOME 

[root@oracle01 dbhome_1]# ls

EMStage            ccr          crs    dbs          dv     install        jdbc  lib           mgw      olap         oui    precomp   scheduler     srvm             ucp  xdk

OPatch.old.opatch  cdata        csmig  dc_ocm       emcli  instantclient  jdev  listener.log  network  opmn         owb    racg      slax          startup.log      uix

apex               cfgtoollogs  css    deinstall    has    inventory      jdk   log           nls      oraInst.loc  owm    rdbms     sqldeveloper  suptools         usm

assistants         clone        ctx    demo         hs     j2ee           jlib  md            oc4j     oracore      perl   relnotes  sqlj          sysman           utl

bin                config       cv     diagnostics  ide    javavm         ldap  mesg          odbc     ord          plsql  root.sh   sqlplus       timingframework  wwg

[root@oracle01 dbhome_1]# pwd

/u01/app/oracle/product/11.2.4/dbhome_1

[root@oracle01 dbhome_1]# cd

[root@oracle01 ~]# cd /home/oracle/opatch/

[root@oracle01 opatch]# ls

28729262  OPatch  PatchSearch.xml  p28729262_112040_Linux-x86-64.zip  p6880880_112000_Linux-x86-64.zip

[root@oracle01 opatch]# mv OPatch /u01/app/oracle/product/11.2.4/dbhome_1


--oracle用户查看 opatch 工具是否替换正确

[oracle@oracle01 ~]$ /u01/app/oracle/product/11.2.4/dbhome_1/OPatch/opatch version

OPatch Version: 11.2.0.3.20


OPatch succeeded.

3. 测试兼容性, 如果之前没有打过,这步也可以忽略。

[oracle@oracle01 OPatch]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/oracle/opatch/28729262 -oh $ORACLE_HOME 

Oracle Interim Patch Installer version 11.2.0.3.20

Copyright (c) 2019, Oracle Corporation.  All rights reserved.


PREREQ session


Oracle Home       : /u01/app/oracle/product/11.2.4/dbhome_1

Central Inventory : /u01/app/oraInventory

   from           : /u01/app/oracle/product/11.2.4/dbhome_1/oraInst.loc

OPatch version    : 11.2.0.3.20

OUI version       : 11.2.0.4.0

Log file location : /u01/app/oracle/product/11.2.4/dbhome_1/cfgtoollogs/opatch/opatch2019-01-17_09-59-26AM_1.log


Invoking prereq "checkconflictagainstohwithdetail"


Prereq "checkConflictAgainstOHWithDetail" passed.


OPatch succeeded.

[oracle@oracle01 OPatch]$ 

4. 为数据库做冷备份

[oracle@oracle01 ~]$ mkdir -p /home/oracle/rmanbak/

[oracle@oracle01 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jan 17 10:07:43 2019


Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


connected to target database: VDEDU (DBID=4278199980, not open)

RMAN> run {

shutdown immediate;

startup mount;

allocate channel c1 type disk;

allocate channel c2 type disk;

backup full tag='db_full_bak' database format '/home/oracle/rmanbak/full_cold_%d_%s.bak';

alter database open;

}

使用root用户备份oracle_home (将#ORACLE_HOME上级目录整个备份)

tar -zcvpf db_20170319.tar.gz dbhome_1/


5. 关闭数据库实例及相关进程 (静态监听、动态监听、EOM、相关服务)

--停止数据库外部进程


[oracle@oracle01 ~]$ su - root

Password: 

[root@oracle01 ~]# ps -ef|grep -v grep |grep LOCAL=NO|awk '{print $2}'|xargs kill -9 

[root@oracle01 ~]# su - oracle

[oracle@oracle01 ~]$ sqlplus / as sysdba

SQL> shutdown immediate;


[oracle@oracle01 ~]$ cd /u01/app/oracle/product/11.2.4/dbhome_1/network/admin/

listener.ora  samples/      shrept.lst    tnsnames.ora  

[oracle@oracle01 ~]$ cat /u01/app/oracle/product/11.2.4/dbhome_1/network/admin/listener.ora 

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.4/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.


ADR_BASE_VDEDU = /u01/app/oracle


VDEDU =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = oracle01)(PORT = 1521))

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

  )



[oracle@11g rmanbak]$ lsnrctl stop

[oracle@11g rmanbak]$ lsnrctl status

[oracle@11g rmanbak]$ ps -ef |grep ora_|grep -v grep

[oracle@11g rmanbak]$ netstat -an |grep 1521

[oracle@11g rmanbak]$ netstat -an |grep 1158


6.oracle database 打补丁

[oracle@oracle01 ~]$ $ORACLE_HOME/OPatch/opatch napply -oh $ORACLE_HOME -local /home/oracle/opatch/28729262 

Do you want to proceed? [y|n]

y

User Responded with: Y

All checks passed.

Provide your email address to be informed of security issues, install and

initiate Oracle Configuration Manager. Easier for you if you use your My

Oracle Support Email address/User Name.

Visit http://www.oracle.com/support/policies.html for details.

Email address/User Name:


You have not provided an email address for notification of security issues.

Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]: y


Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.

(Oracle Home = '/home/oracle/app/oracle/product/11.2.0.4/dbhome_1')


Is the local system ready for patching? [y|n]

y

User Responded with: Y

Backing up files...                               #以下是补丁内容

    .......

OPatch found the word "error" in the stderr of the make command.

Please look at this stderr. You can re-run this make command.

Stderr output:

chmod: changing permissions of /u01/app/oracle/product/11.2.4/dbhome_1/bin/extjobO: Operation not permitted

make: [iextjob] Error 1 (ignored)

successfully applied.

OPatch Session completed with warnings.

Log file location: /u01/app/oracle/product/11.2.4/dbhome_1/cfgtoollogs/opatch/opatch2019-01-17_10-21-13AM_1.log


OPatch completed with warnings.


7. 查看打补丁情况:

[oracle@oracle01 ~]$ /u01/app/oracle/product/11.2.4/dbhome_1/OPatch/opatch lsinv



Oracle Interim Patch Installer version 11.2.0.3.20

Copyright (c) 2019, Oracle Corporation.  All rights reserved.



Oracle Home       : /u01/app/oracle/product/11.2.4/dbhome_1

Central Inventory : /u01/app/oraInventory

   from           : /u01/app/oracle/product/11.2.4/dbhome_1/oraInst.loc

OPatch version    : 11.2.0.3.20

OUI version       : 11.2.0.4.0

Log file location : /u01/app/oracle/product/11.2.4/dbhome_1/cfgtoollogs/opatch/opatch2019-01-17_10-33-41AM_1.log


Lsinventory Output file location : /u01/app/oracle/product/11.2.4/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2019-01-17_10-33-41AM.txt


--------------------------------------------------------------------------------

Local Machine Information::

Hostname: oracle01

ARU platform id: 226

ARU platform description:: Linux x86-64


Installed Top-level Products (1): 


Oracle Database 11g                                                  11.2.0.4.0

There are 1 products installed in this Oracle Home.



Interim patches (1) :


Patch  28729262     : applied on Thu Jan 17 10:27:42 CST 2019

Unique Patch ID:  22664181

Patch description:  "Database Patch Set Update : 11.2.0.4.190115 (28729262)"


8. 升级数据库数据字典、编译无效对象 。 

数据库启动,并加载修改SQL Files到数据库

[root@oracle01 ~]# sqlplus / as sysdba

SQL> startup;

-- 升级数据库数据字典

SQL> @?/rdbms/admin/catbundle.sql psu apply

省略大量输出

。。。。。。

SQL> SET echo off     ## 输出末尾内容

Check the following log file for errors:

/u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_VDEDU_APPLY_2019Jan17_10_38_27.log   


--编译无效对象的脚本

SQL>@?/rdbms/admin/utlrp.sql


9. 查看 PSU 更新信息

执行完后我们可以查到PSU更新信息:

set line 150

col ACTION_TIME for a30

col ACTION for a8

col NAMESPACE for a8

col VERSION for a10

col BUNDLE_SERIES for a5

col COMMENTS for a20

select * from dba_registry_history;

ACTION_TIME                    ACTION   NAMESPAC VERSION            ID BUNDL COMMENTS

------------------------------ -------- -------- ---------- ---------- ----- --------------------

24-AUG-13 12.03.45.119862 PM   APPLY    SERVER   11.2.0.4            0 PSU   Patchset 11.2.0.2.0

03-DEC-18 11.30.45.641934 AM   APPLY    SERVER   11.2.0.4            0 PSU   Patchset 11.2.0.2.0

17-JAN-19 10.39.18.887520 AM   APPLY    SERVER   11.2.0.4       190115 PSU   PSU 11.2.0.4.190115


--查看无效对象

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

COUNT(*)

----------

      0

      

--- 查看监听是否正常

[oracle@oracle01 ~]$ lsnrctl status

[oracle@oracle01 ~]$ lsnrctl start           #启动监听,开放对外服务


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31562969/viewspace-2565311/,如需转载,请注明出处,否则将追究法律责任。

上一篇: sql 性能优化
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2018-11-20

  • 博文量
    24
  • 访问量
    12498