通过以下事例来说明表空间的恢复,删除表空间内的数据文件,删除后在针对位于该表空间的表进行插入记录以及实施检查点进程

SQL> select a.tablespace_name from dba_tablespaces a;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS

1.1查询表空间

RMAN> backup tablespace users format '/data2/backup/tb_%d_%T_%U';

Starting backup at 14-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/data2/orcl/user01.dbf
channel ORA_DISK_1: starting piece 1 at 14-OCT-15
channel ORA_DISK_1: finished piece 1 at 14-OCT-15
piece handle=/data2/backup/tb_ORCL_20151014_24qjn1b5_1_1 tag=TAG20151014T172700 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 14-OCT-15 Starting Control File and SPFILE Autobackup at 14-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_14/o1_mf_s_893093222_c1w7z7xo_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 14-OCT-15

1.2备份表空间

SQL> ! rm /data2/orcl/user01.dbf;

1.查看数据文件是否存:
[oracle@TEST144239 ~]$ ll /data2/orcl/
总用量 1712960
-rw-r----- 1 oracle oinstall 9846784 10月 14 17:35 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 10月 12 15:18 control01.ctl.bak
drwxr-xr-x 3 oracle oinstall 4096 10月 10 10:48 recover_log
-rw-r----- 1 oracle oinstall 52429312 10月 14 17:35 redo01.log
-rw-r----- 1 oracle oinstall 52429312 10月 14 16:03 redo02.log
-rw-r----- 1 oracle oinstall 52429312 10月 14 16:03 redo03.log
-rw-r----- 1 oracle oinstall 723525632 10月 14 17:35 sysaux01.dbf
-rw-r----- 1 oracle oinstall 754982912 10月 14 17:33 system01.dbf
-rw-r----- 1 oracle oinstall 30416896 10月 14 17:10 temp01.dbf
-rw-r----- 1 oracle oinstall 94380032 10月 14 17:35 undotbs01.dbf
SQL> insert into scott.dept
2 (deptno, dname, loc)
3 values
4 (99, 'xuzhengzhu', '中国'); 1 row created. SQL> commit;
Commit complete. 2.手工执行一次检查点(进行检查点时,会触发数据块从数据缓存区写入到数据文件)
SQL> alter system checkpoint;
alter system checkpoint
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 18465
Session ID: 191 Serial number: 3 3.强制检查点后,告警日志出现错误提示,视图v$recover_file给出了故障数据文件:
[oracle@TEST144239 alert]$ cd /
[oracle@TEST144239 /]$ cd /u01/app/oracle/diag/rdbms/orcl/orcl/alert
[oracle@TEST144239 alert]$ ll
总用量 644
-rw-r----- 1 oracle oinstall 652116 10月 14 17:39 log.xml
[oracle@TEST144239 alert]$ tail -n 50 log.xml
</txt>
</msg>
<msg time='2015-10-14T17:39:08.856+08:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level=''
host_id='TEST144239.localdomain' host_addr='10.88.144.239' module=''
pid=''>
<txt>Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ckpt_18394.trc:
ORA-63999: data file suffered media failure
ORA-01116: error in opening database file 4
ORA-01110: data file 4: &apos;/data2/orcl/user01.dbf&apos;
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

1.3试验(删除表空间)

使用RMAN命令恢复数据文件,此时数据库处于OPEN状态,因此首先需要将表空间脱机,恢复完成之后再将其联机。

RMAN> run{
2> sql 'alter tablespace users offline immediate';
3> set newname for datafile 4 to '/data2/orcl/user01.dbf';
4> restore tablespace users ;
5> switch datafile all;
6> recover tablespace users ;
7> sql 'alter tablespace users online';
8> } sql statement: alter tablespace users offline immediate executing command: SET NEWNAME Starting restore at 14-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 10/14/2015 18:08:26
RMAN-20021: database not set
RMAN-06019: could not translate tablespace name "users"

2.1恢复表空间

问题解决:需要在nomount 的运行状态下,设置BDID,例如该数据库,set DBID=1420421951
RMAN> startup nomount force;
Oracle instance started
Total System Global Area 1937457152 bytes
Fixed Size 2229584 bytes
Variable Size 1241516720 bytes
Database Buffers 687865856 bytes
Redo Buffers 5844992 bytes RMAN> set DBID=1420421951;
executing command: SET DBID RMAN> startup mount force;
Oracle instance started
database mounted
Total System Global Area 1937457152 bytes
Fixed Size 2229584 bytes
Variable Size 1241516720 bytes
Database Buffers 687865856 bytes
Redo Buffers 5844992 bytes RMAN> alter database open; database opened RMAN> run{
2> sql 'alter tablespace users offline immediate';
3> set newname for datafile 4 to '/data2/orcl/user01.dbf';
4> restore tablespace users ;
5> switch datafile all;
6> recover tablespace users ;
7> sql 'alter tablespace users online';
8> } sql statement: alter tablespace users offline immediate executing command: SET NEWNAME Starting restore at 15-OCT-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=131 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=199 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=72 device type=DISK channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00004 to /data2/orcl/user01.dbf
channel ORA_DISK_1: reading from backup piece /data2/backup/tb_ORCL_20151014_24qjn1b5_1_1
channel ORA_DISK_1: piece handle=/data2/backup/tb_ORCL_20151014_24qjn1b5_1_1 tag=TAG20151014T172700
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 15-OCT-15 Starting recover at 15-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3 starting media recovery archived log for thread 1 with sequence 13 is already on disk as file /data2/orcl/recover_log/archive_log/1_13_892917066.dbf
archived log for thread 1 with sequence 14 is already on disk as file /data2/orcl/recover_log/archive_log/1_14_892917066.dbf
archived log for thread 1 with sequence 15 is already on disk as file /data2/orcl/recover_log/archive_log/1_15_892917066.dbf
archived log for thread 1 with sequence 16 is already on disk as file /data2/orcl/recover_log/archive_log/1_16_892917066.dbf
archived log for thread 1 with sequence 17 is already on disk as file /data2/orcl/recover_log/archive_log/1_17_892917066.dbf
archived log file name=/data2/orcl/recover_log/archive_log/1_13_892917066.dbf thread=1 sequence=13
archived log file name=/data2/orcl/recover_log/archive_log/1_14_892917066.dbf thread=1 sequence=14
media recovery complete, elapsed time: 00:00:00
Finished recover at 15-OCT-15 sql statement: alter tablespace users online

2.2解决恢复失败问题

SQL> conn sys/Sina.2015@study as sysdba;
Connected.
SQL> select * from scott.dept; DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
99 xuzhengzhu ??????

3.0查看恢复后结果

  另外: 也可以使用下面的命令完成同样的功能,注意表空间内有多个数据文件的情形,而仅有单个数据文件损坏则采用下面的方式处理更为妥当。

 run{
sql 'alter database datafile 4 offline';
set newname for datafile 4 to '/data2/orcl/user01.dbf';
restore datafile 4;
switch datafile all;
recover datafile 4;
sql 'alter database datafile 4 online';}

恢复单个数据文件

RMAN备份与恢复之表空间的更多相关文章

  1. 【RMAN】TSPITR--RMAN表空间基于时间点的自动恢复

    [RMAN]TSPITR--RMAN表空间基于时间点的自动恢复 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其 ...

  2. RMAN恢复 增加表空间后控制文件丢失

    查看目前的控制文件位置 SQL> select name from v$controlfile; NAME-------------------------------------------- ...

  3. 如何通过RMAN使用传输表空间迁移到不同的Endian平台 (Doc ID 371556.1)

    How to Migrate to different Endian Platform Using Transportable Tablespaces With RMAN (Doc ID 371556 ...

  4. 转://RMAN跨平台可传输表空间和数据库

    参考链接: http://blog.itpub.net/23135684/viewspace-776048/ http://blog.sina.com.cn/s/blog_69e7b8d7010164 ...

  5. SYSTEM 表空间管理及备份恢复

    标签: systemoraclesqldatabasefile数据库 2010-11-28 18:14 12689人阅读 评论(0) 收藏 举报 分类: -----Oracle备份恢复(16) 版权声 ...

  6. Oracle DB 执行表空间时间点恢复

    • 列出在执行表空间时间点恢复(TSPITR) 时会发生的操作 • 阐释TSPITR 使用的术语的定义 • 确定适合将TSPITR 用作解决方案的情况 • 确定时间点恢复的正确目标时间 • 确定不能使 ...

  7. Oracle 阅读器-刚看完表空间回复的详细解释

    (一) 当使用一个控制文件的备份恢复,例如下面的附图.使用备份控制文件恢复位置 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZGVtb25zb24=/fo ...

  8. 数据泵 TTS(传输表空间技术)

    1.源库准备环境 --创建被传输的表空间create tablespace tts logging datafile '/home/oracle/app/oradata/orcl/tts01.dbf' ...

  9. Oracle误删除表空间的恢复

    对于误删除表空间的恢复,本文通过基于数据库的时间点恢复和基于表空间的时间点恢复分别加以讨论 一 通过基于数据库的时间点恢复被误删除的表空间 1 需要注意的事项 a 基于数据库的时间点恢复将会回退整个数 ...

随机推荐

  1. JSON金额解析BUG的解决过程

    [原创申明:文章为原创,欢迎非盈利性转载,但转载必须注明来源] 这是在我们开发的一个支付系统中暴露的一个BUG,问题本身比较简单,有意思的是解决问题的过程.将过程分享出来,希望能够对大家有所帮助. 一 ...

  2. BZOJ 3223: Tyvj 1729 文艺平衡树

    3223: Tyvj 1729 文艺平衡树 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 3628  Solved: 2052[Submit][Sta ...

  3. 高级语言虚拟机的一点理解,对比.NET和Java平台

    最近学习了一些高级语言虚拟机的知识,在此对.NET平台和java平台做一个简单的比较.对java平台已经很熟了,所以此处只介绍.NET平台下的一些概念. 一.CLI 通用语言基础架构(Common L ...

  4. html5shiv.js-让IE浏览器支持HTML5标准

    兼容性IE8及以下IE版本 浏览器IE8及以下IE版本对HTML5标签的支持是有限的,我们可以通过在网页中添加脚本的方式来解决目前IE浏览器对HTML5支持的问题. <!–[if IE]> ...

  5. coursera-miniproject stopwatch任务总结

    ---恢复内容开始--- 首先是miniproject的说明: combin text drawing in canvas with time to build digital stopwatch. ...

  6. Apache Spark Shark的简介

    Shark是构建在Spark和Hive基础之上的数据仓库. 目前,Shark已经完成学术使命,终止开发,但其架构和原理仍具有借鉴意义. 它提供了能够查询Hive中所存储数据的一套SQL接口,兼容现有的 ...

  7. WPF动画之线性插值动画(1)

    XAML代码: <Window x:Class="线性插值动画.MainWindow" xmlns="http://schemas.microsoft.com/wi ...

  8. 无废话MVC入门教程二[第一个小Demo]

    mvc技术交流,欢迎加群: 本文目标 1.了解"模型"."视图"."控制器"的创建.调试和使用过程. 本文目录 1.创建模型 2.创建视图 ...

  9. oracle常用函数以及调用入参为record的存储过程的方法,

    转自:http://www.cnblogs.com/zhangronghua/archive/2007/08/20/862812.html SQL中的单记录函数1.ASCII返回与指定的字符对应的十进 ...

  10. 【ARTS】01_16_左耳听风-20190225~20190303

    ARTS: Algrothm: leetcode算法题目 Review: 阅读并且点评一篇英文技术文章 Tip/Techni: 学习一个技术技巧 Share: 分享一篇有观点和思考的技术文章 Algo ...