sitemap

RSS地图

收藏本站

设为首页

Oracle研究中心

当前位置:Oracle研究中心 > 故障案例 >

【学习笔记】使用TAR的方式迁移克隆Oracle数据库并完成版本升级

时间:2016-10-19 21:44   来源:Oracle研究中心   作者:HTZ   点击:

天萃荷净 tar安装数据库并从10.2.0.4.8升级到10.2.0.4.9.运维DBA反映在使用Linux tar来克隆迁移Oracle数据库后在升级版本时遇到问题.通过详细操作来讲解练习Oracle数据库目录的克隆迁移。
今天同事说tar安装的数据库在做打补丁的时候会出时候.原来还真没有注意过.一般tar安装的数据库.都是已经打好了补丁的。个人觉得他说的出问题.应该是指tar过来后.数据库使用的relink方式来编译了一次.而没有使用clone或者oui的方式来安装.在环境一样的时候.很多时候我们都只用了relink方式.这个要方便一些.下面的测试环境是

OS:RHEL 4.8 TO RHEL 5.4 OS:10.2.0.4.8 to 10.2.0.4.9

测试结果是能正常打补丁.也能正常回退。

1.源环境tar软件


建议使用root用户来tar包.我的环境.源环境与目标环境.存在OS版本不一样.用户的名字与id都不一样。

[root@rhel4 product]# pwd
/u01/app/oracle/product
[root@rhel4 product]# tar -czvf /soft/test.tar.gz 10.2.0

2.目标库上安装数据库


2.1 系统环境准备.由于这里只是测试.所以部分参数配置不合理
groupadd -g 500 dba
groupadd -g 501 oinstall
useradd -u 500 -g dba -G oinstall oracle
echo "oracle"|passwd oracle --stdin

echo "kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
net.ipv4.tcp_wmem = 262144 262144 262144
net.ipv4.tcp_rmem = 262144 262144 262144">>/etc/sysctl.conf

/etc/security/limits.conf
echo "oracle soft memlock 5242880
oracle hard memlock 524280
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 65536
oracle hard nofile 65536">> /etc/security/limits.conf


echo "session     required      pam_limits.so">>/etc/pam.d/login


export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db
export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs
export ORACLE_SID=rac1
export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$CRS_HOME/lib32:$ORA_CRS_HOME/lib32
export DISPLAY=192.168.100.1:0.0
set -o vi
stty erase ^h

[root@vxvm db_1]# tail -1 /etc/hosts
192.168.111.43 vxvm.htz.pw
2.2 修改文件的权限
[root@vxvm oracle]#  find . -group 210 -exec chgrp dba {} \;
chgrp: changing group of `./produce/10.2.0/db_1/ctx/lib/libicuuc.so.26': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/ctx/lib/libXML4CMessages.so.54': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/ctx/lib/libicudata.so': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/ctx/lib/libxml4c.so': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/ctx/lib/libXML4CMessages.so': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/ctx/lib/libxml4c.so.54': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/ctx/lib/libicuuc.so': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/ctx/lib/libicudata.so.26': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/bin/lbuilder': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/lib/liborasdkbase.so': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/lib/liborasdk.so': No such file or directory
chgrp: changing group of `./produce/10.2.0/db_1/lib32/ldflags': No such file or directory
[root@vxvm oracle]#  find . -user 211 -exec chown oracle  {} \;
chown: changing ownership of `./produce/10.2.0/db_1/ctx/lib/libicuuc.so.26': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/ctx/lib/libXML4CMessages.so.54': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/ctx/lib/libicudata.so': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/ctx/lib/libxml4c.so': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/ctx/lib/libXML4CMessages.so': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/ctx/lib/libxml4c.so.54': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/ctx/lib/libicuuc.so': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/ctx/lib/libicudata.so.26': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/bin/lbuilder': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/lib/liborasdkbase.so': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/lib/liborasdk.so': No such file or directory
chown: changing ownership of `./produce/10.2.0/db_1/lib32/ldflags': No such file or directory

[root@vxvm app]# chmod 777 oracle
[root@vxvm app]# ls -lrt
total 4
drwxrwxrwx 3 root root 4096 Jun  4 15:21 oracle
[root@vxvm app]# pwd
/u01/app
2.3 修改oracle用户组
[oracle@vxvm ~]$ cd $ORACLE_HOME/rdbms/lib
[oracle@vxvm lib]$ pwd
/u01/app/oracle/product/10.2.0/db_1/rdbms/lib

[oracle@vxvm lib]$ mv config.o config.o_backup
[oracle@vxvm lib]$  vi config.c
/*  SS_DBA_GRP defines the UNIX group ID for adminstrative access.  */
/*  Refer to the Installation and User's Guide for further information.  */

#define SS_DBA_GRP "dba"
#define SS_OPER_GRP "dba"

char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP};
2.4 编译oracle
[oracle@vxvm lib]$ make -f ins_rdbms.mk config.o
/usr/bin/gcc  -O3  -trigraphs -fPIC -I/u01/app/oracle/product/10.2.0/db_1/rdbms/demo -I/u01/app/oracle/product/10.2.0/db_1/rdbms/public -I/u01/app/oracle/product/10.2.0/db_1/plsql/public -I/u01/app/oracle/product/10.2.0/db_1/network/public -DLINUX -DORAX86_64 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -DSLTS_ENABLE -DSLMXMX_ENABLE -D_REENTRANT -DNS_THREADS -DLONG_IS_64 -fno-strict-aliasing -DSS_64BIT_SERVER      -c -o config.o config.c
[oracle@vxvm lib]$ make -f ins_rdbms.mk ioracle
chmod 755 /u01/app/oracle/product/10.2.0/db_1/bin

- Linking Oracle
rm -f /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/oracle
gcc  -o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/oracle -L/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ -L/u01/app/oracle/product/10.2.0/db_1/lib/ -L/u01/app/oracle/product/10.2.0/db_1/lib/stubs/   -Wl,-E `test -f /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/sskgpsmti.o && echo /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/sskgpsmti.o` /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/opimai.o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ssoraed.o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ttcsoi.o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/defopt.o  -Wl,--whole-archive -lperfsrv10 -Wl,--no-whole-archive /u01/app/oracle/product/10.2.0/db_1/lib/nautab.o /u01/app/oracle/product/10.2.0/db_1/lib/naeet.o /u01/app/oracle/product/10.2.0/db_1/lib/naect.o /u01/app/oracle/product/10.2.0/db_1/lib/naedhs.o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/config.o  -lserver10 -lodm10 -lnnet10 -lskgxp10 -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 -lhasgen10 -lcore10 -lskgxn2 -locr10 -locrb10 -locrutl10 -lhasgen10 -lcore10 -lskgxn2   -lclient10  -lvsn10 -lcommon10 -lgeneric10 -lknlopt `if /usr/bin/ar tv /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/libknlopt.a | grep xsyeolap.o > /dev/null 2>&1 ; then echo "-loraolap10" ; fi` -lslax10 -lpls10  -lplp10 -lserver10 -lclient10  -lvsn10 -lcommon10 -lgeneric10 `if [ -f /u01/app/oracle/product/10.2.0/db_1/lib/libavserver10.a ] ; then echo "-lavserver10" ; else echo "-lavstub10"; fi` `if [ -f /u01/app/oracle/product/10.2.0/db_1/lib/libavclient10.a ] ; then echo "-lavclient10" ; fi` -lknlopt -lslax10 -lpls10  -lplp10 -ljox10 -lserver10 -lclsra10 -ldbcfg10 -locijdbcst10 -lwwg  `cat /u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lmm -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10   -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `if /usr/bin/ar tv /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/libknlopt.a | grep "kxmnsd.o" > /dev/null 2>&1 ; then echo " " ; else echo "-lordsdo10"; fi` -lctxc10 -lctx10 -lzx10 -lgx10 -lctx10 -lzx10 -lgx10 -lordimt10 -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 -lsnls10 -lunls10  -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 -laio    `cat /u01/app/oracle/product/10.2.0/db_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/10.2.0/db_1/lib -lm    `cat /u01/app/oracle/product/10.2.0/db_1/lib/sysliblist` -ldl -lm   -L/u01/app/oracle/product/10.2.0/db_1/lib
/u01/app/oracle/product/10.2.0/db_1/lib//libcore10.a(lcd.o): In function `lcdprm':
lcd.c:(.text+0xb71): warning: the `gets' function is dangerous and should not be used.
mv -f /u01/app/oracle/product/10.2.0/db_1/bin/oracle /u01/app/oracle/product/10.2.0/db_1/bin/oracleO
mv /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/oracle /u01/app/oracle/product/10.2.0/db_1/bin/oracle
chmod 6751 /u01/app/oracle/product/10.2.0/db_1/bin/oracle

2.5 创建/etc/oraInst.loc
[root@vxvm soft]# cat /etc/oraInst.loc
inventory_loc=/u01/app/oracle/oraInventory

2.6 克隆安装数据库软件
[oracle@vxvm bin]$ cd $ORACLE_HOME/clone/bin
[oracle@vxvm bin]$ mkdir /u01/app/oracle/oraInventory
[oracle@vxvm bin]$ perl clone.pl ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME="OraDbName10gr2"
./runInstaller -silent -clone -waitForCompletion  "ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1" "ORACLE_HOME_NAME=OraDbName10gr2" -noConfig -nowait
Starting Oracle Universal Installer...

No pre-requisite checks found in oraparam.ini, no system pre-requisite checks will be executed.
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-06-04_03-28-19PM. Please wait ...Oracle Universal Installer, Version 10.2.0.4.0 Production
Copyright (C) 1999, 2008, Oracle. All rights reserved.

You can find a log of this install session at:
/u01/app/oracle/oraInventory/logs/cloneActions2013-06-04_03-28-19PM.log

[oracle@vxvm bin]$ perl clone.pl ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME="OraDbName10gr2"
./runInstaller -silent -clone -waitForCompletion  "ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1" "ORACLE_HOME_NAME=OraDbName10gr2" -noConfig -nowait
Starting Oracle Universal Installer...

No pre-requisite checks found in oraparam.ini, no system pre-requisite checks will be executed.
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-06-04_03-28-19PM. Please wait ...Oracle Universal Installer, Version 10.2.0.4.0 Production
Copyright (C) 1999, 2008, Oracle. All rights reserved.

You can find a log of this install session at:
/u01/app/oracle/oraInventory/logs/cloneActions2013-06-04_03-28-19PM.log
.................................................................................................... 100% Done.

Installation in progress (Tuesday, June 4, 2013 3:28:38 PM CST)
..........................................................................                                                      74% Done.
Install successful

Linking in progress (Tuesday, June 4, 2013 3:28:47 PM CST)

Link successful

Setup in progress (Tuesday, June 4, 2013 3:32:42 PM CST)
Setup successful

End of install phases.(Tuesday, June 4, 2013 3:32:53 PM CST)
WARNING:
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root script to run
/u01/app/oracle/product/10.2.0/db_1/root.sh
To execute the configuration scripts:
    1. Open a terminal window
    2. Log in as "root"
    3. Run the scripts

The cloning of OraDbName10gr2 was successful.
Please check '/u01/app/oracle/oraInventory/logs/cloneActions2013-06-04_03-28-19PM.log' for more details.
在root用户下面执行root.sh脚本

2.7 dbca创建数据库
[oracle@vxvm bin]$ export DISPLAY=192.168.111.1:0.0
[oracle@vxvm bin]$ dbca

dbca创建数据库成功

3 开始升级


3.1 查看现在的版本
[oracle@vxvm OPatch]$ ./opatch lsinventory
Invoking OPatch 10.2.0.5.1

Oracle Interim Patch Installer version 10.2.0.5.1
Copyright (c) 2010, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/10.2.0/db_1
Central Inventory : /u01/app/oracle/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 10.2.0.5.1
OUI version       : 10.2.0.4.0
OUI location      : /u01/app/oracle/product/10.2.0/db_1/oui
Log file location : /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch2013-06-04_15-41-55PM.log

Patch history file: /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2013-06-04_15-41-55PM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (2):

Oracle Database 10g                                                  10.2.0.1.0
Oracle Database 10g Release 2 Patch Set 3                            10.2.0.4.0
There are 2 products installed in this Oracle Home.


Interim patches (2) :

Patch  11724977     : applied on Mon Jan 07 13:44:17 CST 2013
Unique Patch ID:  13596298
   Created on 25 Mar 2011, 23:17:54 hrs PST8PDT
   Bugs fixed:
     9713537, 9655017, 9573054, 9654991, 9714832, 11725015, 10014012, 11787762
     11787763, 11787764, 10249540, 10014015, 11724977, 11787765, 11787766
     9952234, 9442335, 10014009, 11787767, 10248636, 10325885, 10013975
     10325878, 9173248, 8309642, 9678690, 7609058, 9952272, 9678695, 9678697
   This patch overlays patches:
     9352164
   This patch needs patches:
     9352164
   as prerequisites
数据库的版本是10.2.0.4.8.现在升级到10.2.0.4.9看报错不。

3.2 把软件解压到/tmp/目录
[oracle@vxvm 12419397]$ pwd
/tmp/12419397

3.3 停数据库与监听.如果有em这些也要停
[oracle@vxvm 12419397]$ export ORACLE_SID=test
[oracle@vxvm 12419397]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Jun 4 15:45:29 2013

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

oracleplus.net>shutdown abort;
ORACLE instance shut down.

3.3到补丁目录.开始opatch apply
[oracle@vxvm 12419397]$ /u01/app/oracle/product/10.2.0/db_1/OPatch/opatch apply
Invoking OPatch 10.2.0.5.1

Oracle Interim Patch Installer version 10.2.0.5.1
Copyright (c) 2010, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/10.2.0/db_1
Central Inventory : /u01/app/oracle/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 10.2.0.5.1
OUI version       : 10.2.0.4.0
OUI location      : /u01/app/oracle/product/10.2.0/db_1/oui
Log file location : /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch2013-06-04_15-45-57PM.log

Patch history file: /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt

ApplySession applying interim patch '12419397' to OH '/u01/app/oracle/product/10.2.0/db_1'
Interim patch 12419397 is a superset of the patch(es) [  11724977 ] in the Oracle Home
OPatch will rollback the subset patches and apply the given patch.

Running prerequisite checks...
Patch 12419397: Optional component(s) missing : [ oracle.rdbms.dv, 10.2.0.4.0 ] , [ oracle.rdbms.dv.oc4j, 10.2.0.4.0 ]
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]:  N
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

OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/10.2.0/db_1')

Is the local system ready for patching  [y|n]
y
User Responded with: Y
Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '12419397' for restore. This might take a while...
Backing up files affected by the patch '11724977' for restore. This might take a while...
ApplySession rolling back interim patch '11724977' from OH '/u01/app/oracle/product/10.2.0/db_1'
Execution of 'sh /u01/app/oracle/product/10.2.0/db_1/.patch_storage/11724977_Mar_25_2011_23_17_54/original_patch/custom/scripts/pre -rollback 11724977 ':

Return Code = 0

Patching component oracle.rdbms, 10.2.0.4.0...
Updating archive file "/u01/app/oracle/product/10.2.0/db_1/lib/libserver10.a"  with "lib/libserver10.a/kwqit.o"
Updating archive file "/u01/app/oracle/product/10.2.0/db_1/lib/libserver10.a"  with "lib/libserver10.a/kkzl.o"
Updating archive file "/u01/app/oracle/product/10.2.0/db_1/lib/libserver10.a"  with "lib/libserver10.a/kkxe.o"
Updating archive file "/u01/app/oracle/product/10.2.0/db_1/lib/libserver10.a"  with "lib/libserver10.a/kpolon.o"
Updating archive file "/u01/app/oracle/product/10.2.0/db_1/lib/libserver10.a"  with "lib/libserver10.a/kkxs.o"
Updating archive file "/u01/app/oracle/product/10.2.0/db_1/lib/libserver10.a"  with "lib/libserver10.a/kza.o"
Updating archive file "/u01/app/oracle/product/10.2.0/db_1/lib/libserver10.a"  with "lib/libserver10.a/kzvdve.o"
Deleting file "/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/bundledata_OPSU.xml"
...................................................
Running make for target itnslsnr
Running make for target client_sharedlib
ApplySession adding interim patch '12419397' to inventory

Verifying the update...
Inventory check OK: Patch ID 12419397 is registered in Oracle Home inventory with proper meta-data.
Files check OK: Files from Patch ID 12419397 are present in Oracle Home.

The local system has been patched and can be restarted.
--------------------------------------------------------------------------------
The following warnings have occurred during OPatch execution:
1) OUI-67620:Interim patch 12419397 is a superset of the patch(es) [  11724977 ] in the Oracle Home
--------------------------------------------------------------------------------
OPatch Session completed with warnings.

OPatch completed with warnings.

3.4 运行catbundle.sql
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle.sql opsu apply
SQL> @utlrp.sql
SQL> QUIT

oracleplus.net>select * from dba_registry_history
  2  ;

ACTION_TIME                    ACTION     NAMESPACE  VERSION            ID BUNDLE_SERIES   COMMENTS
------------------------------ ---------- ---------- ---------- ---------- --------------- ------------------------------
04-JUN-13 03.56.09.350649 PM   APPLY      SERVER     10.2.0.4            5 OPSU            PSU 10.2.0.4.9

1 row selected.

oracleplus.net>select comp_name, version, status from sys.dba_registry
  2  ;

COMP_NAME                                          VERSION    STATUS
-------------------------------------------------- ---------- ----------------------
Oracle Database Catalog Views                      10.2.0.4.0 VALID
Oracle Database Packages and Types                 10.2.0.4.0 VALID
Oracle Workspace Manager                           10.2.0.4.3 VALID
JServer JAVA Virtual Machine                       10.2.0.4.0 VALID
Oracle XDK                                         10.2.0.4.0 VALID
Oracle Database Java Packages                      10.2.0.4.0 VALID
Oracle Expression Filter                           10.2.0.4.0 VALID
Oracle Data Mining                                 10.2.0.4.0 VALID
Oracle Text                                        10.2.0.4.0 VALID
Oracle XML Database                                10.2.0.4.0 VALID
Oracle Rules Manager                               10.2.0.4.0 VALID
Oracle interMedia                                  10.2.0.4.0 VALID
OLAP Analytic Workspace                            10.2.0.4.0 VALID
Oracle OLAP API                                    10.2.0.4.0 VALID
OLAP Catalog                                       10.2.0.4.0 VALID
Spatial                                            10.2.0.4.0 VALID
Oracle Enterprise Manager                          10.2.0.4.0 VALID

3.5 编译对象
[oracle@vxvm ~]$ cd $ORACLE_HOME/cpu/view_recompile
[oracle@vxvm view_recompile]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Jun 4 17:21:50 2013

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

oracleplus.net>@recompile_precheck_jan2008cpu.sql

Running precheck.sql...

Number of views to be recompiled :2062
-----------------------------------------------------------------------

Number of objects to be recompiled :4149
Please follow the README.txt instructions for running viewrecomp.sql

PL/SQL procedure successfully completed.

oracleplus.net>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
oracleplus.net>startup upgrade
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  2083368 bytes
Variable Size             117442008 bytes
Database Buffers          159383552 bytes
Redo Buffers                6303744 bytes
Database mounted.
Database opened.
oracleplus.net>@view_recompile_jan2008cpu.sql
oracleplus.net>@view_recompile_jan2008cpu.sql

PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


1 row created.


Commit complete.

No. of Invalid Objects is :244
Please refer to README.html to for instructions on valhttp://www.oracleplus.netidating these objects

PL/SQL procedure successfully completed.

Logfile for the current viewrecomp.sql session is : vcomp_TEST_04Jun2013_17_23_18.log
oracleplus.net>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
oracleplus.net>startup
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  2083368 bytes
Variable Size             138413528 bytes
Database Buffers          138412032 bytes
Redo Buffers                6303744 bytes
Database mounted.
Database opened.

3.6 无效对象
oracleplus.net>@ /rdbms/admin/utlrp

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN  2013-06-04 17:31:20

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.
DOC>
DOC>   Use the following queries to track recompilation progress:
DOC>
DOC>   1. Query returning the number of invalid objects remaining. This
DOC>      number should decrease with time.
DOC>         SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC>   2. Query returning the number of objects compiled so far. This number
DOC>      should increase with time.
DOC>         SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC>   This script automatically chooses serial or parallel recompilation
DOC>   based on the number of CPUs available (parameter cpu_count) multiplied
DOC>   by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC>   On RAC, this number is added across all RAC nodes.
DOC>
DOC>   UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC>   recompilation. Jobs are created without instance affinity so that they
DOC>   can migrate across RAC nodes. Use the following queries to verify
DOC>   whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC>   1. Query showing jobs created by UTL_RECOMP
DOC>         SELECT job_name FROM dba_scheduler_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC>   2. Query showing UTL_RECOMP jobs that are running
DOC>         SELECT job_name FROM dba_scheduler_running_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#

PL/SQL procedure successfully completed.

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END  2013-06-04 17:32:03

PL/SQL procedure successfully completed.

DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#

OBJECTS WITH ERRORS
-------------------
                  0

DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#

ERRORS DURING RECOMPILATION
---------------------------
                          0

PL/SQL procedure successfully completed.
升级成功.没有出现报错。

4 回退过程


4.1 停数据库.停监听.停EM
oracleplus.net>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

4.2 回退软件部分
[oracle@vxvm 12419397]$ /u01/app/oracle/product/10.2.0/db_1/OPatch/opatch rollback -id 12419397
..............................
Patching component oracle.sysman.repository.db, 10.2.0.4.0...
Copying file to "/u01/app/oracle/product/10.2.0/db_1/sysman/admin/emdrep/sql/db/latest/eml/eml_pkgbodys.sql"
Copying file to "/u01/app/oracle/product/10.2.0/db_1/sysman/admin/emdrep/sql/db/latest/eml/eml_pkgdefs.sql"
Copying file to "/u01/app/oracle/product/10.2.0/db_1/sysman/admin/emdrep/sql/db/latest/policy/default_policy_setup.sql"
Running make for target ioracle
Running make for target client_sharedlib
Running make for target itnslsnr
Running make for target client_sharedlib
RollbackSession removing interim patch '12419397' from inventory

The local system has been patched and can be restarted.

4.3 回退数据库与无效对象编译
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle_OPSU_TEST_ROLLBACK.sql
SQL> @utlrp.sql
SQL> QUIT

OPatch succeeded.

oracleplus.net>select * from dba_registry_history;

ACTION_TIME                    ACTION     NAMESPACE  VERSION            ID BUNDLE_SERIES   COMMENTS
------------------------------ ---------- ---------- ---------- ---------- --------------- ------------------------------
04-JUN-13 03.56.09.350649 PM   APPLY      SERVER     10.2.0.4            5 OPSU            PSU 10.2.0.4.9
04-JUN-13 05.24.28.814302 PM   CPU                                 6452863                 view recompilation
04-JUN-13 05.44.52.514759 PM   ROLLBACK   SERVER     10.2.0.4            5 OPSU            PSU 10.2.0.4.9
4.4 查看数据库的版本.已经回退到10.2.0.4这个版本去了
[oracle@vxvm 12419397]$ /u01/app/oracle/product/10.2.0/db_1/OPatch/opatch lsinventory
Invoking OPatch 10.2.0.5.1

Oracle Interim Patch Installer version 10.2.0.5.1
Copyright (c) 2010, Oracle Corporation.  All rights reserved.

Oracle Home       : /u01/app/oracle/product/10.2.0/db_1
Central Inventory : /u01/app/oracle/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 10.2.0.5.1
OUI version       : 10.2.0.4.0
OUI location      : /u01/app/oracle/product/10.2.0/db_1/oui
Log file location : /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch2013-06-04_17-48-59PM.log

Patch history file: /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2013-06-04_17-48-59PM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (2):

Oracle Database 10g                                                  10.2.0.1.0
Oracle Database 10g Release 2 Patch Set 3                            10.2.0.4.0
There are 2 products installed in this Oracle Home.


Interim patches (1) :

Patch  9352164      : applied on Mon Jan 07 13:33:54 CST 2013
Unique Patch ID:  12307477
   Created on 1 Apr 2010, 11:33:14 hrs PST8PDT
整个打补丁与回退都成功了.并没有出现报错

本文固定链接: http://www.htz.pw/2013/06/04/tar%e5%ae%89%e8%a3%85%e6%95%b0%e6%8d%ae%e5%ba%93%e5%b9%b6%e4%bb%8e10-2-0-4-8%e5%8d%87%e7%ba%a7%e5%88%b010-2-0-4-9.html | 认真就输

--------------------------------------ORACLE-DBA----------------------------------------

最权威、专业的Oracle案例资源汇总之【学习笔记】使用TAR的方式迁移克隆Oracle数据库并完成版本升级

本文由大师惜分飞原创分享,网址:http://www.oracleplus.net/arch/1004.html

Oracle研究中心

关键词:

Oracle所有目录进行迁移案例

Oracle数据库使用的relink方式来编译一次

如何使用tar的方式安装迁移克隆Oracle数据库

tar安装数据库后升级报错