Oracle Study之--Oracle 单实例11.2.0.1.0升级到11.2.0.3.0
系统环境:
操作系统:RedHat EL6(64位)
Oracle: Oracle 11gR2
Oracle 11.2.0.1 单实例升级到11.2.0.3
Oracle 升级的步骤都差点儿相同,先升级Oracle software,然后升级Oracle instance。
Oracle 11.2.0.2的patchset No 是:10098816。 关于该Patchset 的下载地址,參考以下的链接:
Oracle 11.2.0.2 Patch 说明 http://www.linuxidc.com/Linux/2011-10/44230.htm
Oracle11.2.0.3 的Patchset no是:10404530,下载地址:http://www.linuxidc.com/Linux/2011-10/44229.htm
Oracle 11.2.0.3 Patchset 下载地址
patchset 有7个文件。关于这7个文件的不同作用。參考:
Oracle 11gR2 Patchset 不同文件作用说明 http://www.linuxidc.com/Linux/2011-09/43889.htm
我们升级DB。 仅仅须要当中的第一个和第二个文件。将2个文件解压缩,然后将第二个文件的内容copy到第一个文件的相应文件夹里。即将2个文件合成一个文件。
一.查看DB 相关的信息
32位的DB:
[oracle@rh6 ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 24 14:20:50 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> select name from v$database;
NAME
---------
prod
查看 Oracle 是32位还是64位的方法 http://blog.csdn.net/lqx0405/article/details/46621697
二.升级的相关说明
2.1 Patchset 的说明
内容copy 自patchset的readme 文档:
Oracle Databasepatch set, release 11.2.0.3(11.2.0.2) is a full installation of the Oracle Database software. This meansthat you do not need to install Oracle Database 11g Release 2 (11.2.0.1)before installing Oracle Database 11g Release 2 (11.2.0.3/11.2.0.2).
Oracle 11.2.0.2 和 11.2.0.3 的patchset都是完整的安装包。
所以能够直接用来安装。
Note the following changes with the newpatch set packaging:
(1)Newinstallations consist of installing the most recent patch set, rather thaninstalling a base release and then upgrading to a patch release.
(2)Directupgrades from previous releases to the most recent patch set are supported.
(3)Out-of-placepatch set upgrades recommended, in which you install the patch set into a new,separate Oracle home. In-place upgrades are supported, but not recommended.
2.1.1 In-Place Upgrade
This feature enablesyou to upgrade an existing installation of Oracle database to Oracle Database11g Release 2 (11.2.0.3) into the same Oracle home directory by replacingthe existing database files. The patch set application requires more downtimeand is not recommended. This upgrade type requires less disk space.
将升级文件安装到原来的Oracle home 文件夹,这样能够节省磁盘空间,可是须要很多其它的downtime。 这样的并不推荐。
2.1.2 Out-of-Place Upgrade
This featureenables you to install Oracle Database 11g Release 2 (11.2.0.3) in a new,separate Oracle home directory. After the installation is complete, the datafrom the database in the old Oracle home directory is migrated to the databasein the new
Oracle home directory.
能够将Oracle Database 安装的新的OracleHome directory。当安装结束后,旧的database 会迁移到新的Oracle homedirectory。
Out-of-placeupgrade process is similar to Oracle database upgrade from one version toanother and is the recommended type. The benefits of this upgrade type is thatthe patch set application requires much less downtime, and is safer when thepatch set application must be aborted. This upgrade type requires more diskspace to accommodate two Oracle home directories simultaneously.
这样的方法是oracle推荐的方式。它能够减少downtime 时间,也相对更安全。可是这样的方法须要2倍的地盘空间,只是对与如今白菜价硬盘来说。这点空间也不算什么了。
2.2 升级步骤
Oracle 10g的Readme上有具体的升级步骤,可是11g的Readme上并没有具体的升级说明。须要參考官方文档。
Oracle 10g upgrade from10.2.0.1 to 10.2.0.4 见 http://www.linuxidc.com/Linux/2011-05/35997.htm
(1) 备份数据库
(2) 执行patchset。升级oracle 软件
(3) 准备新的ORACLE_HOME
(4) 执行dbua 或者脚本升级实例
(5) 检查升级后的版本号信息和无效对象
官网地址:
Upgrading to theNew Release
http://download.oracle.com/docs/cd/E11882_01/server.112/e23633/upgrade.htm#i1011372
单实例的升级。相对较简单。假设是RAC的升级,预计还要麻烦一点。11gR2 RAC 升级后面会继续进行測试。
三.升级Oracle 软件
3.1 备份DB
本机是測试环境。就不进行备份,假设是生产环境,切记要先备份。后操作。
假设是In-Place Upgrade。同一时候备份一下整个ORACLE_HOME文件夹。
假设升级有问题,还能够还原回来。
重点是例如以下文件夹:
ORACLE_HOME/dbs
ORACLE_HOME/network/admin
ORACLE_HOME/hostname_dbname
ORACLE_HOME/oc4j/j2ee/OC4J_DBConsole_hostname_dbname
3.2 升级Oracle database 软件
将升级包解压。11.2.0.3总共7个升级包,仅仅须要前两个
[root@rh6 ~]# su - oracle
[oracle@rh6 ~]$ cd soft
[oracle@rh6 soft]$ ls -l
total 2442052
-rwxr--r-- 1 oracle oinstall 1358454646 Jul 7 2013 p10404530_112030_Linux-x86-64_1of7.zip
-rwxr--r-- 1 oracle oinstall 1142195302 Jul 7 2013 p10404530_112030_Linux-x86-64_2of7.zip
[oracle@rh6 soft]$ unzip p10404530_112030_Linux-x86-64_1of7.zip ;unzip p10404530_112030_Linux-x86-64_2of7.zip
...... creating: database/stage/Components/oracle.rdbms.install.seeddb/ creating: database/stage/Components/oracle.rdbms.install.seeddb/11.2.0.3.0/ creating: database/stage/Components/oracle.rdbms.install.seeddb/11.2.0.3.0/1/ creating: database/stage/Components/oracle.rdbms.install.seeddb/11.2.0.3.0/1/DataFiles/ creating: database/stage/Components/oracle.rdbms.install.seeddb/11.2.0.3.0/1/DataFiles/Expanded/ creating: database/stage/Components/oracle.rdbms.install.seeddb/11.2.0.3.0/1/DataFiles/Expanded/filegroup1/ inflating: database/stage/Components/oracle.rdbms.install.seeddb/11.2.0.3.0/1/DataFiles/Expanded/filegroup1/Seed_Database.ctl inflating: database/stage/Components/oracle.rdbms.install.seeddb/11.2.0.3.0/1/DataFiles/Expanded/filegroup1/Seed_Database.dfb inflating: database/stage/Components/oracle.rdbms.install.seeddb/11.2.0.3.0/1/DataFiles/filegroup2.jar creating: database/stage/Components/oracle.sysman.console.db/ creating: database/stage/Components/oracle.sysman.console.db/11.2.0.3.0/ creating: database/stage/Components/oracle.sysman.console.db/11.2.0.3.0/1/ creating: database/stage/Components/oracle.sysman.console.db/11.2.0.3.0/1/DataFiles/ ......
解压后,生成database目录:
[oracle@rh6 soft]$ ls -l
total 2442056
drwxr-xr-x 8 oracle oinstall 4096 Sep 22 2011 database
-rwxr--r-- 1 oracle oinstall 1358454646 Jul 7 2013 p10404530_112030_Linux-x86-64_1of7.zip
-rwxr--r-- 1 oracle oinstall 1142195302 Jul 7 2013 p10404530_112030_Linux-x86-64_2of7.zip
查看database目录:
[oracle@rh6 soft]$ cd database/ [oracle@rh6 database]$ ls doc install readme.html response rpm runInstaller sshsetup stage welcome.html
[oracle@rh6 database]$ cd stage/
[oracle@rh6 stage]$ ls Actions install1.jar products.xml ComponentList install2.jar properties Components invDetails.properties Queries config.xml libs.xml shiphomeinfo.properties cvu oracle.server.11_2_0_3_0_1316280737644.bak shiphomeproperties.xml Dialogs oracle.server.11_2_0_3_0_1316280738235.bak sizes ext oracle.server.11_2_0_3_0_dep_default.properties TopLevel_UserAction.properties fastcopy oracle.server.11_2_0_3_0.xml UserActions fastcopy.xml OuiConfigVariables.xml globalvariables productlanguages.properties
[oracle@rh6 stage]$ du -sh Components 2.3G Components
升级前对数据库进行备份:
[oracle@rh6 stage]$ mkdir /dsk1/backup [oracle@rh6 stage]$ rman target / Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jun 24 11:38:23 2015 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database (not started) RMAN> run { 2> startup mount; 3> backup database format '/dsk1/backup/%d_%s.bak'; 4> backup current controlfile format '/dsk1/backup/control.bak'; 5> } Oracle instance started database mounted Total System Global Area 417546240 bytes Fixed Size 2213936 bytes Variable Size 297797584 bytes Database Buffers 113246208 bytes Redo Buffers 4288512 bytes Starting backup at 24-JUN-15 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=18 device type=DISK channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle/oradata/prod/system01.dbf input datafile file number=00002 name=/u01/app/oracle/oradata/prod/sysaux01.dbf input datafile file number=00005 name=/u01/app/oracle/oradata/prod/example01.dbf input datafile file number=00003 name=/u01/app/oracle/oradata/prod/undotbs01.dbf input datafile file number=00004 name=/u01/app/oracle/oradata/prod/users01.dbf channel ORA_DISK_1: starting piece 1 at 24-JUN-15 ...... RMAN> list backup of database; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 1 Full 1.00G DISK 00:00:58 24-JUN-15 BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20150624T113940 Piece Name: /dsk1/backup/PROD_1.bak List of Datafiles in backup set 1 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 1066745 24-JUN-15 /u01/app/oracle/oradata/prod/system01.dbf 2 Full 1066745 24-JUN-15 /u01/app/oracle/oradata/prod/sysaux01.dbf 3 Full 1066745 24-JUN-15 /u01/app/oracle/oradata/prod/undotbs01.dbf 4 Full 1066745 24-JUN-15 /u01/app/oracle/oradata/prod/users01.dbf 5 Full 1066745 24-JUN-15 /u01/app/oracle/oradata/prod/example01.dbf
<strong>关闭数据库准备升级:</strong>
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
本次採用Out-of-Place Upgrade,所以将11.2.0.3的软件安装到不同的文件夹下:
[oracle@rh6 ~]$ mkdir -p /u01/app/oracle/product/11.2.0.3/db_1
[oracle@rh6 ~]$ cat .bash_profile
export EDITOR=vi
export ORACLE_SID=prod
export ORACLE_BASE=/u01/app/oracle
#export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.3/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin
umask 022
执行Patchset 的runInstaller:
注意这里。我们选择第三个选项。skip software update。由于我们的patchset已经下载过了
安装11.2.0.3.0软件
运行root.sh脚本(以root身份):
[root@rh6 ~]# /u01/app/oracle/product/11.2.0.3/db_1/root.sh Performing root user operation for Oracle 11g The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /u01/app/oracle/product/11.2.0.3/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.
将原文件夹(11.2.0.1.0) 下的文件复制到新的文件夹(11.2.0.3.0)下:
[oracle@rh6 ~]$ cd /u01/app/oracle/product/11.2.0/db_1/dbs [oracle@rh6 dbs]$ ls hc_DBUA0.dat hc_prod.dat init.ora lkPROD orapwprod snapcf_prod.f spfileprod.ora [oracle@rh6 dbs]$ cp * /u01/app/oracle/product/11.2.0.3/db_1/dbs/ [oracle@rh6 dbs]$ cd ../network/admin/ [oracle@rh6 admin]$ pwd /u01/app/oracle/product/11.2.0/db_1/network/admin [oracle@rh6 admin]$ ls listener.ora samples shrept.lst tnsnames.ora [oracle@rh6 admin]$ cp -R * /u01/app/oracle/product/11.2.0.3/db_1/network/admin/
改动/etc/cattab文件:
[oracle@rh6 admin]$ cat /etc/oratab # # This file is used by ORACLE utilities. It is created by root.sh # and updated by the Database Configuration Assistant when creating # a database. # A colon, ':', is used as the field terminator. A new line terminates # the entry. Lines beginning with a pound sign, '#', are comments. # # Entries are of the form: # $ORACLE_SID:$ORACLE_HOME:<N|Y>: # # The first and second fields are the system identifier and home # directory of the database respectively. The third filed indicates # to the dbstart utility that the database should , "Y", or should not, # "N", be brought up at system boot time. # # Multiple entries with the same $ORACLE_SID are not allowed. # # prod:/u01/app/oracle/product/11.2.0/db_1:N 改动为: [oracle@rh6 admin]$ cat /etc/oratab # # This file is used by ORACLE utilities. It is created by root.sh # and updated by the Database Configuration Assistant when creating # a database. # A colon, ':', is used as the field terminator. A new line terminates # the entry. Lines beginning with a pound sign, '#', are comments. # # Entries are of the form: # $ORACLE_SID:$ORACLE_HOME:<N|Y>: # # The first and second fields are the system identifier and home # directory of the database respectively. The third filed indicates # to the dbstart utility that the database should , "Y", or should not, # "N", be brought up at system boot time. # # Multiple entries with the same $ORACLE_SID are not allowed. # # prod:/u01/app/oracle/product/11.2.0.3/db_1:N
---至此,Oracle软件升级完毕!
四、升级数据字典(Instance)
Instance启动到upgrade状态:
[oracle@rh6 admin]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 24 14:06:04 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup upgrade;
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2228944 bytes
Variable Size 297798960 bytes
Database Buffers 113246208 bytes
Redo Buffers 4272128 bytes
Database mounted.
Database opened.
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
prod OPEN MIGRATE
SQL> @?/rdbms/admin/catupgrd.sql
运行完毕后,关闭数据库。在又一次正常启动数据库:
[oracle@rh6 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sun Dec 8 04:13:52 2013
Copyright (c) 1982, 2011, Oracle.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted.
Database opened.
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
编译无效的对象:
SQL>@?/rdbms/admin/utlrp.sql
......
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2015-06-24 15:59:15
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.
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
---------------------------
4
Function created.
PL/SQL procedure successfully completed.
Function dropped.
PL/SQL procedure successfully completed.
验证升级结果:
SQL> set linesize 120
SQL> r
1* select comp_name,version,status from sys.dba_registry
COMP_NAME VERSION STATUS
---------------------------------------- ------------------------------ ----------------------
OWB 11.2.0.3.0 VALID
Oracle Application Express 3.2.1.00.10 VALID
Oracle Enterprise Manager 11.2.0.3.0 VALID
OLAP Catalog 11.2.0.3.0 VALID
Spatial 11.2.0.3.0 VALID
Oracle Multimedia 11.2.0.3.0 VALID
Oracle XML Database 11.2.0.3.0 VALID
Oracle Text 11.2.0.3.0 VALID
Oracle Expression Filter 11.2.0.3.0 VALID
Oracle Rules Manager 11.2.0.3.0 VALID
Oracle Workspace Manager 11.2.0.3.0 VALID
COMP_NAME VERSION STATUS
---------------------------------------- ------------------------------ ----------------------
Oracle Database Catalog Views 11.2.0.3.0 VALID
Oracle Database Packages and Types 11.2.0.3.0 INVALID
JServer JAVA Virtual Machine 11.2.0.3.0 VALID
Oracle XDK 11.2.0.3.0 VALID
Oracle Database Java Packages 11.2.0.3.0 VALID
OLAP Analytic Workspace 11.2.0.3.0 VALID
Oracle OLAP API 11.2.0.3.0 VALID
18 rows selected.
改动兼容性參数:
SQL> show parameter comp
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offload_compaction string ADAPTIVE
compatible string 11.2.0.0.0
nls_comp string BINARY
plsql_v2_compatibility boolean FALSE
SQL> alter system set compatible='11.2.0.3' scope=spfile;
System altered.
SQL> startup force;
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2228944 bytes
Variable Size 390073648 bytes
Database Buffers 20971520 bytes
Redo Buffers 4272128 bytes
Database mounted.
Database opened.
SQL> show parameter comp
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offload_compaction string ADAPTIVE
compatible string 11.2.0.3
nls_comp string BINARY
plsql_v2_compatibility boolean FALSE
-----至此。整个升级过程结束!