undo 损坏案列
公司一台测试环境的基于linux 平台下 oracle 11.2.0.3 的数据库,为开归档,未备份。 21号晚上,因/目录下 空间使用%100,oracle
公司一台测试环境的基于linux 平台下 Oracle 11.2.0.3 的数据库,为开归档,未备份。 21号晚上,因/目录下 空间使用%100,oracle HOME目录在系统 / 目录下:
因硬盘资源占尽,不能连接操作,oracle 数据库挂起。
某人的操作,查看undotbs1 占用最大,,通过mv 移动到 另一目录,同时系统被重启,使得undotbs1 数据文件损坏,不能使用,最后又做了一个rm 操作, 重启库,导致故障出现!
报错一:
Wed Jan 22 09:42:50 2014
ALTER DATABASE OPEN
Errors in file /u01/app/oracle/diag/rdbms/gtadata13/gtadata13/trace/gtadata13_dbw0_4245.trc:
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf'
ORA-27047: unable to read the header block of file
Linux-x86_64 Error: 25: Inappropriate ioctl for device
Additional information: 1
Wed Jan 22 09:42:52 2014
Checker run found 1 new persistent data failures
Errors in file /u01/app/oracle/diag/rdbms/gtadata13/gtadata13/trace/gtadata13_ora_4361.trc:
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf'
ORA-1157 signalled during: ALTER DATABASE OPEN...
--- 就是oracle 在mount后,不能加载到open 状态。
2 接下来操作: 因为undo tablespace 数据文件undotbs1 没有了,想通过重建一个undo 表空间 undotbs2 把数据库启动到open 状态
操作:
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL > CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '/XXXX.DBF' SIZE 32M AUTOEXTEND ON NEXT 32M MAXSIZE 10G; --重创建表空间
SQL > SELECT * FROM V$TABLESAPCE SELECT NAME,STATUS FROM V$DATAFILE -- 查询其状态值
SQL > ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS2 SCOPE=BOTH -- 通过show parameter undo 查看是否使用。
3 此时,数据库可以open起来, 但是通过client ,或者其他用户连接时,报错:
报错二
SQL> conn input/INPUT
ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-00376: file 3 cannot be read at this time
ORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf'
ORA-02002: error while writing to audit trail
ORA-00604: error occurred at recursive SQL level 1
ORA-00376: file 3 cannot be read at this time
ORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf'
4 根据报错,发现不仅仅是 undotbs1数据文件有问题,还有开启了审计 audit: 如是
先关闭审计
SQL > SHOW PARAMETER AUDIT
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/gtadata1
3/adump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string DB
SQL > alter system set audit_trail=none scope=spfile -- 设置后需要重启库。 --具体见审计
5 再通过对undotbs1数据文件操作,使其offline 处理(看行否)
SQL > alter database datafile 3 offline drop ;
6 通过 v$logfile,dba_tablespaces, dba_data_files 查看数据表空间,数据文件的状态:
SQL> select tablespace_name,file_id,file_name from dba_data_files;
TABLESPACE_NAME FILE_ID FILE_NAME
------- ---------- -------------------------------------------------------------
USERS 4 /u01/app/oracle/oradata/gtadata13/users01.dbf
UNDOTBS1 3 /u01/app/oracle/oradata/gtadata13/undotbs01.dbf
SQL> select status,tablespace_name from dba_tablespaces;
STATUS TABLESPACE_NAME
--------- ------------------------------
ONLINE SYSTEM
ONLINE SYSAUX
ONLINE UNDOTBS1
7 此时发现undotbs1 数据文件还在,同时undotbs1 表空online
如是操作: