Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1265374
  • 博文数量: 1211
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 14340
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-09 11:20
文章分类

全部博文(1211)

文章存档

2011年(1)

2008年(1210)

我的朋友

分类: 服务器与存储

2008-06-11 17:02:20

准备工作 下面的信息说明了如果是完全恢复,可以看到insert into test1 values(16);,否则可以看到15,就是被归档的那个。17因为没有提交,是不会被恢复的。 
 
SQL> conn internal 
SQL> archive log list; 
Database log mode Archive Mode 
Automatic archival Enabled 
Archive destination d:\BACKUPDB\archive 
Oldest online log sequence 14 
Next log sequence to archive 16 
Current log sequence 16 
SQL> conn lunar/lunar 
SQL> select * from test1 where a>10; 
SQL> insert into test1 values(15); 
SQL> alter system switch logfile; 
System altered. 
SQL> insert into test1 values(16); 
SQL> insert into test1 values(17); 
新开一个session,进行shutdown abort 
 
E:\>sqlplus internal 
SQL> shutdown abort 
ORACLE 例程已经关闭。 
 
把热备的数据文件和控制文件拷贝过来 
mount数据库 
E:\>sqlplus internal 
SQL> startup mount 
ORACLE instance started. 
 
ORA-01991: invalid password file 'd:\oracle1\ora81\DATABASE\PWDbackup.ORA' 
 
根据提示重建口令文件 
SQL> host 
E:\>del d:\oracle1\ora81\DATABASE\PWDbackup.ORA 
E:\>orapwd file=d:\oracle1\ora81\DATABASE\PWDbackup.ORA password=oracle entries= 
10 
用to trace备份控制文件 
SQL> alter database backup controlfile to trace; 
Database altered. 
找到这个跟踪文件并编辑它 
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> shutdown immediate 
ORA-01109: database not open 
 
Database dismounted. 
ORACLE instance shut down. 
SQL> startup nomount 
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 
 
SQL> @D:\BACKUPDB\udump\ORA02176.sql 
ORA-01081: cannot start already-running ORACLE - shut it down first 
CREATE CONTROLFILE REUSE DATABASE "BACKUP" NORESETLOGS ARCHIVELOG 
ERROR at line 1: 
ORA-01503: CREATE CONTROLFILE failed 
ORA-01565: error in identifying file 'D:\BACKUPDB\REDO01.LOG' 
ORA-27041: unable to open file 
OSD-04002: 无法打开文件 
O/S-Error: (OS 2) 系统找不到指定的文件。 
 
ORA-01507: database not mounted 
ALTER SYSTEM ARCHIVE LOG ALL 
ERROR at line 1: 
ORA-01507: database not mounted 
ALTER DATABASE OPEN 
ERROR at line 1: 
ORA-01507: database not mounted 
可见,因为缺少所有的redo,重建控制文件是行不通的。 
Mount数据库
SQL> alter database mount; 
Database altered. 
用using backup controlfile进行恢复 
SQL> alter database mount; 
Database altered. 
SQL> recover database until cancel using backup controlfile; 
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: {=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-00308: cannot open archived log 'D:\BACKUPDB\ARCHIVE\BACKUPT001S00017.ARC' 
ORA-27041: unable to open file 
OSD-04002: 无法打开文件 
O/S-Error: (OS 2) 系统找不到指定的文件。 
 
用Open Resetlog 打开数据库 
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; 
Database altered. 
 
验证恢复结果:不完全恢复,redo里面的数据丢失了 
SQL> conn lunar/lunar 
SQL> select * from test1 where a>10; 
SQL> conn internal 
SQL> archive log list; 
Database log mode Archive Mode 
Automatic archival Enabled 
Archive destination d:\BACKUPDB\archive 
Oldest online log sequence 0 
Next log sequence to archive 1 
Current log sequence 1 
说明: 
1. 把热备的数据文件和控制文件拷贝过来   
2. mount数据库   
3. 根据提示重建口令文件 
4. 用using backup controlfile进行恢复   
5. Open Resetlog 打开数据库  
阅读(599) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~