rman 对数据文件 的恢复测试(一)

2014-11-24 18:38:21 · 作者: · 浏览: 0

一下是关于rman 的备份,恢复的测试:


database 是mount 状态,其他用户连不了:
SQL> select status from v$instance;


STATUS
------------
MOUNTED


Warning: You are no longer connected to ORACLE.
SQL>


好,下面切换到sys 用户来test:


-----
先看一下参数:
RMAN> startup mount;


Oracle instance started
database mounted


Total System Global Area 335544320 bytes


Fixed Size 1219280 bytes
Variable Size 83887408 bytes
Database Buffers 247463936 bytes
Redo Buffers 2973696 bytes



对rman auobackup on 开启,和路径设置,实验:
[oracle@aoracle rman]$ ls -lrt
total 0
[oracle@aoracle rman]$ pwd
/u02/rman
[oracle@aoracle rman]$


RMAN> show all;


RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/rman/ctl_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/pp/oracle/product/10.2/db_1/dbs/snapcf_ezhou.f'; # default


好,下面进行实验:


对一个database 进行备份:


RMAN> backup database format '/u02/rman/ezhou_%U.bak';


Starting backup at 16-OCT-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=152 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u02/ezhou/system01.dbf
input datafile fno=00002 name=/u02/ezhou/undotbs01.dbf
input datafile fno=00003 name=/u02/ezhou/sysaux01.dbf
input datafile fno=00005 name=/u02/ezhou/example01.dbf
input datafile fno=00004 name=/u02/ezhou/users01.dbf
input datafile fno=00006 name=/u02/ezhou/example02.dbf
channel ORA_DISK_1: starting piece 1 at 16-OCT-11
channel ORA_DISK_1: finished piece 1 at 16-OCT-11
piece handle=/u02/rman/ezhou_09mp76h8_1_1.bak tag=TAG20111016T021256 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:20
Finished backup at 16-OCT-11


Starting Control File and SPFILE Autobackup at 16-OCT-11
piece handle=/u02/rman/ctl_c-4046377924-20111016-00 comment=NONE
Finished Control File and SPFILE Autobackup at 16-OCT-11


仔细研究一下log:
看到是一个channel,生成的文件放在:
/u02/rman/ezhou_09mp76h8_1_1.bak
/u02/rman/ctl_c-4046377924-20111016-00


上面一个是database ,下面一个是control file 和spfile ,这个是自动备份的。
因为上面的control file autobackup 是on.


好,看一下生成的文件:
[oracle@aoracle rman]$ ls -lrt
total 898088
-rw-r----- 1 oracle oinstall 911589376 Oct 16 02:15 ezhou_09mp76h8_1_1.bak
-rw-r----- 1 oracle oinstall 7143424 Oct 16 02:15 ctl_c-4046377924-20111016-00


下面对数据文件进行恢复:
先看一下数据文件放的位置:


RMAN> report schema;


Report of database schema


List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 480 SYSTEM *** /u02/ezhou/system01.dbf
2 285 UNDOTBS1 *** /u02/ezhou/undotbs01.dbf
3 250 SYSAUX ***