备份数据文件,模拟磁盘损坏时,还原恢复数据文件.

 首先,查询数据文件序号,备份数据文件,可根据数据文件序号指定备份的数据文件.

SQL> set linesize 1000
SQL> select file_name,file_id from dba_data_files; FILE_NAME FILE_ID
------------------------------------------------------------------------------------------
/data2/orcl/users01.dbf 4
/data2/orcl/undotbs01.dbf 3
/data2/orcl/sysaux01.dbf 2
/data2/orcl/system01.dbf 1

1.1查询数据文件序号

  备份数据文件,可单个数据文件备份,即镜像备份,如backup as copy datafile 1 ;也可以将多个数据文件作为备份集进行备份: datafile 1,2,3,4

[oracle@TEST144239 ~]$ rman target sys/Sina.2015

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Oct 14 11:52:47 2015

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

connected to target database: ORCL (DBID=1420421951)

RMAN>  backup as copy datafile 1
2> format '/data2/backup/df1_%d_%U'; Starting backup at 14-OCT-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=15 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=76 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=133 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/data2/orcl/system01.dbf
output file name=/data2/backup/df1_ORCL_data_D-ORCL_I-1420421951_TS-SYSTEM_FNO-1_1vqjmdom tag=TAG20151014T115254 RECID=6 STAMP=893073252
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:26
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_893073260_c1vnhhjp_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 14-OCT-15 RMAN> list copy ;
specification does not match any control file copy in the repository
List of Datafile Copies
======================= Key File S Completion Time Ckp SCN Ckp Time
------- ---- - --------------- ---------- ---------------
6 1 A 14-OCT-15 1690358 14-OCT-15
Name: /data2/backup/df1_ORCL_data_D-ORCL_I-1420421951_TS-SYSTEM_FNO-1_1vqjmdom
Tag: TAG20151014T115254 RMAN> backup datafile 1,2,3,4 format '/data2/backup/df_%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=00001 name=/data2/orcl/system01.dbf
input datafile file number=00003 name=/data2/orcl/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 14-OCT-15
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=/data2/orcl/sysaux01.dbf
input datafile file number=00004 name=/data2/orcl/users01.dbf
channel ORA_DISK_2: starting piece 1 at 14-OCT-15
channel ORA_DISK_2: finished piece 1 at 14-OCT-15
piece handle=/data2/backup/df_ORCL_20151014_22qjme43_1_1 tag=TAG20151014T115858 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:01:35
channel ORA_DISK_1: finished piece 1 at 14-OCT-15
piece handle=/data2/backup/df_ORCL_20151014_21qjme43_1_1 tag=TAG20151014T115858 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55
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_893073655_c1vnvsmo_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 14-OCT-15

1.2备份数据文件

1. 删除数据文件
[root@TEST144239 backup]# su - oracle
[oracle@TEST144239 ~]$ sqlplus "/ as sysdba" SQL*Plus: Release 11.2.0.3.0 Production on Wed Oct 14 14:48:09 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> ! rm /data2/orcl/users01.dbf 2.查看下是否删除:
[oracle@TEST144239 orcl]$ ll
总用量 1712960
-rw-r----- 1 oracle oinstall 9846784 10月 14 14:50 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 04:00 redo01.log
-rw-r----- 1 oracle oinstall 52429312 10月 14 11:37 redo02.log
-rw-r----- 1 oracle oinstall 52429312 10月 14 14:50 redo03.log
-rw-r----- 1 oracle oinstall 723525632 10月 14 14:50 sysaux01.dbf
-rw-r----- 1 oracle oinstall 754982912 10月 14 14:49 system01.dbf
-rw-r----- 1 oracle oinstall 30416896 10月 14 14:28 temp01.dbf
-rw-r----- 1 oracle oinstall 94380032 10月 14 14:50 undotbs01.dbf

2.1试验(删除数据文件)

SQL> startup mount 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
Database mounted. [oracle@TEST144239 orcl]$ rman
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Oct 14 15:51:41 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target sys/Sina.2015@study
connected to target database: ORCL (DBID=1420421951, not open) RMAN> run{
2> set newname for datafile 4 to '/data2/orcl/user01.dbf';
3> restore database;
4> switch datafile all;
5> recover database;
6> alter database open;} executing command: SET NEWNAME Starting restore at 14-OCT-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=192 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=6 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=67 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 00002 to /data2/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /data2/orcl/user01.dbf
channel ORA_DISK_1: reading from backup piece /data2/backup/df_ORCL_20151014_22qjme43_1_1
channel ORA_DISK_2: starting datafile backup set restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
channel ORA_DISK_2: restoring datafile 00001 to /data2/orcl/system01.dbf
channel ORA_DISK_2: restoring datafile 00003 to /data2/orcl/undotbs01.dbf
channel ORA_DISK_2: reading from backup piece /data2/backup/df_ORCL_20151014_21qjme43_1_1
channel ORA_DISK_1: piece handle=/data2/backup/df_ORCL_20151014_22qjme43_1_1 tag=TAG20151014T115858
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:02
channel ORA_DISK_2: piece handle=/data2/backup/df_ORCL_20151014_21qjme43_1_1 tag=TAG20151014T115858
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 00:01:12
Finished restore at 14-OCT-15 datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=893088213 file name=/data2/orcl/user01.dbf Starting recover at 14-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3 starting media recovery
media recovery complete, elapsed time: 00:00:16 Finished recover at 14-OCT-15 database opened SQL> select file#,name,status from v$datafile where file#=4; FILE# NAME STATUS
4 /data2/orcl/user01.dbf ONLINE SQL> select * from scott.dept; DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

2.2恢复数据文件

RMAN备份与恢复之数据文件的更多相关文章

  1. oracle直通车6关于rman备份恢复数据文件,以及创建分区表的实验

    1.创建一张表,在表上创建一个索引,分别查询表,索引各自分配了多少个extents,多少个数据块以及总共占用空间的大小(bytes). 答:创建一张表t,为字段object_id创建索引t_objec ...

  2. RMAN备份与恢复之参数文件与控制文件

    0   说明 本例是基于备份数据库全库的基础上,还原参数据文件(spfile),控制文件. 1   准备 [oracle@TEST144239 /]$ sqlplus /nolog SQL Produ ...

  3. MongoDB 数据文件备份与恢复

    备份与恢复数据对于管理任何数据存储系统来说都是非常重要的. 1.冷备份与恢复——创建数据文件的副本(前提是要停止MongoDB服务器),也就是直接copy MongoDB将所有数据都存储在数据目录下, ...

  4. Oracle 11g Rac 用rman实现把本地数据文件迁移到ASM共享存储中

    在Oracle Rac环境中,数据文件都是要存放在ASM共享存储上的,这样两个节点才能同时访问.而当你在某一节点下把数据文件创建在本地磁盘的时候,那么在另一节点上要访问该数据文件的时候就会报错,因为找 ...

  5. Oracle【IT实验室】数据库备份与恢复之四:RMAN(备份与恢复管理器)

    RMAN是ORACLE提供的一个备份与恢复的工具,可以用来备份和还原数据库文件. 归档日志和控制文件.它也可以用来执行完全或不完全的数据库恢复. RMAN可以由命令行接口或者 OEM的 Backup ...

  6. RMAN备份与恢复之概念二

      1   RMAN备份恢复 1.1  基础理论 恢复可以分为完全恢复和不完全恢复 完全数据库恢复是恢复到故障发生前的状态,所有已经提交的操作都进行恢复,确保数据库不丢失任何数据,完全恢复只用于归档模 ...

  7. 将数据文件从普通文件系统移动到ASM

    场景一:数据库可以关闭1.关闭并mount数据库 $ sqlplus '/as sysdba' SQL> shutdown immediate SQL> startup mount; 2. ...

  8. 将数据文件从asm移到普通文件系统

    数据库可以关闭的场景: 1.关闭并重新mount数据库 $ sqlplus '/as sysdba' SQL> shutdown immediate; SQL> startup mount ...

  9. RMAN备份与恢复之表空间

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

随机推荐

  1. array_walk() 函数

    array_walk() 函数对数组中的每个元素应用回调函数.如果成功则返回 TRUE,否则返回 FALSE. 典型情况下 function 接受两个参数.array 参数的值作为第一个,键名作为第二 ...

  2. DATEADD(Day, DATEDIFF(Day,0,ShippingTime), 0)

    select DATEADD(Day, DATEDIFF(Day,0,GETDATE()), 0),DATEDIFF(Day,0,GETDATE()),GETDATE() 结果: (无列名) (无列名 ...

  3. 发布b3log-solo后,访问http://localhost:8080/b3log-solo/提示错误为staticServePath Error。

    发布b3log-solo后,访问http://localhost:8080/b3log-solo/提示错误为staticServePath Error. latke.props内容为: serverS ...

  4. 装载: Matlab 提取矩阵 某一行 或者 某一列 的方法

    比如,从一个6*6矩阵中,提取它的第一行元素,形成一个6维行向量. A(i,:)行  A(:,i)列 方法: A(i,:) 提取矩阵A的第 i行 A(:,i) 提取矩阵A的第 i列   给你个例子: ...

  5. poj3249 Test for Job ——拓扑+DP

    link:http://poj.org/problem?id=3249 在拓扑排序的过程中进行状态转移,dp[i]表示从起点到 i 这个点所得到的的最大值.比如从u点到v点,dp[v]=max(dp[ ...

  6. 网站不能访问(httperrLog【Timer_MinBytesPerSecond】【Timer_ConnectionIdle】)(转载)

    在\LogFiles\HTTPERR的日志(C:\Windows\System32\LogFiles\HTTPERR)中发现了大量Timer_MinBytesPerSecond,Timer_Conne ...

  7. C函数及指针学习1

    1 大段程序注释的方法 #if 0#endif 2三字母词 以两个问号 开始的都要注意 3 字面值(常量) 在整型号字面值后加 字符L (long),U(unsigned)说明字符常量 为长整型 或( ...

  8. Cent OS 6.5安装 php memcached扩展

    首先查看memcache的依赖库是否有安装,如果对这个有疑问可以参考php手册的memcache的安装需求说明 命令如下: 查询: rpm -qa | grep libevent 安装:yum -y ...

  9. 【POJ3904】【P1202】水晶密码

    说是莫比乌斯反演,其实只是玩儿玩儿内个miu函数而已…… 原题: wty  打算攻击 applepi  的用来存放机密数据的水晶系统. applepi 早有察觉,于是布置了一个密码系统来防备 wty ...

  10. 黑马程序员——JAVA基础之构造函数,构造代码块

    ------- android培训.java培训.期待与您交流! ---------- 构造函数特点: 1.  函数名与类名相同 2.  不用定义返回值类型 3.  不可以写return语句 构造函数 ...