升级可能导致数据库不可用[待看]

来源:互联网 发布:魏志香 知乎 编辑:程序博客网 时间:2024/05/02 01:41
升级可能导致数据库不可用(一)2010-08-19 23:55:00

分类: Linux

升级过程也是一个危险的过程,操作不当可能造成数据库无法打开,因此在升级之前应该做好备份。

描述问题产生的原因。

 

 

尝试将一个9.2.0.4的数据库手工升级为11.2.0.1。但是升级过程中犯了一个小错误,在升级之前没有执行11.2的ORACLE_HOME/rdbms/admin/utlu112i.sql。

就是这个小错误,导致数据库升级失败。

在执行catupgrd.sql脚本时,出现了ORA-00942: table or view does not exist错误:

SQL> spo upgrade.sql
SQL> @?/rdbms/admin/catupgrd
DOC>#######################################################################
DOC>#######################################################################
DOC>
DOC>   The first time this script. is run, there should be no error messages
DOC>   generated; all normal upgrade error messages are suppressed.
DOC>
DOC>   If this script. is being re-run after correcting some problem, then
DOC>   expect the following error which is not automatically suppressed:
DOC>
DOC>   ORA-00001: unique constraint (<constraint_name>) violated
DOC>              possibly in conjunction with
DOC>   ORA-06512: at "<procedure/function name>", line NN
DOC>
DOC>   These errors will automatically be suppressed by the Database Upgrade
DOC>   Assistant (DBUA) when it re-runs an upgrade.
DOC>
DOC>#######################################################################
DOC>#######################################################################
DOC>#
.
.
.

DOC>#######################################################################
DOC>#######################################################################
DOC>   The following statement will cause:
DOC>   - "ORA-00942: table or view does not exist" ; or
DOC>   - "ORA-00904: "TZ_VERSION": invalid identifier"" ; or
DOC>   - "ORA-01722: invalid number"
DOC>     if the pre-upgrade utility (utlu112i.sql) has not been run to:
DOC>     a) create and update registry$database table to include the current
DOC>        database timezone file version used in the old release; or
DOC>     b) do inserts into sys.props$.
DOC>
DOC>     o Action:
DOC>       Shutdown ABORT and revert to the original ORACLE_HOME.  Then run
DOC>       utlu112i.sql to populate registry$database with the database timezone
DOC>       file version used by the lower version database and to populate
DOC>       sys.props$ with Day Light Saving Time (DST) properties information.
DOC>
DOC>   OR
DOC>   - An "ORA-01722: invalid number"
DOC>     if the old release uses a timezone file version newer than 8 (shipped with
DOC>     11.2) but the new release has not been patched yet.
DOC>
DOC>     o Action:
DOC>       Shutdown ABORT and patch new ORACLE_HOME to the same timezone file
DOC>       version as used in the old ORACLE_HOME.
DOC>
DOC>
DOC>#######################################################################
DOC>#######################################################################
DOC>#
       TO_NUMBER(value$) != (SELECT tz_version from registry$database))
                                                    *
第 6 行出现错误:
ORA-00942: 表或视图不存在


Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开

根据Oracle给出的解决方法,需要设置9.2的ORACLE_HOME,启动数据库执行11.2的ORACLE_HOME/rdbms/admin/utlu112i.sql。但是由于已经设置了COMPATIBLE为11.2.0.1.0,并启动过数据库,导致9i环境已经无法打开数据库,启动将报错:

[oracle@bjtest ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期五 4月 30 22:05:47 2010

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


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown abort
ORACLE
例程已经关闭。
SQL> exit
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开

[oracle@bjtest ~]$ export ORACLE_HOME=/opt/oracle/product/9.2
[oracle@bjtest ~]$ export PATH=$ORACLE_HOME/bin:$PATH
[oracle@bjtest ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on 星期五 4月 30 22:06:42 2010

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

已连接到空闲例程。

SQL> startup pfile=inittest9.ora
ORA-00401: the value for parameter compatible is not supported by this release

初始化参数的值COMPATIBLE设置为11.2.0.1.0,在9i是无法启动的,但是即使改成9.2.0.1.0,由于已经更改了CONTROL_FILE,因此也是无法启动的。

修改初始化参数后,尝试启动:

SQL> startup pfile=inittest9.ora
ORACLE 例程已经启动。

Total System Global Area  657246184 bytes
Fixed Size                   743400 bytes
Variable Size             385875968 bytes
Database Buffers          268435456 bytes
Redo Buffers                2191360 bytes
ORA-00201: ?????? 9.2.0.0.0 ? ORACLE ?? 9.2.0.0.0 ???
ORA-00202: ????: '/data/oradata/test9/control01.dbf'

而且这时在11g的环境下,利用UPGRADE方式启动,也无法调用utlu112i.sql了,调用会报错:

[oracle@bjtest ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on 星期五 4月 30 22:11:26 2010

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


连接到:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production

SQL> shutdown abort
ORACLE
例程已经关闭。
SQL> exit
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production中断开

[oracle@bjtest ~]$ export ORACLE_HOME=/data/oracle/product/11.2
[oracle@bjtest ~]$ export PATH=$ORACLE_HOME/bin:$PATH
[oracle@bjtest ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期五 4月 30 22:12:00 2010

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

已连接到空闲例程。

将初始化参数改回为11.2.0.1.0,利用UPGRADE启动数据库:

SQL> startup pfile=inittest9.ora upgrade
ORA-32006: BACKGROUND_DUMP_DEST initialization parameter has been deprecated
ORA-32006: USER_DUMP_DEST initialization parameter has been deprecated
ORACLE 例程已经启动。

Total System Global Area  618012672 bytes
Fixed Size                  2215784 bytes
Variable Size             343933080 bytes
Database Buffers          268435456 bytes
Redo Buffers                3428352 bytes
数据库装载完毕。
数据库已经打开。
SQL> @?/rdbms/admin/utlu112i.sql
ERROR:
ORA-04023:
无法验证或授权对象 SYS.STANDARD


DECLARE
*
第 1 行出现错误:
ORA-04023: 无法验证或授权对象 SYS.STANDARD


ERROR:
ORA-04023:
无法验证或授权对象 SYS.STANDARD

现在已经陷入了两难的境地,在9i和11g都无法成功的打开数据库。如果在升级操作之前没有备份,就很可能导致数据库的彻底崩溃。


评论:


爱乐2010-08-20 09:40:09

是否可以重安装9i目录,重新定义环境变量。再启动呢?:



yangtingkun2010-08-20 23:57:27

不行,控制文件已经发生变化了



升级可能导致数据库不可用(二)2010-08-20 23:57:00

分类: Linux

升级过程也是一个危险的过程,操作不当可能造成数据库无法打开,因此在升级之前应该做好备份。

尝试解决问题。

升级可能导致数据库不可用(一):http://yangtingkun.itpub.net/post/468/504017

 

 

在上一篇的文章中,由于升级过程中犯了个小错误,倒是数据库无法打开,且升级过程无法正常继续。

其实这个错误都不是很严重,本来是有办法解决的。但是由于当前的数据库环境必须设置COMPATIBLE,而且11.2升级过程中,也比较确保COMPATIBLE大于10.1,这就导致COMPATIBLE参数不能保持原始值不变,从而导致了严重的后果。

如果升级之前备份了数据库,那么只需要关闭数据库,并利用备份恢复,然后改成错误,重新执行升级过程即可。

在没有备份的情况下,只能采用一些极端的手段进行恢复了。

由于执行catupgrd.sql脚本报错,下面之后修改脚本中检查错误的地方,将catupstr.sql脚本的下列语句注释掉:

DOC
#######################################################################
#######################################################################
   The following statement will cause:
   - "ORA-00942: table or view does not exist" ; or
   - "ORA-00904: "TZ_VERSION": invalid identifier"" ; or
   - "ORA-01722: invalid number"
     if the pre-upgrade utility (utlu112i.sql) has not been run to:
     a) create and update registry$database table to include the current
        database timezone file version used in the old release; or
     b) do inserts into sys.props$.

     o Action:
       Shutdown ABORT and revert to the original ORACLE_HOME.  Then run
       utlu112i.sql to populate registry$database with the database timezone
       file version used by the lower version database and to populate
       sys.props$ with Day Light Saving Time (DST) properties information.

   OR
   - An "ORA-01722: invalid number"
     if the old release uses a timezone file version newer than 8 (shipped with
     11.2) but the new release has not been patched yet.

     o Action:
       Shutdown ABORT and patch new ORACLE_HOME to the same timezone file
       version as used in the old ORACLE_HOME.


#######################################################################
#######################################################################
#

SELECT TO_NUMBER('MUST_BE_SAME_TIMEZONE_FILE_VERSION')
   FROM sys.props$
   WHERE
     (
      (name = 'DST_PRIMARY_TT_VERSION' AND
       TO_NUMBER(value$) != (SELECT tz_version from registry$database))
      AND
      ((SELECT version from v$timezone_file) !=
       (SELECT tz_version from registry$database))
     )
     OR
     (
      (name = 'DST_PRIMARY_TT_VERSION' AND TO_NUMBER(value$) > 8)
      AND
      (0 = (select count(*) from v$timezone_file))
     );

由于没有执行utlu112i.sql,导致registry$database表不存在,因此这里执行报错,为了整个语句可以顺利执行,先把这个SQL注释掉。

再次调用catupgrd.sql,升级过程开始。

但是由于缺少表的支持,升级过程必然会出现错误,导致升级到一半,出现了大量的ORA-3113错误:

ORA-00603: ORACLE server session terminated by fatal error
ERROR:
ORA-03114:
脦麓脕卢陆脫碌陆 ORACLE
ERROR:
ORA-03114: 脦麓脕卢陆脫碌陆
ORACLE
ERROR:
ORA-03114: 脦麓脕卢陆脫碌陆
ORACLE
ERROR:
ORA-03114: 脦麓脕卢陆脫碌陆
ORACLE
ERROR:
ORA-03114: 脦麓脕卢陆脫碌陆
ORACLE
ERROR:
ORA-03114: 脦麓脕卢陆脫碌陆
ORACLE
ERROR:
ORA-03114: 脦麓脕卢陆脫碌陆
ORACLE
ERROR:
ORA-03114: 脦麓脕卢陆脫碌陆
ORACLE
ERROR:
ORA-03114: 脦麓脕卢陆脫碌陆
ORACLE
ERROR:
ORA-03114: 脦麓脕卢陆脫碌陆
ORACLE
.
.
.

升级失败。不过这时在意料之中的,将catupstr.sql中注释的部分去掉,关闭数据库,重启以upgrade方式启动,再次执行catupgrd.sql脚本,重新升级过程。

执行最终仍然出现了上面的错误信息。重复多次升级步骤,问题依旧。

但是虽然升级过程失败,但是数据库可以短暂的打开:

[oracle@bjtest ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 4月 29 23:07:20 2010

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

已连接到空闲例程。

SQL> startup pfile=inittest9.ora
ORA-32006: BACKGROUND_DUMP_DEST initialization parameter has been deprecated
ORA-32006: USER_DUMP_DEST initialization parameter has been deprecated
ORACLE 例程已经启动。

Total System Global Area  618012672 bytes
Fixed Size                  2215784 bytes
Variable Size             343933080 bytes
Database Buffers          268435456 bytes
Redo Buffers                3428352 bytes
数据库装载完毕。
数据库已经打开。
SQL> select instance_name, status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
test9            OPEN

SQL> select name, open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
TEST9     READ WRITE

SQL> exit
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开

[oracle@bjtest ~]$ exp system/test file=full.dp full=y buffer=20480000 log=full.log

Export: Release 11.2.0.1.0 - Production on 星期四 4月 29 23:09:31 2010

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


连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集

即将导出整个数据库...
. 正在导出表空间定义

. 正在导出概要文件
. 正在导出用户定义
. 正在导出角色
EXP-00008: 遇到 ORACLE 错误 4045
ORA-04045: 在重新编译/重新验证 SYS.DBMS_DATAPUMP 时出错

ORA-00600: 内部错误代码, 参数: [ktfbbsearch-8], [128], [15], [], [], [], [], [], [], [], [], []
ORA-06508: PL/SQL: 无法找到正在调用 : "SYS.DBMS_DATAPUMP" 的程序单元

ORA-06512: "SYS.DBMS_LOGREP_EXP", line 3242
ORA-06512: 在
"SYS.DBMS_FILE_GROUP_EXP", line 813
ORA-06512: 在
line 1
EXP-00083: 调用 SYS.DBMS_FILE_GROUP_EXP.grant_sysprivs_exp 时出现前一问题

. 正在导出资源成本
. 正在导出回退段定义
. 正在导出数据库链接
. 正在导出序号
. 正在导出目录别名
. 正在导出上下文名称空间
. 正在导出外部函数库名
. 导出 PUBLIC 类型同义词
. 正在导出专用类型同义词
. 正在导出对象类型定义
. 正在导出系统过程对象和操作
EXP-00008: 遇到 ORACLE 错误 4063
ORA-04063: package body "SYS.DBMS_DATAPUMP" 有错误

ORA-06508: PL/SQL: 无法找到正在调用 : "SYS.DBMS_DATAPUMP" 的程序单元
ORA-06512: "SYS.DBMS_REPCAT_EXP", line 113
ORA-06512: 在
line 1
EXP-00083: 调用 SYS.DBMS_REPCAT_EXP.system_info_exp 时出现前一问题

. 正在导出 pre-schema 过程对象和操作
EXP-00008: 遇到 ORACLE 错误 4063
ORA-04063: package body "SYS.DBMS_AW_EXP" 有错误

ORA-06508: PL/SQL: 无法找到正在调用 : "SYS.DBMS_AW_EXP" 的程序单元
ORA-06512: line 1
EXP-00083: 调用 SYS.DBMS_AW_EXP.schema_info_exp 时出现前一问题

EXP-00008: 遇到 ORACLE 错误 4063
ORA-04063: package body "SYS.DBMS_DATAPUMP" 有错误

ORA-06508: PL/SQL: 无法找到正在调用 : "SYS.DBMS_DATAPUMP" 的程序单元
ORA-06512: "SYS.DBMS_RULE_EXP_UTL", line 50
ORA-06512: 在
"SYS.DBMS_RULE_EXP_RULES", line 147
ORA-06512: 在
line 1
EXP-00083: 调用 SYS.DBMS_RULE_EXP_RULES.schema_info_exp 时出现前一问题

. 正在导出簇定义
. 即将导出 SYSTEM 的表通过常规路径...
. . 正在导出表                     DEF$_AQCALL导出了           0 行

. . 正在导出表                    DEF$_AQERROR导出了           0 行
. . 正在导出表                   DEF$_CALLDEST导出了           0 行
. . 正在导出表                DEF$_DEFAULTDEST导出了           0 行
. . 正在导出表                DEF$_DESTINATION导出了           0 行
.
.
.
. .
正在导出表        REPCAT$_USER_PARM_VALUES导出了           0 行
. . 正在导出表         SQLPLUS_PRODUCT_PROFILE导出了           1 行
. 即将导出 OUTLN 的表通过常规路径...
. . 正在导出表                             OL$导出了           0 行

. . 正在导出表                        OL$HINTS导出了           0 行
. . 正在导出表                        OL$NODES导出了           0 行
. 即将导出 U1 的表通过常规路径...
. . 正在导出表                      PLAN_TABLE导出了           0 行

. . 正在导出表                               T导出了           0 行
. 正在导出同义词
. 正在导出视图
. 正在导出引用完整性约束条件
. 正在导出存储过程
. 正在导出运算符
. 正在导出索引类型
. 正在导出位图, 功能性索引和可扩展索引
. 正在导出后期表活动
. 正在导出触发器
. 正在导出实体化视图
. 正在导出快照日志
. 正在导出作业队列
. 正在导出刷新组和子组
. 正在导出维
. 正在导出 post-schema 过程对象和操作
EXP-00008: 遇到 ORACLE 错误 4063
ORA-04063: package body "SYS.DBMS_AW_EXP" 有错误

ORA-06508: PL/SQL: 无法找到正在调用 : "SYS.DBMS_AW_EXP" 的程序单元
ORA-06512: line 1
EXP-00083: 调用 SYS.DBMS_AW_EXP.schema_info_exp 时出现前一问题

EXP-00008: 遇到 ORACLE 错误 4063
ORA-04063: package body "SYS.DBMS_DATAPUMP" 有错误

ORA-06508: PL/SQL: 无法找到正在调用 : "SYS.DBMS_DATAPUMP" 的程序单元
ORA-06512: "SYS.DBMS_RULE_EXP_UTL", line 50
ORA-06512: 在
"SYS.DBMS_RULE_EXP_RULES", line 147
ORA-06512: 在
line 1
EXP-00083: 调用 SYS.DBMS_RULE_EXP_RULES.schema_info_exp 时出现前一问题

. 正在导出用户历史记录表
. 正在导出默认值和系统审计选项
. 正在导出统计信息
导出成功终止, 但出现警告。

打开数据库后,马上利用EXP可以将数据库进行逻辑导出,可以看到,虽然数据库中部分组件仍然存在错误,但是用户数据部分已经导出了。这样就有机会重建数据库了。

数据库虽然可以打开,但是状态并不正常,运行一段时间,数据库自动报错关闭:

[oracle@bjtest ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期五 4月 30 01:00:19 2010

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


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter db_block_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_block_size                        integer     10240
SQL> show parameter compat 
ORA-03135:
连接失去联系
进程 ID: 25948
会话 ID: 48 序列号: 65


SQL> EXIT
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开

虽然数据库可以导出,但是很可能会导致数据出现不一致或其他的问题,为了避免这种情况的出现,应该在升级之前备份好数据库。

 

疑问:

自己实施oracle10g数据库升级问题       [草稿]

 

对compatible参数的理解

 


对compatible参数的理解

 

0 0
原创粉丝点击