ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 11.2.0.1 升级到11.2.0.2

11.2.0.1 升级到11.2.0.2

原创 Linux操作系统 作者:shilei1 时间:2012-01-31 07:51:02 0 删除 编辑
11.2.0.1 升级到11.2.0.2
2011-11-18 17:01

--小斌

从11.2.0.2 版本开始往后,ORACLE版本将不再推出零碎的补丁集了,而是通过完整的安装包直接升级版本。仍然可以通过in-place upgrade方式把新版本直接安装覆盖原来的ORACLE_HOME目录,但oracle将再推荐这种做法,因为需要更多的停机时间。ORACLE推荐的是out-of-place upgrade方式,通过安装在新的ORACLE_HOME目录,完成升级后久得数据库将会迁移到新的数据库目录下。

准备升级的服务器环境是:

OS CentOS release 5.5

database oracle 11.2.0.1 单节点

升级之前的准备工作:

1.备份数据库

2.准备新的ORACLE_HOME

3.运行patchset,升级oracle 软件

4.运行dbua 或者脚本升级实例

5.检查升级后的版本信息和无效对象

备份数据库

常言说有备无患,没有备份则无从回退。

[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun Feb 10 23:47:20 2002

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

connected to target database: SZCERT (DBID=1077254391)

RMAN> backup as copy database format '/u01/backup/2011_11_18_%U';

Starting backup at 2002-02-11 01:11:41
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
channel ORA_DISK_1: starting datafile copy

......

......

如果是采用in-place upgrade方式升级,则必须备份ORACLE_HOME目录,以防出现异常时方便回退。

升级安装包

我下载的安装包如下

p10098816_112020_LINUX_1of7.zip
p10098816_112020_LINUX_2of7.zip 前2个文件是database
p10098816_112020_LINUX_3of7.zip 第3个是Grid
p10098816_112020_LINUX_4of7.zip 第4个是Client
p10098816_112020_LINUX_5of7.zip 第5个是gateways
p10098816_112020_LINUX_6of7.zip 第6个是examples
p10098816_112020_LINUX_7of7.zip 第7个是deinstall
注:共5G多真X够大的,真是不吐不快。这些安装包都是独立包含各个组件,亲下载的时候可以按需要选择下载。

解压

unzip p10098816_112020_LINUX_1of7.zip

unzip p10098816_112020_LINUX_2of7.zip

unzip p10098816_112020_LINUX_3of7.zip
重复...重复...

1号和2号压缩包解压后会合并在一起

[oracle@localhost 11.2.0.2upgrade]$ ll
total 4430800
drwxr-xr-x 6 oracle oinstall 4096 Nov 12 2010 client
drwxr-xr-x 8 oracle oinstall 4096 Nov 16 2010 database
drwxr-xr-x 6 oracle oinstall 4096 Nov 12 2010 examples
drwxr-xr-x 8 oracle oinstall 4096 Nov 12 2010 grid
-rw-rw-r-- 1 oracle oinstall 1322952768 Nov 18 2011 p10098816_112020_LINUX_1of7.zip
-rw-rw-r-- 1 oracle oinstall 1050532828 Nov 17 2011 p10098816_112020_LINUX_2of7.zip
-rw-rw-r-- 1 oracle oinstall 864428964 Nov 18 2011 p10098816_112020_LINUX_3of7.zip
-rw-rw-r-- 1 oracle oinstall 665723921 Nov 17 2011 p10098816_112020_LINUX_4of7.zip
-rw-rw-r-- 1 oracle oinstall 512243685 Nov 17 2011 p10098816_112020_LINUX_6of7.zip
-rw-rw-r-- 1 oracle oinstall 116762007 Nov 17 2011 p10098816_112020_LINUX_7of7.exe

准备新的ORACLE_HOME目录

[oracle@localhost product]$ cd /u01/oracle/product/
[oracle@localhost product]$ ll
total 4
drwxr-xr-x 3 oracle oinstall 4096 Sep 17 2011 11.2.0

再创建一个新的ORACLE_HOME目录

[oracle@localhost product]$ mkdir -p 11.2.0.2/db_1

[oracle@localhost product]$ ll
total 8
drwxr-xr-x 3 oracle oinstall 4096 Sep 17 2011 11.2.0
drwxr-xr-x 2 oracle oinstall 4096 Feb 13 19:41 11.2.0.2

运行升级包


NEXT

因为我的升级包已经下载完成了,所以我选择了“skip software updates”,也可以选择上面的选项下载,但是需要metalink帐号。


从一,二两个选项来看,这个安装包也可以直接安装数据库,正由于这样,才使得升级那么方便。


选择软件运行的语言,我觉得English看得比较习惯。


选择“enterprise edition”


路径为新建的ORACLE_HOME。


NEXT。


我的服务器就是烂,内存不足的错误可以忽略。。。 点上"ignore all"NEXT。

准备就绪。


upgrade ing...

经过若干分钟后...


这里提示需要run一个脚本。

运行脚本

以root身份运行

[root@localhost ~]# cd /u01/oracle/product/11.2.0.2/db_1/
[root@localhost db_1]# bash root.sh
Running Oracle 11g root script...

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/oracle/product/11.2.0.2/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying oraenv to /usr/local/bin ...
The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying coraenv to /usr/local/bin ...

Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions.


然后进度继续走。


完成。

然后提示我配置监听,,监听原来已经有了,所以不配置了。




由于刚刚我们取消了listener的配置,所以造成了“配置错误”,在安装完之后,就不再显示DBUA来升级实例。所以要通过手工升级实例。

修改环境参数

修改系统概要文件的ORACLE_HOME参数

[oracle@localhost ~]$ vi .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH


umask 022
export ORACLE_HOSTNAME=szcert
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=/u01/oracle/product/11.2.0.2/db_1
export ORACLE_SID=szcert
export PATH=.:/u01/oracle/product/11.2.0.2/db_1/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
".bash_profile" 25L, 560C written

注:要使之生效。

[oracle@localhost ~]$ source /home/oracle/.bash_profile

别忘了etc/oratab文件

[oracle@localhost etc]$ vi oratab

#

# This file is used by ORACLE utilities. It is created by root.sh
<忽略显示>
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
szcert:/u01/oracle/product/11.2.0.2/db_1:N

转移参数文件

[oracle@localhost etc]$ cd /u01/oracle/product/11.2.0
11.2.0/ 11.2.0.2/
[oracle@localhost etc]$ cd /u01/oracle/product/11.2.0/db_1/dbs/
[oracle@localhost dbs]$ ll
total 9560
-rw-rw---- 1 oracle oinstall 1544 Feb 11 00:59 hc_szcert.dat
-rw-r--r-- 1 oracle oinstall 2851 May 15 2009 init.ora
-rw-r----- 1 oracle oinstall 24 Sep 17 2011 lkSZCERT
-rw-r----- 1 oracle oinstall 1536 Sep 17 2011 orapwszcert
drwx------ 2 oracle oinstall 4096 Sep 17 2011 peshm_szcert_0
-rw-r----- 1 oracle oinstall 9748480 Feb 11 01:14 snapcf_szcert.f
-rw-r----- 1 oracle oinstall 2560 Feb 11 01:14 spfileszcert.ora
[oracle@localhost dbs]$ cp -R * /u01/oracle/product/11.2.0.2/db_1/dbs/

转移网络配置文件

[oracle@localhost db_1]$ cd network/admin
[oracle@localhost network]$ ll
total 36
drwxr-xr-x 3 oracle oinstall 4096 Sep 17 2011 admin
drwxr-xr-x 2 oracle oinstall 4096 Sep 17 2011 doc
drwxr-xr-x 4 oracle oinstall 4096 Sep 17 2011 install
drwxr-xr-x 2 oracle oinstall 4096 Sep 17 2011 jlib
drwxr-xr-x 2 oracle oinstall 4096 Sep 17 2011 lib
drwxrwx--- 2 oracle oinstall 4096 Sep 17 2011 log
drwxr-xr-x 2 oracle oinstall 4096 Sep 17 2011 mesg
drwxr-xr-x 4 oracle oinstall 4096 Sep 17 2011 tools
drwxrwx--- 2 oracle oinstall 4096 Sep 17 2011 trace
[oracle@localhost network]$ cd admin/
[oracle@localhost admin]$ cp -R * /u01/oracle/product/11.2.0.2/db_1/network/admin/

运行升级脚本

有两种方式升级INSTANCE,使用DBUA或者通过手工升级。DBUA我们这里暂且不讨论,我们通过手工升级来一步一步了解过中的来龙去脉。

为了更新数据库升级信息。需要管理员权限运行。

[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.2.0 Production on Wed Feb 13 23:33:28 2002 #在我们登录SQLPLUS时发现已经为新版本。

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

SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system

发现错误。

google了一下回来,原来这个错误在11R会出现,原因是11g中增加了MEMORY_TARGET参数新特性。简单点来说就是MEMORY_TARGET参数大于操作系统/dev/shm大小,/dev/shm是临时文件系统,这个文件系统就是类似ramdisk功能,区别是它是文件系统,而ramdisk是需要加载,并且是块设备。

我们来解决这个问题。

调节shm大小

shm在没有设置size的情况下,默认是内存大小的一半,我这个服务器是台老机器,内存只有1G,怪不得会出这种错误。所以我们要把shm调大。

[root@localhost dbs]# vi /etc/fstab

/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults,size=1024M 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
"/etc/fstab" 7L, 534C

重启。

[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
75385912 30241676 41253036 43% /
/dev/hdd1 101086 12107 83760 13% /boot
tmpfs 1048576 0 1048576 0% /dev/shm

搞定。

尝试启动实例。

SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 464519168 bytes
Fixed Size 1344896 bytes
Variable Size 356518528 bytes
Database Buffers 100663296 bytes
Redo Buffers 5992448 bytes
Database mounted.
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
Process ID: 2222
Session ID: 1 Serial number: 5
SQL> startup UPGRADE
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist
SQL> shutdown
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist

注:启动实例要用UPGRADE参数,我这里没用所以就发生了错误,而且进程也挂起了。
退出oracle用户的session,重新登录sqlplus.

运行第一个脚本utlu112i.sql

[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 14 00:24:17 2002

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

SQL> startup UPGRADE
ORA-01031: insufficient privileges
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup UPGRADE
ORACLE instance started.

Total System Global Area 464519168 bytes
Fixed Size 1344896 bytes
Variable Size 356518528 bytes
Database Buffers 100663296 bytes
Redo Buffers 5992448 bytes
Database mounted.
Database opened.

SQL> @$ORACLE_HOME/rdbms/admin/utlu112i.sql
Oracle Database 11.2 Pre-Upgrade Information Tool 02-14-2002 00:26:49
Script. Version: 11.2.0.2.0 Build: 001
**********************************************************************
Database:
**********************************************************************
--> name: SZCERT
--> version: 11.2.0.1.0
--> compatible: 11.2.0.0.0
--> blocksize: 8192
--> platform. Linux IA (32-bit)
--> timezone file: V11
**********************************************************************
Tablespaces: [make adjustments in the current environment]
**********************************************************************
--> SYSTEM tablespace is adequate for the upgrade.
.... minimum required size: 698 MB
--> SYSAUX tablespace is adequate for the upgrade.
.... minimum required size: 613 MB
--> UNDOTBS1 tablespace is adequate for the upgrade.
.... minimum required size: 382 MB
--> TEMP tablespace is adequate for the upgrade.
.... minimum required size: 61 MB
**********************************************************************
Flashback: OFF
**********************************************************************
**********************************************************************
Update Parameters: [Update Oracle Database 11.2 init.ora or spfile]
Note: Pre-upgrade tool was run on a lower version 32-bit database.
**********************************************************************
--> If Target Oracle is 32-Bit, refer here for Update Parameters:
-- No update parameter changes are required.

--> If Target Oracle is 64-Bit, refer here for Update Parameters:
WARNING: --> "memory_target" needs to be increased to at least 620 MB
**********************************************************************
Renamed Parameters: [Update Oracle Database 11.2 init.ora or spfile]
**********************************************************************
-- No renamed parameters found. No changes are required.
**********************************************************************
Obsolete/Deprecated Parameters: [Update Oracle Database 11.2 init.ora or spfile]
**********************************************************************
-- No obsolete parameters found. No changes are required.

**********************************************************************
Components: [The following database components will be upgraded or installed]
**********************************************************************
--> Oracle Catalog Views [upgrade] VALID
--> Oracle Packages and Types [upgrade] VALID
--> JServer JAVA Virtual Machine [upgrade] VALID
--> Oracle XDK for Java [upgrade] VALID
--> Oracle Workspace Manager [upgrade] VALID
--> OLAP Analytic Workspace [upgrade] VALID
--> OLAP Catalog [upgrade] VALID
--> EM Repository [upgrade] VALID
--> Oracle Text [upgrade] VALID
--> Oracle XML Database [upgrade] VALID
--> Oracle Java Packages [upgrade] VALID
--> Oracle interMedia [upgrade] VALID
--> Spatial [upgrade] VALID
--> Expression Filter [upgrade] VALID
--> Rule Manager [upgrade] VALID
--> Oracle Application Express [upgrade] VALID
--> Oracle OLAP API [upgrade] VALID
.
<忽略显示>

**********************************************************************

运行第二个脚本catupgrd.sql

这个脚本才是真正的升级脚本

SQL> @$ORACLE_HOME/rdbms/admin/utlu112i.sql
运行的时间很长。。。很长。。。

SQL>................................

<忽略显示>

SQL> Rem *********************************************************************
SQL> Rem END catupgrd.sql
SQL> Rem *********************************************************************
SQL> SQL>

这个脚本运行了N久终于搞定了,从最后一段显示来看,脚本在运行到最后运行了shutdown immediate命令。在DOC这一段中大概是说,已经成功完成这个脚本,脚本运行过程中出现的错误可以在spool log 中查看,如果发现错误,可以参考oracle相关的升级错误诊断文档。接下来需要正常运行数据库并运行utlrp.sql脚本来编译一些无效对象。如果你的源数据库时区版本较老,可以运行DBMS_DST 脚本升级 最新的TIMESTAMP WITH TIME ZONE 。

编译无效对象

为了保证数据字典的有效性和完整性,在运行完升级脚本后,建议运行该脚本。

SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql

TIMESTAMP
<忽略显示>
PL/SQL procedure successfully completed.


运行时间比较长,运行完之后 我们还需要运行一个脚本。

运行utlu112s.sql

这个脚本可以验证各个组件的版本和状态。


SQL> @$ORACLE_HOME/rdbms/admin/utlu112s.sql
.
Oracle Database 11.2 Post-Upgrade Status Tool 02-14-2002 19:34:42
.
Component Status Version HH:MM:SS
.
Oracle Server
. VALID 11.2.0.2.0 00:30:12
JServer JAVA Virtual Machine
. VALID 11.2.0.2.0 00:06:17
Oracle Workspace Manager
. VALID 11.2.0.2.0 00:01:57
OLAP Analytic Workspace
. VALID 11.2.0.2.0 00:01:21
OLAP Catalog
. VALID 11.2.0.2.0 00:03:06
Oracle OLAP API
. VALID 11.2.0.2.0 00:01:17
Oracle Enterprise Manager
. VALID 11.2.0.2.0 00:08:50
Oracle XDK
. VALID 11.2.0.2.0 00:02:03
Oracle Text
. VALID 11.2.0.2.0 00:01:29
Oracle XML Database
. VALID 11.2.0.2.0 00:06:52
Oracle Database Java Packages
. VALID 11.2.0.2.0 00:01:01
Oracle Multimedia
. VALID 11.2.0.2.0 00:11:18
Spatial
. VALID 11.2.0.2.0 00:02:49
Oracle Expression Filter
. VALID 11.2.0.2.0 00:00:27
Oracle Rules Manager
. VALID 11.2.0.2.0 00:00:24
. VALID 3.2.1.00.10
Gathering Statistics
. 00:06:41
Total Upgrade Time: 01:26:17

PL/SQL procedure successfully completed.

从运行结果来看,基本没什么问题。后面显示的是各个组件升级所使用的时间,从我这里看,大概使用了80分钟。真够长的。。。

运行catuppst.sql

这个脚本是定位ORACLE_HOME/rdbms/admin目录用的,不需要进入upgrade模式了。所以直接运行。

SQL> @$ORACLE_HOME/rdbms/admin/catuppst.sql

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP POSTUP_BGN 2002-02-14 19:44:20
PL/SQL procedure successfully completed.
This script. will migrate the Baseline data on a pre-11g database
to the 11g database. ...
... Completed Moving the Baseline Data ...
...
... If there are no Move BL Data messages ...
... above, then there are no renamed ...
... baseline tables in the system. .

...<忽略显示>

SQL> SPOOL off
SQL> SET echo off
Check the following log file for errors:
/u01/oracle/cfgtoollogs/catbundle/catbundle_PSU_SZCERT_APPLY_2002Feb14_19_44_34.log

运行utlrp.sql

这个脚本的作用是编译剩余存储的PL/SQL和JAVA代码。

SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql

TIMESTAMP
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2002-02-14 19:47:33

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
<忽略显示>
PL/SQL procedure successfully completed.

检验所有的包和类都是有效的

SQL> SELECT count(*) FROM dba_invalid_objects;

COUNT(*)
----------
0

SQL> SELECT distinct object_name FROM dba_invalid_objects;

no rows selected

注:如果发现无效对象,registry$sys_inv_objs和andregistry$nonsys_inv_objs 查找到无效对象,可以运行 ORACLE_HOME/rdbms/admin/utluiobj.sql 去显示最近的。

退出SQLPLUS就基本完成升级

如果你是RAC,则需要执行srctl命令

$ srvctl upgradedatabase -d db-unique-name -o oraclehome

db-unique-name:需要数据库名,不是实例名喔!

oraclehome:新的ORACLE_HOME路径。

如果在升级过程中遇到问题,可以重新执行升级脚本,步骤如下:

1.Shut down the database as follows:

SQL> SHUTDOWNIMMEDIATE

2.Restart the databasein UPGRADE mode:

SQL> STARTUPUPGRADE

3.Set the system to spool results to a logfile for later verification of success:

SQL> SPOOLupgrade.log

4.Rerun catupgrd.sql:

SQL>@catupgrd.sql

Note:

You can rerunthe catupgrd.sql script. as many times as necessary. The first timeyou run the script, there should be no error messages returned. If you rerunthe script, then the ORA-00001 messageis displayed. You can safely ignore this message.

5.Rerun utlu112s.sql:

SQL>@utlu112s.sql

最后我们来看看刚刚升级后,数据字典查到的信息。

SQL> SELECT COMP_NAME, VERSION, STATUS FROM SYS.DBA_REGISTRY;

<忽略显

注:OWB是ORACLE 的一个综合,它提供对 ETL(提取、转换和加载)、完全集成的关系和维度建模、数据质量、数据审计,以及数据和元数据的整个生命周期的管理。与RDBMS的运行关系不是非常之大,所以可以不管了。

自此,11.2.0.1 to 11.2.0.2基本升级完毕。

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

请登录后发表评论 登录
全部评论

注册时间:2018-10-10

  • 博文量
    536
  • 访问量
    9607