ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 利用完整的数据文件恢复数据库ORCL

利用完整的数据文件恢复数据库ORCL

原创 Linux操作系统 作者:monica_yaotf 时间:2009-04-23 15:47:10 0 删除 编辑

今天下午实现利用已有的数据文件实现数据库的恢复工作。

期间出现了很多问题,一一进行解决。

实现步骤如下:

1.安装数据库,创建数据库实例ORCL。

2.删除安装目录下所有的文件(datafiles,control files,log files)

3.把需要恢复的数据库的数据文件复制到此目录下。

 

4.重建控制文件。内容如下:

CREATE CONTROLFILE REUSE DATABASE "orcl" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 30
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 'D:\oracle\product\10.2.0\oradata\orcl\redo01.log' SIZE 50M,
GROUP 2 'D:\oracle\product\10.2.0\oradata\orcl\redo02.log' SIZE 50M,
GROUP 3 'D:\oracle\product\10.2.0\oradata\orcl\redo03.log' SIZE 50M
DATAFILE
'D:\oracle\product\10.2.0\oradata\orcl\SYSTEM01.DBF',
'D:\oracle\product\10.2.0\oradata\orcl\UNDOTBS01.DBF',
'D:\oracle\product\10.2.0\oradata\orcl\USERS01.DBF',
'D:\oracle\product\10.2.0\oradata\orcl\SYSAUX01.DBF',
'D:\oracle\product\10.2.0\oradata\orcl\REPDBSPACE.DBF',
'D:\oracle\product\10.2.0\oradata\orcl\ODSDBSPACE.DBF',
'D:\oracle\product\10.2.0\oradata\orcl\EXAMPLE01.DBF',
'D:\oracle\product\10.2.0\oradata\orcl\DWDBSPACE.DBF',
'D:\oracle\product\10.2.0\oradata\orcl\DMDBSPACE.DBF',
'D:\oracle\product\10.2.0\oradata\orcl\DBSPACE.DBF'
;

SQL>conn sys/pw as sysdba;

SQL>shutdown immediate;

SQL>startup nomount;

SQL> @d:controlfile.sql

期间出错,

1)提示需要恢复的实例名称和文件头部的实例名称不符。

(原因是创建的实例TEST和需要恢复的实例名称ORCL不一致,后删除实例重建名为ORCL的实例,继续进行。)

2)提示temp.dbf不是数据文件,把此条删除,重新执行。

(temp.dbf不能在此阶段定义,等数据库恢复后再进行创建即可)

3)指定的redo文件大小不符。

(开始是自己创建了3个文件,文件大小为0k,和controlfile.sql内指定的50m不一致。把原始文件复制过来,定义成原始文件大小即可)

5.恢复数据库

recover database using backup controlfile until cancel;

出现错误:

1)介质文件需要需要恢复

(使用命令recover datafile filename;进行逐条恢复)

SQL> recover database using backup controlfile until cancel;
ORA-00279: ?? 70123 (? 02/28/2005 15:22:05 ??) ???? 1 ????
ORA-00289: ??: C:\ORACLE\ORADATA\TESTDB\ARCHIVE\1_3.DBF
ORA-00280: ?? 70123 ???? 1 ???? # 3 ???


指定日志: {=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: ??: RECOVER ??? OPEN RESETLOGS ???????
ORA-01194: ??1?????????????
ORA-01110: ???? 1: 'C:\ORACLE\ORADATA\TESTDB\SYSTEM01.DBF'


ORA-01112: ???????

我们看到如果是abort DOWN机的话,打开数据库都需要应用在线活动日志

这时必须加隐含参数强制打开数据库,并进行导出,重建数据库,导入业务数据

SQL> show parameter spfile                                                                               
                                                                                                         
NAME                                 TYPE        VALUE                                                   
------------------------------------ ----------- -----------------------------                           
spfile                               string      %ORACLE_HOME%\DATABASE\SPFILE                           
                                                 ORACLE_SID%.ORA                                         
                                                                                                         
                                                                                                         
SQL> create pfile='pfiletest.ora' from spfile;                                                           
                                                                                                         
文件已创建。                                                                                             
                                                                                                         
SQL> create pfile='c:\pfiletest.ora' from spfile;                                                        
                                                                                                         
文件已创建。                                                                                             
编辑c:\pfiletest.ora                                                                                     
增加三个参数                                                                                             
                                                                                                         
_allow_resetlogs_corruption=true                                                                         
_corrupted_rollback_segments=true                                                                        
_offline_rollback_segments=true                                                                          
                                                                                                         
SQL> shutdown immediate                                                                                  
ORA-01109: 数据库未打开                                                                                  
                                                                                                         
                                                                                                         
已经卸载数据库。                                                                                         
ORACLE 例程已经关闭。                                                                                    
SQL>                                                                                                     
SQL>                                                                                                     
SQL>                                                                                                     
SQL> startup pfile='c:\pfiletest.ora'                                                                    
ORACLE 例程已经启动。                                                                                    
                                                                                                         
Total System Global Area  135338868 bytes                                                                
Fixed Size                   453492 bytes                                                                
Variable Size             109051904 bytes                                                                
Database Buffers           25165824 bytes                                                                
Redo Buffers                 667648 bytes                                                                
数据库装载完毕。                                                                                         
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项                            

         
SQL> alter database open resetlogs;                                                                      
alter database open resetlogs                                                                            
*                                                                                                        
ERROR 位于第 1 行:                                                                                       
ORA-01092: ORACLE 例程终止。强行断开连接                                                                 
                                                                                                         
                                                                                                         
SQL>                                                                                                     
SQL>                                                                                                     
SQL> exit                                                                                                
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production                                             
With the Partitioning, OLAP and Oracle Data Mining options                                               
JServer Release 9.2.0.1.0 - Production中断开                                                             
                                                                                                         
C:\>sqlplus "/as sysdba"                                                                                 
                                                                                                         
SQL*Plus: Release 9.2.0.1.0 - Production on 星期五 12月 31 14:03:09 2004                                 
                                                                                                         
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.                                      
                                                                                                         
已连接到空闲例程。                                                                                       
                                                                                                         
SQL> startup pfile='c:\pfiletest.ora'                                                                    
ORACLE 例程已经启动。                                                                                    
                                                                                                         
Total System Global Area  135338868 bytes                                                                
Fixed Size                   453492 bytes                                                                
Variable Size             109051904 bytes                                                                
Database Buffers           25165824 bytes                                                                
Redo Buffers                 667648 bytes                                                                
数据库装载完毕。                                                                                         
数据库已经打开。                                                                                         
SQL>                          

 

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

下一篇: ORA-00608错误
请登录后发表评论 登录
全部评论

注册时间:2008-03-27

  • 博文量
    73
  • 访问量
    295655