Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

131

积分

1

好友

13

主题
1#
发表于 2012-5-29 18:43:56 | 查看: 4363| 回复: 1
群里的一个话题:
数据库处于归档模式下,所有的日志都存在,但是从来没有进行备份过,如果此时数据库挂掉了改如何进行恢复那?请刘大给一下案例:)



====================================================================================================

comment by maclean.liu

一个好的问题 的基本要素:一个好的标题、 完整的版本信息、 完整的日志信息、 报错信息

你的标题毫无意义,  标题以修改为《没有数据文件备份仅有相关archivelog的情况下如何恢复》
2#
发表于 2012-6-6 20:36:13
ODM TEST:

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE    10.2.0.5.0      Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     45
Next log sequence to archive   47
Current log sequence           47

SQL> create tablespace movetest datafile '/s01/move.dbf' size 10M;

Tablespace created.

SQL> create table  mt tablespace movetest as select * from dba_tables;

Table created.

SQL> select count(*) from mt;

  COUNT(*)
----------
      1610
         




SQL> alter tablespace movetest offline;

Tablespace altered.

SQL> ! rm /s01/move.dbf

SQL> alter tablespace movetest online;
alter tablespace movetest online
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 9 - see DBWR trace file
ORA-01110: data file 9: '/s01/move.dbf'


[oracle@vrh8 ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Wed Jun 6 20:31:36 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: G10R25 (DBID=2652277393)

RMAN>

RMAN>



RMAN> list backup of tablespace movetest;

using target database control file instead of recovery catalog


没有任何 数据文件备份

RMAN> restore tablespace movetest;

Starting restore at 06-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=143 devtype=DISK

creating datafile fno=9 name=/s01/move.dbf
restore not done; all files readonly, offline, or already restored
Finished restore at 06-JUN-12



[oracle@vrh8 ~]$ ls -lh /s01/move.dbf
-rw-r----- 1 oracle oinstall 11M Jun  6 20:32 /s01/move.dbf
[oracle@vrh8 ~]$
[oracle@vrh8 ~]$ strings /s01/move.dbf
}|{z
G10R25
.3K)
MOVETEST


RMAN> recover tablespace movetest;

Starting recover at 06-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=158 devtype=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:02

Finished recover at 06-JUN-12



RMAN> sql ' alter tablespace movetest online';

using target database control file instead of recovery catalog
sql statement:  alter tablespace movetest online


SQL> select count(*) from mt;

  COUNT(*)
----------
      1610



10g以后 在没有数据文件备份 但是有该数据文件从创建开始的所有的  archivelog归档日志的情况下,  可以直接restore datafile  , RMAN会还原一个空的数据文件,之后recover 时 会利用archivelog 来做实现恢复。




10g之前需要使用 alter database create datafile as 命令。

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-12-26 12:04 , Processed in 0.047060 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569