最近因Linux磁盘满了,需要迁移数据库数据文件到其他磁盘,因该服务器数据库有几个,忘了关闭其中一个而move文件,造成数据库崩溃,现在实施恢复,正常后,再迁移
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
SOLGLE_LO MOUNTED
---手动将控制文件移动回原目录,可是数据库不能打开
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00742: Log read detects lost write in thread %d sequence %d block %d
ORA-00312: online log 2 thread 1: '/u01/data/sys/solgle_db/redo02.log'
--尝试恢复,可惜失败了
SQL> recover database until cancel;
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/data/sys/solgle_db/system01.dbf'
SQL> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
--这样打开也失败
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/data/sys/solgle_db/system01.dbf'
---查看scn状态
SQL> select checkpoint_change# from v$datafile;
CHECKPOINT_CHANGE#
------------------
1083796
1083796
1083796
1083796
1083796
1083796
1083796
1083796
8 rows selected.
SQL> select checkpoint_change# from v$database;
CHECKPOINT_CHANGE#
------------------
1043552
SQL> select checkpoint_change# from v$datafile_heeder;
select checkpoint_change# from v$datafile_heeder
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
1083796
1083796
1083796
1083796
1083796
1083796
1083796
1083796
8 rows selected.
---以上可以查出控制文件没有跟上scn(需要说明的是当前并没有做过数据库备份)
SQL> recover database using backup controlfile until cancel
ORA-00279: change 1083796 generated at 04/29/2015 09:25:21 needed for thread 1
ORA-00289: suggestion :
/u01/app/fast_recovery_area/solgle_db/archivelog/2015_04_29/o1_mf_1_11_%u_.arc
ORA-00280: change 1083796 for thread 1 is in sequence #11
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open resetlogs;
Database altered.
SQL>
----数据库恢复成功