首页 > 代码库 > 服务器断电后一连串的异常处理

服务器断电后一连串的异常处理

(因为服务器是在分店,具体的环境不了解)

通过日志发现,应该是早晨7:44重新开启了服务器,至于是什么时候断电就不清楚了。

首先是有人反应连不到数据库,远程登录后,查看监听是正常的,然后查看数据为的状态

 

SQL> select status from v$instance;STATUS------------------------STARTED

发现数据库没有OPEN,关闭数据库,然后再打开,看看有什么报错信息

SQL> shutdown immediateORA-01507: database not mountedORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesORA-00214: control file /u02/oradata/dba/control02.ctl version 133052inconsistent with file /u02/oradata/dba/control01.ctl version 133048

控制文件出了问题,第一个和第二个控制文件异常,第三个应该是好的吧

SQL> alter system set control_files=/u02/oradata/dba/control03.ctl scope=spfile;System altered.SQL> shutdown immediateORA-01507: database not mountedORACLE instance shut down.SQL> startup mountORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesDatabase mounted.

第三个控制文件确实可用,这样问题就简单了,把第三个控制文件覆盖第一和第二个控制文件即可

SQL> shutdown immediateORA-01109: database not openDatabase dismounted.ORACLE instance shut down.SQL> exit-bash-3.2$ cd /u02/oradata/dba-bash-3.2$ cp control03.ctl control01.ctl-bash-3.2$ cp control03.ctl control02.ctl-bash-3.2$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.4.0 - Production on Wed Aug 6 11:48:15 2014Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.Connected to an idle instance.SQL> startup nomountORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesSQL> alter system set control_files=/u02/oradata/dba/control01.ctl,/u02/oradata/dba/control02.ctl,/u02/oradata/dba/control03.ctl scope=spfile;System altered.SQL> shutdown immediateORA-01507: database not mountedORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesDatabase mounted.ORA-01113: file 3 needs media recoveryORA-01110: data file 3: /u02/oradata/dba/sysaux01.dbf

还有数据文件需要恢复,这也好办

SQL> recover datafile 3;Media recovery complete.

最后修复了近10个数据文件,以为这下总可以了吧,可是在重启数据库时又出现了新的问题

SQL> startupORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesDatabase mounted.ORA-00603: ORACLE server session terminated by fatal error

经查问题,修改了两个参数,重启数据库成功

SQL> startup nomount;ORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesSQL> alter system set events 10046 trace name context off;System altered.SQL> alter system set timed_statistics=false;System altered.SQL> shutdown immediateORA-01507: database not mountedORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesDatabase mounted.Database opened.SQL> 

以为问题解决了,于是去翻了一下alert,发现alert中有很多的错误

Errors in file /u01/app/oracle/admin/dba/bdump/ora8_smon_5028.trc:ORA-01595: error freeing extent (18) of rollback segment (11))ORA-00607: Internal error occurred while making a change to a data blockORA-00600: internal error code, arguments: [4194], [14], [16], [], [], [], [], []Wed Aug  6 13:35:50 2014DEBUG: Replaying xcb 0x9abcc418, pmd 0x991fa808 for failed op 8Doing block recovery for file 18 block 6187No block recovery was neededWed Aug  6 13:35:50 2014Errors in file /u01/app/oracle/admin/dba/bdump/ora8_j000_5050.trc:ORA-00600: internal error code, arguments: [4194], [18], [23], [], [], [], [], []ORA-00600: internal error code, arguments: [4194], [18], [23], [], [], [], [], []Wed Aug  6 13:35:51 2014DEBUG: Replaying xcb 0x9abcc418, pmd 0x991fa808 for failed op 8Wed Aug  6 13:35:51 2014Errors in file /u01/app/oracle/admin/dba/bdump/ora8_j000_5050.trc:ORA-00600: internal error code, arguments: [4194], [18], [23], [], [], [], [], []ORA-00600: internal error code, arguments: [4194], [18], [23], [], [], [], [], []Doing block recovery for file 18 block 6187No block recovery was neededWed Aug  6 13:35:51 2014Errors in file /u01/app/oracle/admin/dba/bdump/ora8_mmon_5034.trc:ORA-00600: internal error code, arguments: [4194], [18], [23], [], [], [], [], []Wed Aug  6 13:35:55 2014DEBUG: Replaying xcb 0x9abcc418, pmd 0x991fa808 for failed op 8Doing block recovery for file 18 block 6187No block recovery was neededWed Aug  6 13:35:55 2014Errors in file /u01/app/oracle/admin/dba/bdump/ora8_pmon_5016.trc:ORA-00600: internal error code, arguments: [4194], [18], [23], [], [], [], [], []Wed Aug  6 13:35:57 2014Errors in file /u01/app/oracle/admin/dba/bdump/ora8_pmon_5016.trc:ORA-00600: internal error code, arguments: [4194], [18], [23], [], [], [], [], []PMON: terminating instance due to error 472Instance terminated by PMON, pid = 5016

从报错信息中发现,可能与回滚段有关,并且数据库被强行关闭。

此时想如果换一个undo表空间是否可以启动数据库,由于数据库使用的undo表空间不是系统默认的,所以此时想到改回默认的undo表空间试一下,后来发现还是不行,于是将undo的管理方式改为手动,此时可以正常启动数据库

SQL> startup mountORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesDatabase mounted.SQL> alter system set undo_management=manual scope=spfile;System altered.SQL> alter system set undo_tablespace=UNDOTBS01 scope=spfile;System altered.SQL> shutdown immediateORA-01109: database not openDatabase dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesDatabase mounted.Database opened.

然后将原来的undo表空间删除、重建,再重启数据,正常打开

SQL> drop tablespace jfsys_rb including contents and datafiles cascade constraints;System altered.SQL> create undo tablespace jfsys_rb datafile /u02/oradata/jfsys_rb.dbf size 4G;Tablespace created.SQL> alter tablespace jfsys_rb add datafile /u02/oradata/jfsys_rb_add.dbf size 4G;Tablespace altered.SQL> alter system set undo_tablespace=jfsys_rb scope=spfile;System altered.SQL> alter system set undo_management=auto scope=spfile;System altered.SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1010827264 bytesFixed Size                  2088920 bytesVariable Size             608174120 bytesDatabase Buffers          394264576 bytesRedo Buffers                6299648 bytesDatabase mounted.Database opened.

至此再查看alert,日志信息正常。