准备工作
下面的操作,说明如果完全恢复,可以看到insert into test1 values(11);,因为11是redo中已经commit的,12是redo中没有commit的
SQL> insert into test1 values(8);
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test1 values(9);
1 row created.
SQL> alter system switch logfile;
System altered.
SQL> conn internal
Connected.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination d:/BACKUPDB/archive
Oldest online log sequence 11
Next log sequence to archive 13
Current log sequence 13
SQL>
SQL> conn lunar/lunar
Connected.
SQL> insert into test1 values(10);
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test1 values(11);
1 row created.
SQL> conn internal
Connected.
SQL> conn lunar/lunar
Connected.
SQL> insert into test1 values(12);
1 row created.
SQL>
然后单独开启一个实例,再shutdown immediate
(这样,insert into test1 values(12);就是没有提交的数据了,如果完全恢复应该一直可以看到insert into test1 values(11);)
Microsoft Windows 2000 [Version 5.00.2195]
(C) 版权所有 1985-2000 Microsoft Corp.
E:/>sqlplus internal
SQL*Plus: Release 8.1.7.0.0 - Production on 星期一 10月 21 00:58:38 2002
(c) Copyright 2000 Oracle Corporation. All rights reserved.
连接到:
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL>
拷贝热备的所有控制文件和数据文件
mount数据库
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 25856028 bytes
Fixed Size 75804 bytes
Variable Size 8925184 bytes
Database Buffers 16777216 bytes
Redo Buffers 77824 bytes
ORA-01991: ???????'d:/oracle1/ora81/DATABASE/PWDbackup.ORA'
根据提示,重建口令文件
SQL> host
Microsoft Windows 2000 [Version 5.00.2195]
(C) 版权所有 1985-2000 Microsoft Corp.
E:/>cd d:/oracle1/ora81/DATABASE/PWDbackup
系统找不到指定的路径。
E:/>cd d:/oracle1/ora81/DATABASE
E:/>d:
D:/oracle1/ora81/database>del PWDbackup.ORA
D:/oracle1/ora81/database>dir PWDbackup.ORA
驱动器 D 中的卷是 Program
卷的序列号是 D0E6-FA1C
D:/oracle1/ora81/database 的目录
找不到文件
D:/oracle1/ora81/database>orapwd file=d:/oracle1/ora81/DATABASE/PWDbackup.ORA pa
ssword=oracle entries=10;
D:/oracle1/ora81/database>exit
用to trace备份控制文件
SQL> alter database backup controlfile to trace;
数据库已更改。
shutdown immediate关闭数据库
SQL> shutdown immediate;
ORA-01109: ??????
已经卸载数据库。
ORACLE 例程已经关闭。
SQL>
找到那个控制文件,然后编辑:
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "BACKUP" NORESETLOGS ARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 254
MAXINSTANCES 1
MAXLOGHISTORY 453
LOGFILE
GROUP 1 'D:/BACKUPDB/REDO01.LOG' SIZE 1M,
GROUP 2 'D:/BACKUPDB/REDO02.LOG' SIZE 1M,
GROUP 3 'D:/BACKUPDB/REDO03.LOG' SIZE 1M
DATAFILE
'D:/BACKUPDB/SYSTEM01.DBF',
'D:/BACKUPDB/RBS01.DBF',
'D:/BACKUPDB/USERS01.DBF',
'D:/BACKUPDB/TEMP01.DBF',
'D:/BACKUPDB/TOOLS01.DBF',
'D:/BACKUPDB/INDX01.DBF'
CHARACTER SET ZHS16GBK
;
RECOVER DATABASE
ALTER SYSTEM ARCHIVE LOG ALL;
ALTER DATABASE OPEN;
重建控制文件,并且恢复数据库
SQL> startup nomount
ORACLE 例程已经启动。
Total System Global Area 25856028 bytes
Fixed Size 75804 bytes
Variable Size 8925184 bytes
Database Buffers 16777216 bytes
Redo Buffers 77824 bytes
SQL>
SQL> @D:/BACKUPDB/udump/ORA01904.sql
ORA-01081: cannot start already-running ORACLE - shut it down first
Cluster altered.
ORA-00279: change 424112 generated at 10/20/2002 20:40:52 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00001.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:/BACKUPDB/SYSTEM01.DBF'
SQL>
关闭数据库
除了redo log file中没有提交的数据,其他都可以找回来
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
重新mount,作完全恢复(recover database;)
SQL> startup mount
ORACLE instance started.
Total System Global Area 25856028 bytes
Fixed Size 75804 bytes
Variable Size 8925184 bytes
Database Buffers 16777216 bytes
Redo Buffers 77824 bytes
Database mounted.
SQL>
SQL> recover database;
ORA-00279: change 424112 generated at 10/20/2002 20:40:52 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00001.ARC
ORA-00280: change 424112 for thread 1 is in sequence #1
Specify log: {<RET>=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:/BACKUPDB/ARCHIVE/BACKUPT001S00002.ARC
ORA-00280: change 424125 for thread 1 is in sequence #2
ORA-00278: log file 'D:/BACKUPDB/ARCHIVE/BACKUPT001S00001.ARC' no longer needed
for this recovery
ORA-00279: change 424135 generated at 10/20/2002 21:55:35 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00003.ARC
ORA-00280: change 424135 for thread 1 is in sequence #3
ORA-00278: log file 'D:/BACKUPDB/ARCHIVE/BACKUPT001S00002.ARC' no longer needed
for this recovery
ORA-00279: change 424139 generated at 10/20/2002 21:57:42 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00004.ARC
ORA-00280: change 424139 for thread 1 is in sequence #4
ORA-00278: log file 'D:/BACKUPDB/ARCHIVE/BACKUPT001S00003.ARC' no longer needed
for this recovery
ORA-00279: change 424143 generated at 10/20/2002 21:57:54 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00005.ARC
ORA-00280: change 424143 for thread 1 is in sequence #5
ORA-00278: log file 'D:/BACKUPDB/ARCHIVE/BACKUPT001S00004.ARC' no longer needed
for this recovery
ORA-00279: change 444145 generated at 10/20/2002 22:01:23 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00006.ARC
ORA-00280: change 444145 for thread 1 is in sequence #6
ORA-00278: log file 'D:/BACKUPDB/ARCHIVE/BACKUPT001S00005.ARC' no longer needed
for this recovery
ORA-00279: change 464194 generated at 10/20/2002 22:24:10 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00007.ARC
ORA-00280: change 464194 for thread 1 is in sequence #7
ORA-00278: log file 'D:/BACKUPDB/ARCHIVE/BACKUPT001S00006.ARC' no longer needed
for this recovery
ORA-00279: change 484347 generated at 10/21/2002 00:16:14 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00008.ARC
ORA-00280: change 484347 for thread 1 is in sequence #8
ORA-00278: log file 'D:/BACKUPDB/ARCHIVE/BACKUPT001S00007.ARC' no longer needed
for this recovery
ORA-00279: change 484401 generated at 10/21/2002 00:30:27 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00009.ARC
ORA-00280: change 484401 for thread 1 is in sequence #9
ORA-00278: log file 'D:/BACKUPDB/ARCHIVE/BACKUPT001S00008.ARC' no longer needed
for this recovery
ORA-00279: change 484453 generated at 10/21/2002 00:33:51 needed for thread 1
ORA-00289: suggestion : D:/BACKUPDB/ARCHIVE/BACKUPT001S00010.ARC
ORA-00280: change 484453 for thread 1 is in sequence #10
ORA-00278: log file 'D:/BACKUPDB/ARCHIVE/BACKUPT001S00009.ARC' no longer needed
for this recovery
Log applied.
Media recovery complete.
SQL>
打开数据库
SQL> alter database open;
Database altered.
验证恢复结果:完全恢复
SQL> conn lunar/lunar
Connected.
SQL> select * from test1;
A
----------
1
2
3
4
5
6
7
8
9
10
11
11 rows selected.
SQL>
SQL> conn internal
Connected.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination d:/BACKUPDB/archive
Oldest online log sequence 12
Next log sequence to archive 14
Current log sequence 14
SQL>
说明:
1. 把热备的控制文件和数据文件拷贝过来
2. mount数据库
3. 根据提示,重建口令文件
4. 用to trace备份控制文件
5. shutdown immediate关闭数据库
6. 找到那个控制文件,然后编辑:
7. 重建控制文件,并且恢复数据库
8. 关闭数据库
9. 重新mount,作完全恢复(recover database;)
10. 打开数据库
http://www.cnoug.org/viewthread.php?tid=91&highlight=%2Blunar