(1)备份数据库

在使用RMAN进行数据库恢复之前,先用RMAN进行全库备份

[oracle@redhat6 ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed May 16 14:32:54 2018

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1486787650)

RMAN> backup database;

Starting backup at 16-MAY-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/orcl/mark.bdf
input datafile file number=00011 name=/u01/app/oracle/oradata/orcl/tbs01.bdf
input datafile file number=00012 name=/u01/app/oracle/oradata/orcl/tbs03.dbf
input datafile file number=00013 name=/u01/app/oracle/oradata/orcl/tbs04.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 16-MAY-18
channel ORA_DISK_1: finished piece 1 at 16-MAY-18
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/01t31soh_1_1 tag=TAG20180516T144121 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:33
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00008 name=/u01/app/oracle/oradata/orcl/tbs_32k.dbf
channel ORA_DISK_1: starting piece 1 at 16-MAY-18
channel ORA_DISK_1: finished piece 1 at 16-MAY-18
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/02t31sta_1_1 tag=TAG20180516T144121 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 16-MAY-18
channel ORA_DISK_1: finished piece 1 at 16-MAY-18
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/03t31stc_1_1 tag=TAG20180516T144121 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 16-MAY-18

(2)删除数据文件

查看数据库的数据文件信息:

select      t."NAME",
d."NAME",
d."FILE#"
from v$tablespace t,
v$datafile d
where t."TS#" = d."TS#"
order by t.ts#; NAME NAME FILE#
------------------------------ -------------------------------------------------------------------------------- ----------
SYSTEM /u01/app/oracle/oradata/orcl/system01.dbf 1
SYSAUX /u01/app/oracle/oradata/orcl/sysaux01.dbf 2
UNDOTBS1 /u01/app/oracle/oradata/orcl/undotbs01.dbf 3
USERS /u01/app/oracle/oradata/orcl/users01.dbf 4
EXAMPLE /u01/app/oracle/oradata/orcl/example01.dbf 5
TBS_32K /u01/app/oracle/oradata/orcl/tbs_32k.dbf 8
MARK /u01/app/oracle/oradata/orcl/mark.bdf 9
TBS01 /u01/app/oracle/oradata/orcl/tbs01.bdf 11
TBS03 /u01/app/oracle/oradata/orcl/tbs03.dbf 12
TBS04 /u01/app/oracle/oradata/orcl/tbs04.dbf 13
10 rows selected

删除一个数据文件,这里把文件编号为13的数据文件给删除:

[oracle@redhat6 ~]$ rm -f /u01/app/oracle/oradata/orcl/tbs04.dbf

(3)恢复数据文件

(3.1)使用list failure查看失败操作

RMAN> list failure;

List of Database Failures
========================= Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
8 HIGH OPEN 16-MAY-18 One or more non-system datafiles need media recovery
42 HIGH OPEN 13-DEC-17 One or more non-system datafiles are missing

(3.2)使用RMAN建议来恢复丢失的文件

RMAN> advise failure
2> ; List of Database Failures
========================= Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
8 HIGH OPEN 16-MAY-18 One or more non-system datafiles need media recovery
42 HIGH OPEN 13-DEC-17 One or more non-system datafiles are missing analyzing automatic repair options; this may take some time
using channel ORA_DISK_1
analyzing automatic repair options complete Mandatory Manual Actions
========================
no manual actions available Optional Manual Actions
=======================
1. If you restored the wrong version of data file /u01/app/oracle/oradata/orcl/tbs04.dbf, then replace it with the correct one
2. If file /u01/app/oracle/oradata/orcl/tbs04.dbf was unintentionally renamed or moved, restore it Automated Repair Options
========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 13; Recover datafile 13
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1931299378.hm

最后一行给出了恢复的脚本,查看脚本

[oracle@redhat6 ~]$ more /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1931299378.hm
# restore and recover datafile
sql 'alter database datafile 13 offline';
restore datafile 13;
recover datafile 13;
sql 'alter database datafile 13 online';
# recover datafile
sql 'alter database datafile 13 offline';
recover datafile 13;
sql 'alter database datafile 13 online';

根据脚本,执行修复和恢复

RMAN>  sql 'alter database datafile 13 offline';

sql statement: alter database datafile 13 offline

RMAN> restore datafile ;

Starting restore at 16-MAY-18
using channel ORA_DISK_1 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 00013 to /u01/app/oracle/oradata/orcl/tbs04.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/db_1/dbs/01t31soh_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/01t31soh_1_1 tag=TAG20180516T144121
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 16-MAY-18 RMAN> recover datafile ; Starting recover at 16-MAY-18
using channel ORA_DISK_1 starting media recovery
media recovery complete, elapsed time: 00:00:00 Finished recover at 16-MAY-18 RMAN> sql 'alter database datafile 13 online'; sql statement: alter database datafile 13 online

(4)重启数据库,确认无异常

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started. Total System Global Area 730714112 bytes
Fixed Size 2216944 bytes
Variable Size 314575888 bytes
Database Buffers 411041792 bytes
Redo Buffers 2879488 bytes
Database mounted.
Database opened.

完结。

使用RMAN对数据文件进行恢复的更多相关文章

  1. RMAN数据库恢复 之归档模式有(无)备份-丢失数据文件的恢复

    1.归档模式有备份,丢失数据文件的恢复归档模式有备份,不管丢失什么数据文件,直接在RMAN下RESTOER--->RECOVER--->OPEN即可. RMAN> STARUP MO ...

  2. [20171225]没有备份数据文件的恢复.txt

    [20171225]没有备份数据文件的恢复.txt --//别人问的问题,增加了数据文件没有备份,如何恢复,实际上很简单,因为当前控制文件有记录建立时间只要从建立数据文件开始的--//归档日志都存在恢 ...

  3. RMAN数据库恢复之丢失数据文件的恢复

    删除某一数据文件:SQL> HOST del D:\app\Administrator\oradata\orcl\USERS01.dbf 启动数据库,提示丢失数据文件4,此时数据库处理MOUNT ...

  4. oracle11g 数据文件误删恢复(无备份)

    OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ...

  5. RMAN - "丢失控制文件的恢复"

    OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ...

  6. 记数据库数据文件损坏恢复ORA-00376+ORA-01110

    现象:业务平台无法登陆,日志报错为ORACLE的错误. 查看oracle日志的报错, ORA-00376: file 5 cannot be read at this time ORA-01110: ...

  7. 误删除innodb ibdata数据文件-之恢复

    今天在群里看到有人说不熟悉innodb把ibdata(数据文件)和ib_logfile(事务日志)文件误删除了.不知道怎么解决.当时我也不知道怎么办.后来查阅相关资料.终找到解决方法.其实恢复也挺简单 ...

  8. Rman将数据文件恢复到不同的路径

    RMAN> startup nomount connected to target database (not started)Oracle instance started Total Sys ...

  9. oracle 备份恢复篇(四)---rman 单个数据文件

    一,环境背景

随机推荐

  1. android aidl通信 RemoteCallbackList客户端注册回调

    RemoteCallbackList 声明 public class RemoteCallbackList<E extends IInterface> 情况 在AIDL中客户端向服务端注册 ...

  2. (0!=0)==true? 记一个匪夷所思的问题

    最近换了份工作,公司的开发框架是基于SSH自己搭建的.这个问题是我在解决一个需求的时候遇到的,其实解决这个疑惑的过程也就是读框架源码的过程,特此记录一下. 问题:ba.getState()!=CbBa ...

  3. Oracle中scott用户下基本表练习SQL语句

    --选择部门中30的雇员SELECT * from emp where DEPTNO=30;--列出所有办事员的姓名.部门.编号--采用内连接方式,也就是等值链接,也是最常用的链接SELECT ena ...

  4. Linux进程优先级和nice值

    在学习了linux的完全公平调度算法(CFS)后,记录下学习轨迹 这篇文章主要讲述,完全公平调度算法的工作方式,和一些调度知识 我们可以通过ps -l看到当前正在运行的进程的详细信息其中 F:表示进程 ...

  5. Git和GitHub在线学习资源整理(转)

    原文地址:http://blog.csdn.net/duqi_2009/article/details/12646711 电子书 GotGitHub Git Workflow 文章 GitHub Fu ...

  6. Please, configure Web Facet first!idea报这错的解决办法!!

    Please, configure Web Facet first!idea报这错的解决办法!! 今天在idea导入用eclipse的项目,然后运行项目的时候报这个错, 看下图 网上找了好多都没解决, ...

  7. 使用cookie实现只出现一次的广告代码效果

    我们上网经常会遇到第一次需要登录而之后不用再登录的网站的情况,其实是运用了Cookie 存储 web 页面的用户信息,Cookie 以名/值对形式存储,当浏览器从服务器上请求 web 页面时, 属于该 ...

  8. C++基础--malloc和new的区别

    (1)malloc在C和C++中都可以使用,用来申请一段内存:申请的内存一定要用free释放,然后把指针置为null: new只能在C++中使用,用于动态内存分配:new的对象要delete掉: (2 ...

  9. ASP.NET MVC 音乐商店 - 6. 使用 DataAnnotations 进行模型验证

    在前面的创建专辑与编辑专辑的表单中存在一个问题:我们没有进行任何验证.字段的内容可以不输入,或者在价格的字段中输入一些字符,在执行程序的时候,这些错误会导致数据库保存过程中出现错误,我们将会看到来自数 ...

  10. (转)防止ViewPager中的Fragment被销毁的方法

    在使用ViewPager与Fragment的时候,ViewPager会自动缓存1页内的数据,如下图: 当我们当前处在页面2的时候,页面1和页面3的View实际上已经创建好了,所以在我们拖动的时候是可以 ...