--*********************************
-- Oracle 10.2.0.1 升级到 10.2.0.4
--*********************************
数据库升级并不难,只要遵循其步骤,一般问题不大。但是升级失败的情况也是屡见不鲜,尤其是生产数据库的升级,搞不定的时候甚至要创建SR。
下面描述基于Linux(Oracle Linux 5.4/2.6.18-164.el5PAE)平台下Oracle 10.2.0.1 升级到 10.2.0.4的步骤。
Oracle升级包的下载,请链接:Oracle 补丁全集 (Oracle 9i 10g 11g Path)
注:
在9i以前,无论升级/降级,数据库都是startup migrate
10g后增加了upgrade参数,升级可直接用startup upgrade,降级仍是startup migrate
一、单实例升级先决条件:
1.表空间需求
确保system表空间至少有10M空间可用,下面给出查询语句
col "tablespace_name" for a20
col "Usage_Percent" for a10
SELECT upper(f.tablespace_name) "tablespace_name"
,d.tot_grootte_mb "tablespace_size(M)"
,d.tot_grootte_mb - f.total_bytes "used_size(M)"
,to_char(round((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100,
2),
'990.99') "Usage_Percent"
,f.total_bytes "free_size(M)"
FROM (SELECT tablespace_name
,round(SUM(bytes) / 1024 / 1024) total_bytes
,round(MAX(bytes) / (1024 * 1024), 2) max_bytes
FROM sys.dba_free_space
GROUP BY tablespace_name) f
,(SELECT dd.tablespace_name
,round(SUM(bytes) / 1024 / 1024) tot_grootte_mb
FROM sys.dba_data_files dd
GROUP BY dd.tablespace_name) d
WHERE d.tablespace_name = f.tablespace_name
ORDER BY 2 DESC;
2.系统参数:
确保参数SHARED_POOL_SIZE 和 JAVA_POOL_SIZE大于150MB以上,为加快升级速度,在系统内存可用的情况下,可临时调大这2个参数
SQL> SHOW PARAMETER SHARED_POOL_SIZE
SQL> SHOW PARAMETER JAVA_POOL_SIZE
SQL> ALTER SYSTEM SET SHARED_POOL_SIZE='200M' SCOPE=spfile;
SQL> ALTER SYSTEM SET JAVA_POOL_SIZE='200M' SCOPE=spfile;
二、实施升级
1.关闭需要升级的实例
停止实例
SQL> shutdown immediate
停止与该实例相关的所有后台进程
lsnrctl emctl
2.备份Oracle Home 目录及数据库
tar -cvf $ORACLE_BASE /orabak/ --确保Oracle相关的所有配置都位于$ORACLE_BASE目录,如监听等
cp *.dbf con*.ora redo*.log /orabak/ --对数据库实施冷备
3.升级软件
./runIstanller -->oracle 账户
root.sh -->root 账户
4.更新数据字典
SQL> startup upgrade
SQL> spool patch.log
SQL> @?/rdbms/admin/catupgrd.sql --注9i 使用catpatch.sql
SQL> spool off
5.重编译失效对象:
sql>shutdown immediate
sql>startup
SQL>@?/rdbms/admin/utlrp.sql
6.升级后的检测
SQL>select comp_name,version,status from sys.dba_registry;
检查组件的升级情况
SQL>select * from utl_recomp_errors;
7.修改兼容性参数
SQL> alter system set compatible='10.2.0.4.0' scope=spfile;
8.重新启动数据库:
SQL> SHUTDOWN
SQL> STARTUP
9.如果使用了恢复目录,则执行下面的命令
$ rman catalog username/password@alias
RMAN> UPGRADE CATALOG;
10.升级回退:
SQL> STARTUP DOWNGRADE
SQL> SPOOL downgrade.log
SQL> @catdwgrd.sql(10.2.10运行的是这个,而10.1降级用的是d92000.sql,即dold_release.sql)
Sql>spool off
Sql>shutdown immediate
12.检查升级后的情况
SQL> select comp_name,version,status from sys.dba_registry;
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 Rule Manager 10.2.0.4.0 VALID
COMP_NAME VERSION STATUS
---------------------------------------- ------------------------------ -----------
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
17 rows selected.
SQL> select * from utl_recomp_errors;
no rows selected