使用RMAN备份数据文件

1、查看数据文件信息

  • 通过report schema方式查看
RMAN> report schema;

Report of database schema for database with db_unique_name POLI

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    690      SYSTEM               ***     /u01/oradata/poli/system01.dbf
2    540      SYSAUX               ***     /u01/oradata/poli/sysaux01.dbf
3    85       UNDOTBS1             ***     /u01/oradata/poli/undotbs01.dbf
4    35       USERS                ***     /u01/oradata/poli/users01.dbf
5    100      EXAMPLE              ***     /u01/oradata/poli/example01.dbf
6    200      EXPIMP               ***     /u01/oradata/expimp01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    29       TEMP                 32767       /u01/oradata/poli/temp01.dbf
  • 通过v$datafile查看
[oracle@DG1 arcerzhang]$ sqlplus sys/oracle as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Mar 23 16:34:16 2013

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> desc v$datafile;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 FILE#                                              NUMBER
 CREATION_CHANGE#                                   NUMBER
 CREATION_TIME                                      DATE
 TS#                                                NUMBER
 RFILE#                                             NUMBER
 STATUS                                             VARCHAR2(7)
 ENABLED                                            VARCHAR2(10)
 CHECKPOINT_CHANGE#                                 NUMBER
 CHECKPOINT_TIME                                    DATE
 UNRECOVERABLE_CHANGE#                              NUMBER
 UNRECOVERABLE_TIME                                 DATE
 LAST_CHANGE#                                       NUMBER
 LAST_TIME                                          DATE
 OFFLINE_CHANGE#                                    NUMBER
 ONLINE_CHANGE#                                     NUMBER
 ONLINE_TIME                                        DATE
 BYTES                                              NUMBER
 BLOCKS                                             NUMBER
 CREATE_BYTES                                       NUMBER
 BLOCK_SIZE                                         NUMBER
 NAME                                               VARCHAR2(513)
 PLUGGED_IN                                         NUMBER
 BLOCK1_OFFSET                                      NUMBER
 AUX_NAME                                           VARCHAR2(513)
 FIRST_NONLOGGED_SCN                                NUMBER
 FIRST_NONLOGGED_TIME                               DATE
 FOREIGN_DBID                                       NUMBER
 FOREIGN_CREATION_CHANGE#                           NUMBER
 FOREIGN_CREATION_TIME                              DATE
 PLUGGED_READONLY                                   VARCHAR2(3)
 PLUGIN_CHANGE#                                     NUMBER
 PLUGIN_RESETLOGS_CHANGE#                           NUMBER
 PLUGIN_RESETLOGS_TIME                              DATE
SQL> col name format a60
SQL> select file#,name from v$datafile;

     FILE# NAME
---------- ------------------------------------------------------------
         1 /u01/oradata/poli/system01.dbf
         2 /u01/oradata/poli/sysaux01.dbf
         3 /u01/oradata/poli/undotbs01.dbf
         4 /u01/oradata/poli/users01.dbf
         5 /u01/oradata/poli/example01.dbf
         6 /u01/oradata/expimp01.dbf

6 rows selected.

 2、将FILE#为4的datafile进行备份

RMAN> backup datafile 4 format '/u01/arcerzhang/poli_4_datafile_%U';

Starting backup at 23-MAR-13
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=00004 name=/u01/oradata/poli/users01.dbf
channel ORA_DISK_1: starting piece 1 at 23-MAR-13
channel ORA_DISK_1: finished piece 1 at 23-MAR-13
piece handle=/u01/arcerzhang/poli_4_datafile_0bo58pim_1_1 tag=TAG20130323T163950 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 23-MAR-13

Starting Control File Autobackup at 23-MAR-13
piece handle=/u01/flash_recovery_area/POLI/autobackup/2013_03_23/o1_mf_n_810837593_8nttlswh_.bkp comment=NONE
Finished Control File Autobackup at 23-MAR-13

 备注:

(1)、

backup datafile 4 format '/u01/arcerzhang/poli_4_datafile_%U' 这个命令,只能备份一个数据文件;我们也可以一次备份多个数据文件如下所写:

backup datafile 4,5 format '/u01/arcerzhang/poli_4_5_datafile_%U',如此可以同时备份4,5数据文件;

(2)、上述是按照file#进行备份的,也可以通过file_name进行备份操作

backup datafile '/u01/oradata/poli/users01.dbf'  format '/u01/arderzhang/poli_df_%U';

(3)、

Image copy不支持增量备份;
Image copy进行的备份,是一对一,一比一的备份;将来使用Image copy的备份文件,直接设置回复目录即可;
Image copy备份的文件,没有进行压缩;
Image copy不需要做restore,只需要做switch就可以;Backup set进行restore时,需要extract files from a backup set,因为一个backup set
是将多个文件捏在一起的。

Backup set支持增量备份
Backup set进行的备份文件,可以进行压缩;
Backup set可以写到磁盘或者磁带上,与之相反的Image copy只能写到磁盘上;
Datafile backup sets can be incremental or full(全备或增量备份);对于归档日志文件,就不能做增量备份,只能进行镜像拷贝。
Backup sets do not include never-used blocks.对于一个比较大的数据文件,当初分配空间的时候分配了100个G,在进行Backup set时,
只有20G的block在使用,其他80G尚未分配使用,此时Backup set只会备份20G已经使用的Block,其他未分配的Block不会被Backup,提高效率;

3、将某一个数据文件备份2份

(1)、创建两个目录

[oracle@DG1 arcerzhang]$ mkdir b1 b2
[oracle@DG1 arcerzhang]$ ll
total 16
drwxr-xr-x 2 oracle oinstall 4096 Mar 25 10:46 b1
drwxr-xr-x 2 oracle oinstall 4096 Mar 25 10:46 b2
-rw-r--r-- 1 oracle oinstall   65 Mar 21 23:55 exp.sql
-rw-r--r-- 1 oracle oinstall   73 Mar 19 16:45 rdemo.sh

(2)、执行备份 

注意:copies num中,num的数据最大值为4.通过show all命令,也可以设置最大备份数.(CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default)

RMAN> backup copies 2 datafile 5 format '/u01/arcerzhang/b1/d_%U','/u01/arcerzhang/b2/d_%U';

启动 backup25-3月 -13
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=11 设备类型=DISK
通道 ORA_DISK_1: 正在启动全部数据文件备份集
通道 ORA_DISK_1: 正在指定备份集内的数据文件
输入数据文件: 文件号=00005 名称=/u01/oradata/poli/example01.dbf
通道 ORA_DISK_1: 正在启动段 125-3月 -13
通道 ORA_DISK_1: 已完成段 125-3月 -13, 有 2 个副本和标记 TAG20130325T104849
段 handle=/u01/arcerzhang/b1/d_17o5ddoh_1_1 comment=NONE
段 handle=/u01/arcerzhang/b2/d_17o5ddoh_1_2 comment=NONE
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:46
完成 backup25-3月 -13

启动 Control File Autobackup 于 25-3月 -13
段 handle=/u01/flash_recovery_area/POLI/autobackup/2013_03_25/o1_mf_n_810989375_8nzgt1vc_.bkp comment=NONE
完成 Control File Autobackup 于 25-3月 -13

 

posted @ 2013-03-23 16:42  ArcerZhang  阅读(751)  评论(0编辑  收藏  举报