数据库恢复案例大全

仅仅丢失一个普通用户数据文件的恢复A(联机恢复)

(例如,丢失D:BACKUPDBUSERS01.DBF

准备工作, 通过下面的工作,如果完全恢复,应该可以看到;insert into test1 values(2);

SQL> conn lunar/lunar

SQL> select * from tab;

TESTBACKUP3 TABLE

SQL> create table test1 (a number);

SQL> insert into test1 values(1);

SQL> alter system switch logfile;

SQL> commit;

SQL> alter system switch logfile;

SQL> insert into test1 values(2);

SQL> commit;

SQL> alter system switch logfile;

SQL> conn internal

SQL> archive log list

数据库日志模式 存档模式

自动存档 启用

存档终点 d:BACKUPDBarchive

最早的概要信息日志序列 3

下一个存档日志序列 5

当前日志序列 5

shutdown abort关闭例程,模拟数据文件丢失

SQL> shutdown abort

ORACLE 例程已经关闭。

Mount数据库

SQL> startup mount

数据库装载完毕。

使损坏的数据文件脱机

SQL> alter database datafile 'D:BACKUPDBUSERS01.DBF' offline;

打开数据库

SQL> alter database open;

拷贝刚才热备的数据文件(USERS01.DBF

恢复损坏的数据文件

SQL> recover datafile 'D:BACKUPDBUSERS01.DBF';

ORA-00279: ?? 424116 (? 10/20/2002 20:42:04 ??) ???? 1 ????

ORA-00289: ??: D:BACKUPDBARCHIVEBACKUPT001S00001.ARC

ORA-00280: ?? 424116 ???? 1 ???? # 1 ???

指定日志: {=suggested | filename | AUTO | CANCEL}

auto

ORA-00279: ?? 424125 (? 10/20/2002 20:44:14 ??) ???? 1 ????

ORA-00289: ??: D:BACKUPDBARCHIVEBACKUPT001S00002.ARC

ORA-00280: ?? 424125 ???? 1 ???? # 2 ???

ORA-00278: ??????????? 'D:BACKUPDBARCHIVEBACKUPT001S00001.ARC'

……………………..

已应用的日志。

完成介质恢复。

使恢复完成的数据文件联机

SQL> alter database datafile 'D:BACKUPDBUSERS01.DBF' online;

验证恢复的结果:完全恢复

SQL> select * from tab;

TNAME TABTYPE CLUSTERID

SQL> select * from test1;

说明:

1. shutdown abort关闭例程,模拟数据文件丢失

2. Mount数据库

3. 使损坏的数据文件脱机

4. 打开数据库

5. 拷贝刚才热备的数据文件(USERS01.DBF

6. 恢复损坏的数据文件

7. 使恢复完成的数据文件联机

shutdown immedate,恢复全部数据文件(不包括controlredo) (把热备的数据文件拷贝回来,不包括controlredo
SQL> conn internal
SQL> shutdown immediate;
复制全部热备的数据文件过来(完全恢复成功!)
mount
数据库
SQL> startup mount
完全恢复数据库
SQL> recover database;
ORA-00279: change 424112 generated at 10/20/2002 20:40:52 needed for thread 1
ORA-00289: suggestion : D:BACKUPDBARCHIVEBACKUPT001S00001.ARC
ORA-00280: change 424112 for thread 1 is in sequence #1

Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 424125 generated at 10/20/2002 20:44:14 needed for thread 1
ORA-00289: suggestion : D:BACKUPDBARCHIVEBACKUPT001S00002.ARC
ORA-00280: change 424125 for thread 1 is in sequence #2
ORA-00278: log file 'D:BACKUPDBARCHIVEBACKUPT001S00001.ARC' no longer needed
for this recovery
……………………………………………..
Log applied.
Media recovery complete.
打开数据库
SQL> alter database open;
验证恢复结果:完全恢复
SQL> conn lunar/lunar
SQL> select * from test1;

完全恢复成功! 说明:
1.
复制全部热备的数据文件过来
2. mount
数据库
3.
完全恢复数据库
4.
打开数据库

shutdown abort的情况,恢复全部控制文件和数据文件(不包括redo) 准备工作 (这样,insert into test1 values(13);就是没有提交的数据了,如果完全恢复,应该一直可以看到insert into test1 values(12);
SQL> conn lunar/lunar
SQL> select * from test1;
SQL> insert into test1 values(12);

commit;
SQL> insert into test1 values(13);

单开一个session,用来shutdow abort
E:>sqlplus internal
SQL> shutdown abort
ORACLE
例程已经关闭。

拷贝所有的控制文件和数据文件(不包括redo mount数据库,按照提示重建口令文件

SQL> startup mountORACLE instance started. ORA-01991: invalid password file 'd:oracle1ora81DATABASEPWDbackup.ORA'
SQL> hostE:>cd d:oracle1ora81DATABASE D:oracle1ora81database>del PWDbackup.ORA D:oracle1ora81database>orapwd file=d:oracle1ora81DATABASEPWDbackup.ORA pa ssword=oracle entries=10
/* orapwd Usage: orapwd file= password= entries=

where

file - name of password file (mand),

password - password for SYS and INTERNAL (mand),

entries - maximum number of distinct DBAs and OPERs (opt),

There are no spaces around the equal-to (=) character. */

D:oracle1ora81database>exit 这时,试图完全恢复数据库是不成功的
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
to trace备份控制文件
SQL>alter database backup controlfile to trace;
SQL>shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
找到并且编辑控制文件
STARTUP NOMOUNT

CREATE CONTROLFILE REUSE DATABASE "BACKUP" NORESETLOGS ARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 254
MAXINSTANCES 1
MAXLOGHISTORY 453
LOGFILE
GROUP 1 'D:BACKUPDBREDO01.LOG' SIZE 1M,
GROUP 2 'D:BACKUPDBREDO02.LOG' SIZE 1M,
GROUP 3 'D:BACKUPDBREDO03.LOG' SIZE 1M
DATAFILE
'D:BACKUPDBSYSTEM01.DBF',
'D:BACKUPDBRBS01.DBF',
'D:BACKUPDBUSERS01.DBF',
'D:BACKUPDBTEMP01.DBF',
'D:BACKUPDBTOOLS01.DBF',
'D:BACKUPDBINDX01.DBF'
CHARACTER SET ZHS16GBK;
RECOVER DATABASE
ALTER SYSTEM ARCHIVE LOG ALL;
ALTER DATABASE OPEN;
重建控制文件
SQL> startup nomount
SQL> @D:BACKUPDBudumpORA01532.sql
ORA-01081: cannot start already-running ORACLE - shut it down first
Control file created.
ORA-00279: change 424112 generated at 10/20/2002 20:40:52 needed for thread 1
ORA-00289: suggestion : D:BACKUPDBARCHIVEBACKUPT001S00001.ARC
ORA-00280: change 424112 for thread 1 is in sequence #1
ORA-00308: cannot open archived log 'ALTER'
ORA-27041: unable to open file
OSD-04002:
无法打开文件
O/S-Error: (OS 2)
系统找不到指定的文件。
ALTER DATABASE OPEN
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: 'D:BACKUPDBSYSTEM01.DBF'

shutdown immediate
,然后重新恢复数据库
SQL> shutdown immediate;
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

完全恢复数据库
SQL> recover database;
ORA-00279: change 424112 generated at 10/20/2002 20:40:52 needed for thread 1
ORA-00289: suggestion : D:BACKUPDBARCHIVEBACKUPT001S00001.ARC
ORA-00280: change 424112 for thread 1 is in sequence #1

Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 424125 generated at 10/20/2002 20:44:14 needed for thread 1
ORA-00289: suggestion : D:BACKUPDBARCHIVEBACKUPT001S00002.ARC
ORA-00280: change 424125 for thread 1 is in sequence #2
ORA-00278: log file 'D:BACKUPDBARCHIVEBACKUPT001S00001.ARC' no longer needed
for this recovery
………………………………………..
Log applied.
Media recovery complete.
打开数据库
SQL> alter database open;
SQL> conn lunar/lunar
SQL> select * from test1;
说明:
1.
拷贝所有的控制文件和数据文件(不包括redo
2. mount
数据库,按照提示重建口令文件
3.
这时,试图完全恢复数据库是不成功的
4.
to trace备份控制文件
5.
找到并且编辑控制文件
6.
重建控制文件
7. shutdown immediate
,然后重新恢复数据库
8.
完全恢复数据库
9.
打开数据库

仅仅丢失一个普通用户数据文件的恢复B(脱机恢复) 准备工作 按照下面的输入,如果全部恢复,应该可以看到insert into test1 values(13),因为insert into test1 values(14)没提交。
SQL> conn lunar/lunar
SQL> insert into test1 values(13);
SQL> insert into test1 values(14);

Shutdown immediate,然后模拟数据文件丢失 单开一个session,执行shutdown immediate(保证insert into test1 values(14);没有被隐式提交)
E:>sqlplus internal
SQL>shutdown immediate
ORACLE
例程已经关闭。 模拟数据文件丢失,然后用热备覆盖这个文件
mount
数据库
E:>sqlplus internal
SQL>shutdown immediate
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist

SQL> startup mount 使损坏的数据文件脱机
SQL>alter database datafile 'D:BACKUPDBUSERS01.DBF' offline;
Database altered.
恢复数据文件
SQL> recover datafile 'D:BACKUPDBUSERS01.DBF';
ORA-00279: change 424116 generated at 10/20/2002 20:42:04 needed for thread 1
ORA-00289: suggestion : D:BACKUPDBARCHIVEBACKUPT001S00001.ARC
ORA-00280: change 424116 for thread 1 is in sequence #1

Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 424125 generated at 10/20/2002 20:44:14 needed for thread 1
ORA-00289: suggestion : D:BACKUPDBARCHIVEBACKUPT001S00002.ARC
ORA-00280: change 424125 for thread 1 is in sequence #2
ORA-00278: log file 'D:BACKUPDBARCHIVEBACKUPT001S00001.ARC' no longer needed
for this recovery
…………………………………………………………
Log applied.
Media recovery complete.
使恢复的数据文件联机
SQL>alter database datafile 'D:BACKUPDBUSERS01.DBF' online;
打开数据库
SQL>alter database open;
Database altered.
这时需要重新启动数据库,并完全恢复数据库
SQL> conn lunar/lunar
SQL> select count(*) from test;
select count(*) from test
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> conn internal
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
重新启动数据库,
SQL> startup
ORACLE instance started.
recover database再次恢复数据库
SQL> conn internal
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01124: cannot recover data file 1 - file is in use or recovery
ORA-01110: data file 1: 'D:BACKUPDBSYSTEM01.DBF'
重新使恢复的表空间联机

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/1724534/viewspace-982411/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/1724534/viewspace-982411/

你可能感兴趣的:(数据库恢复案例大全)