RMAN备份与恢复之数据文件
备份数据文件,模拟磁盘损坏时,还原恢复数据文件.
首先,查询数据文件序号,备份数据文件,可根据数据文件序号指定备份的数据文件.
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备份与恢复之数据文件的更多相关文章
- oracle直通车6关于rman备份恢复数据文件,以及创建分区表的实验
1.创建一张表,在表上创建一个索引,分别查询表,索引各自分配了多少个extents,多少个数据块以及总共占用空间的大小(bytes). 答:创建一张表t,为字段object_id创建索引t_objec ...
- RMAN备份与恢复之参数文件与控制文件
0 说明 本例是基于备份数据库全库的基础上,还原参数据文件(spfile),控制文件. 1 准备 [oracle@TEST144239 /]$ sqlplus /nolog SQL Produ ...
- MongoDB 数据文件备份与恢复
备份与恢复数据对于管理任何数据存储系统来说都是非常重要的. 1.冷备份与恢复——创建数据文件的副本(前提是要停止MongoDB服务器),也就是直接copy MongoDB将所有数据都存储在数据目录下, ...
- Oracle 11g Rac 用rman实现把本地数据文件迁移到ASM共享存储中
在Oracle Rac环境中,数据文件都是要存放在ASM共享存储上的,这样两个节点才能同时访问.而当你在某一节点下把数据文件创建在本地磁盘的时候,那么在另一节点上要访问该数据文件的时候就会报错,因为找 ...
- Oracle【IT实验室】数据库备份与恢复之四:RMAN(备份与恢复管理器)
RMAN是ORACLE提供的一个备份与恢复的工具,可以用来备份和还原数据库文件. 归档日志和控制文件.它也可以用来执行完全或不完全的数据库恢复. RMAN可以由命令行接口或者 OEM的 Backup ...
- RMAN备份与恢复之概念二
1 RMAN备份恢复 1.1 基础理论 恢复可以分为完全恢复和不完全恢复 完全数据库恢复是恢复到故障发生前的状态,所有已经提交的操作都进行恢复,确保数据库不丢失任何数据,完全恢复只用于归档模 ...
- 将数据文件从普通文件系统移动到ASM
场景一:数据库可以关闭1.关闭并mount数据库 $ sqlplus '/as sysdba' SQL> shutdown immediate SQL> startup mount; 2. ...
- 将数据文件从asm移到普通文件系统
数据库可以关闭的场景: 1.关闭并重新mount数据库 $ sqlplus '/as sysdba' SQL> shutdown immediate; SQL> startup mount ...
- RMAN备份与恢复之表空间
通过以下事例来说明表空间的恢复,删除表空间内的数据文件,删除后在针对位于该表空间的表进行插入记录以及实施检查点进程 SQL> select a.tablespace_name from dba_ ...
随机推荐
- cmd命令进行RSA 密钥加密操作
--参考 http://msdn.microsoft.com/zh-cn/library/2w117ede http://msdn.microsoft.com/zh-cn/library/yxw286 ...
- WebBrowser使用详解
编号:1007时间:2016年4月29日14:53:45功能:WebBrowser使用详解URl:http://blog.sina.com.cn/s/blog_3d7bed6501000c8n.htm ...
- JS操作DOM常用API总结
<JS高程>中的DOM部分写的有些繁琐,还没勇气整理,直到看到了这篇博文 Javascript操作DOM常用API总结,顿时有了一种居高临下,一览全局的感觉.不过有时间还是得自己把书里面的 ...
- 一步一步理解GB、GBDT、xgboost
GBDT和xgboost在竞赛和工业界使用都非常频繁,能有效的应用到分类.回归.排序问题,虽然使用起来不难,但是要能完整的理解还是有一点麻烦的.本文尝试一步一步梳理GB.GBDT.xgboost,它们 ...
- 获得项目的绝对地址 getRequestURI,getRequestURL的区别
java获得tomcat项目的绝对地址 String basePath = request.getScheme()+"://"+request.getServerName()+&q ...
- UVa 11988 破损的键盘(链表)
原题链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- MySQL复制的基本概念和实现
MySQL的复制的概念是完成水平扩展的架构 MySQL性能方面的扩展方式有scale on(向上扩展,垂直扩展) scale out(向外扩展,水平扩 ...
- Codeforces Round #120 (Div. 2)
A. Vasya and the Bus 根据\(n,m\)是否为0分类讨论下. B. Surrounded 判断两圆是否有交点,否则构造的圆与两圆相切. C. STL 看代码比较清楚. void t ...
- spark优化之优化数据结构
概序: 要减少内存的消耗,除了使用高效的序列化类库以外,还有一个很重要的事情,就是优化数据结构.从而避免Java语法特性中所导致的额外内存的开销,比如基于指针的Java数据结构,以及包装类型. 有一个 ...
- VGG-19 和 VGG-16 的 prototxt文件
VGG-19 和 VGG-16 的 prototxt文件 VGG-19 和 VGG-16 的 prototxt文件 VGG-16:prototxt 地址:https://gist.github.co ...