事故原因如下:
今天早上查看表空间利用率时发现一oracle8i数据库宕机了操作完後过段时间導致數據庫當機。查询警告日志发现大量的关于数据文件的临时读取错误。
原来一同事因磁盘空间达到95%,去清理临时数据和log时,错误的执行了如下命令,清空了临时数据文件。
cat /dev/null > /opt/oracle/oradata/openview/OPC_TEMP_1.dbf
cat /dev/null > /opt/oracle/oradata/openview/OPC_TEMP_1.dbf
cat /dev/null > /opt/oracle/oradata/openview/OPC_TEMP_1.dbf
之后我在启动数据库的时候报错如下:
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
LICENSE_MAX_USERS = 0
Starting up ORACLE RDBMS Version: 8.1.7.0.0.
System parameters with non-default values:
processes = 50
shared_pool_size = 120000000
control_files = /opt/oracle/oradata/openview/control01.ctl, /opt/oracle/oradata/openview/control02.ctl, /opt/oracle/oradata/openview/control03.ctl
db_block_buffers = 550
db_block_size = 8192
compatible = 8.1.7.0.0
log_archive_start = FALSE
log_archive_dest = /opt/oracle/admin/openview/arch
log_archive_format = T%TS%S.ARC
log_buffer = 65536
log_checkpoint_interval = 99999
db_files = 50
db_file_multiblock_read_count= 8
dml_locks = 100
rollback_segments = r01, r02, r03, r04
remote_os_authent = TRUE
db_name = openview
open_cursors = 500
os_authent_prefix =
background_dump_dest = /opt/oracle/admin/openview/bdump
user_dump_dest = /opt/oracle/admin/openview/udump
max_dump_file_size = 10240
core_dump_dest = /opt/oracle/admin/openview/cdump
PMON started with pid=2
DBW0 started with pid=3
LGWR started with pid=4
CKPT started with pid=5
SMON started with pid=6
RECO started with pid=7
Fri Jun 21 08:18:51 2013
ALTER DATABASE MOUNT
Fri Jun 21 08:18:55 2013
Successful mount of redo thread 1, with mount id 2788845359.
Fri Jun 21 08:18:55 2013
Database mounted in Exclusive Mode.
Completed: ALTER DATABASE MOUNT
Fri Jun 21 08:18:55 2013
ALTER DATABASE OPEN
Fri Jun 21 08:18:55 2013
Errors in file /opt/oracle/admin/openview/udump/ora_10395_openview.trc:
ORA-01110: data file 5: '/opt/oracle/oradata/openview/OPC_TEMP_1.dbf'
ORA-01115: IO error reading block from file 5 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
ORA-01110: data file 2: '/opt/oracle/oradata/openview/temp_1.dbf'
ORA-01115: IO error reading block from file 2 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
Fri Jun 21 08:18:55 2013
Errors in file /opt/oracle/admin/openview/udump/ora_10395_openview.trc:
ORA-01110: data file 21: '/opt/oracle/oradata/openview/OPC_TEMP_2.dbf'
ORA-01115: IO error reading block from file 21 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
ORA-01110: data file 2: '/opt/oracle/oradata/openview/temp_1.dbf'
ORA-01115: IO error reading block from file 2 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
ORA-1110 signalled during: ALTER DATABASE OPEN...
Fri Jun 21 08:20:09 2013
重新执行:
alter database open
Fri Jun 21 08:20:31 2013
Errors in file /opt/oracle/admin/openview/udump/ora_10401_openview.trc:
ORA-01110: data file 5: '/opt/oracle/oradata/openview/OPC_TEMP_1.dbf'
ORA-01115: IO error reading block from file 5 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
ORA-01110: data file 2: '/opt/oracle/oradata/openview/temp_1.dbf'
ORA-01115: IO error reading block from file 2 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
Fri Jun 21 08:20:31 2013
Errors in file /opt/oracle/admin/openview/udump/ora_10401_openview.trc:
ORA-01110: data file 21: '/opt/oracle/oradata/openview/OPC_TEMP_2.dbf'
ORA-01115: IO error reading block from file 21 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
ORA-01110: data file 2: '/opt/oracle/oradata/openview/temp_1.dbf'
ORA-01115: IO error reading block from file 2 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
ORA-1110 signalled during: alter database open
...
select status,instance_name from v$instance;
发现数据库在mounted状态下,仍然无法正常启动。
recover database;也不行。
最后确定清空的数据文件及所在表空间后做如下操作:
alter database datafile '/opt/oracle/oradata/openview/temp_1.dbf' offline drop
Fri Jun 21 08:56:45 2013
Completed: alter database datafile '/opt/oracle/oradata/openv
Fri Jun 21 08:57:02 2013
alter database open
Fri Jun 21 08:57:02 2013
Errors in file /opt/oracle/admin/openview/udump/ora_19584_openview.trc:
ORA-01110: data file 21: '/opt/oracle/oradata/openview/OPC_TEMP_2.dbf'
ORA-01115: IO error reading block from file 21 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
ORA-01110: data file 5: '/opt/oracle/oradata/openview/OPC_TEMP_1.dbf'
ORA-01115: IO error reading block from file 5 (block # 1)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
Fri Jun 21 08:57:02 2013
ORA-1110 signalled during: alter database open
...
Fri Jun 21 08:57:50 2013
alter database datafile '/opt/oracle/oradata/openview/OPC_TEMP_1.dbf' offline drop
Fri Jun 21 08:57:50 2013
Completed: alter database datafile '/opt/oracle/oradata/openv
Fri Jun 21 08:58:00 2013
alter database open
ORA-1110 signalled during: alter database open
...
Fri Jun 21 08:58:24 2013
alter database datafile '/opt/oracle/oradata/openview/OPC_TEMP_2.dbf' offline drop
Fri Jun 21 08:58:24 2013
Completed: alter database datafile '/opt/oracle/oradata/openv
Fri Jun 21 08:58:33 2013
alter database open
Beginning crash recovery of 1 threads
Fri Jun 21 08:58:33 2013
Thread recovery: start rolling forward thread 1
Recovery of Online Redo Log: Thread 1 Group 1 Seq 93032 Reading mem 0
Mem# 0 errs 0: /opt/oracle/oradata/openview/redo01.log
Recovery of Online Redo Log: Thread 1 Group 2 Seq 93033 Reading mem 0
Mem# 0 errs 0: /opt/oracle/oradata/openview/redo02.log
Fri Jun 21 08:58:34 2013
Thread recovery: finish rolling forward thread 1
Thread recovery: 551 data blocks read, 249 data blocks written, 1508 redo blocks read
Crash recovery completed successfully
Fri Jun 21 08:58:34 2013
Thread 1 advanced to log sequence 93034
Thread 1 opened at log sequence 93034
Current log# 3 seq# 93034 mem# 0: /opt/oracle/oradata/openview/redo03.log
Successful open of redo thread 1.
Fri Jun 21 08:58:34 2013
SMON: enabling cache recovery
SMON: enabling tx recovery
Fri Jun 21 08:58:35 2013
Completed: alter database open
最終數據庫打開ok;接著開始重建臨時數據文件及表空:
alter tablespace opc_temp add tempfile '/opt/oracle/oradata/openview/OPC_TEMP_3.dbf' SIZE 100M
Fri Jun 21 09:13:42 2013
ORA-3217 signalled during: alter tablespace opc_temp add tempfile '/opt/oracl...
Fri Jun 21 09:15:16 2013
DROP TABLESPACE TEMP
Fri Jun 21 09:15:16 2013
Completed: DROP TABLESPACE TEMP
Fri Jun 21 09:26:12 2013
create temporary tablespace temp tempfile '/opt/oracle/oradata/openview/temp_1.dbf[D[D[D[2[C[C[C[C' size 100M
Fri Jun 21 09:26:40 2013
Completed: create temporary tablespace temp tempfile '/opt/or
alter tablespace opc_temp add tempfile '/opt/oracle/oradata/openview/OPC_TEMP_1.dbf' size 200M
Fri Jun 21 09:32:46 2013
ORA-3217 signalled during: alter tablespace opc_temp add tempfile '/opt/oracl...
drop tablespace opc_temp
Fri Jun 21 09:38:57 2013
Completed: drop tablespace opc_temp
Fri Jun 21 09:41:21 2013
create temporary tablespace opc_temp tempfile '/opt/oracle/oradata/openview/OPC_TEMP_1.dbf' size 200M
Fri Jun 21 09:41:21 2013
Completed: create temporary tablespace opc_temp tempfile '/op
总结测试:此问题后在oracle10g,11g中测试如上操作清空临时数据文件后,然而并不会导致数据库宕机问题。只需要重建临时表空间及数据文件即可。此文件在oracle管理机制中不同于其他数据文件的管理。
临时数据文件简介:
本地管理的(locally managed)临时表空间(temporary tablespace)使用临时的数据文件(datafile)(临时文件),这样的文件与普通数据文件类似,用于磁盘上的分类和临时的存储。
但有以下区别:
● 临时文件总是被设置为 NOLOGGING 模式。
● 用户不能将临时文件设为之读
● 用户不能使用 ALTER DATABASE 语句创建临时文件
● 介质恢复(media recovery)不能识别临时文件:
● BACKUP CONTROLFILE 不会产生与临时文件有关的信息
● CREATE CONTROLFILE 不能设定与临时文件有关的信息
● 当用户创建临时文件或改变其容量时,Oracle并不保证按照用户指定的文件容量为其分配磁盘空间。在某些文件系统(file systems)中(例如UNIX)磁盘块(disk block)并不会在文件创建或改变容量时分配,而是在其被使用之前 才分配。
值得注意的是:
临时文件(tempfile)创建与改变容量操作执行的更快。但是随着临时文件的使用可能会导致磁盘空间不足。
● 临时文件(tempfile)信息可以从 DBA_TEMP_FILES 数据字典表及 V$TEMPFILE 动态性能视图(dynamic performance view)中查询,但是不存在于 DBA_DATA_FILES 或 V$DATAFILE 视图中。
参考资料:
http://www.2cto.com/database/201305/214024.html
扩展内容,临时数据文件及表空间的修改要用如下语句:
alter database tempfile 'file_path/file_name' resize;即可同时也可通过alter tablespace temp_tbs add tempfile 添加数据文件。
undo表空间及数据文件的修改:
undo 数据文件可直接alter database datafile修改,同时undo表空间也可通过alter tablespace undo_tbs add datafie 添加数据文件。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28612416/viewspace-764491/ ,如需转载,请注明出处,否则将追究法律责任。