环境介绍:
ORACLE10.2.0.164BIT
REDHAT 5.4
通过RMAN来自动备份出冗余备份
[@more@]通常通过RMAN备份一份就足够了,备份完成后如果想要多于的冗余的话通常是将备份数据COPY到其他的地方存放,这样就增加了多于的维护成本以及加大了出错的几率,也可能会出现在通过COPY或者FTP传输的时候造成数据的丢失,导致备份的冗余不可用。
通过RMAN可以很容易的备份出冗余数据:
RMAN> run {
2> set backup copies 2;
3> allocate channel ch1 type disk format '/u01/h01','/u02/h02';
4> backup tablespace test_tran;
5> release channel ch1;
6> }
executing command: SET BACKUP COPIES
released channel: ORA_DISK_1
allocated channel: ch1
channel ch1: sid=141 devtype=DISK
Starting backup at 18-DEC-10
channel ch1: starting full datafile backupset
channel ch1: specifying datafile(s) in backupset
input datafile fno=00006 name=/u01/oradata/qqdb/test_tran01.dbf
channel ch1: starting piece 1 at 18-DEC-10
channel ch1: finished piece 1 at 18-DEC-10 with 2 copies and tag TAG20101218T001715
piece handle=/u01/h01 comment=NONE
piece handle=/u02/h02 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:01
Finished backup at 18-DEC-10
released channel: ch1
RMAN> list backup;
BS Key Type LV Size
------- ---- -- ----------
22 Full 152.00K
List of Datafiles in backup set 22
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
6 Full 11338164218367 18-DEC-10 /u01/oradata/qqdb/test_tran01.dbf
Backup Set Copy #1 of backup set 22
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:01 18-DEC-10 NO TAG20101218T001715
List of Backup Pieces for backup set 22 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
22 1 AVAILABLE /u01/h01
Backup Set Copy #2 of backup set 22
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:01 18-DEC-10 NO TAG20101218T001715
List of Backup Pieces for backup set 22 Copy #2
BP Key Pc# Status Piece Name
------- --- ----------- ----------
23 1 AVAILABLE /u02/h02
RMAN> startup mount force;
Oracle instance started
database mounted
Total System Global Area 243269632 bytes
Fixed Size 2019896 bytes
Variable Size 109055432 bytes
Database Buffers 130023424 bytes
Redo Buffers 2170880 bytes
RMAN> restore tablespace test_tran from tag 'TAG20101218T001715';
Starting restore at 18-DEC-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00006 to /u01/oradata/qqdb/test_tran01.dbf
channel ORA_DISK_1: reading from backup piece /u01/h01
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/h01 tag=TAG20101218T001715channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 18-DEC-10
RMAN> recover tablespace test_tran;
Starting recover at 18-DEC-10
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 18-DEC-10
--------------------------------------------------------
[oracle@qqdb u02]$ ll /u02/h*-rw-r----- 1 oracle dba 163840 Dec 18 00:17 /u02/h02
[oracle@qqdb u02]$ ll /u01/h*-rw-r----- 1 oracle dba 163840 Dec 18 00:17 /u01/h01
[oracle@qqdb u02]$
[oracle@qqdb u01]$ mv h01 h11
[oracle@qqdb u01]$ ll h*-rw-r----- 1 oracle dba 163840 Dec 18 00:17 h11
----------------------------------------------------------
RMAN> restore tablespace test_tran from tag 'TAG20101218T001715';
Starting restore at 18-DEC-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00006 to /u01/oradata/qqdb/test_tran01.dbf
channel ORA_DISK_1: reading from backup piece /u01/h01channel ORA_DISK_1: restored backup piece 1
failover to piece handle=/u02/h02 tag=TAG20101218T001715channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 18-DEC-10
RMAN> recover tablespace test_tran;
Starting recover at 18-DEC-10
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-DEC-10
可以看到当备份片CH01丢掉后,RMAN在恢复过程中就自动切换到其他的备份片段进行数据的恢复,其中不用其他人的干预。
----------------------------------------------------------
[oracle@qqdb u01]$ cd /u02/
[oracle@qqdb u02]$ mv h02 h12
[oracle@qqdb u02]$ ll /u01/h*-rw-r----- 1 oracle dba 163840 Dec 18 00:17 /u01/h11
[oracle@qqdb u02]$ ll /u02/h*-rw-r----- 1 oracle dba 163840 Dec 18 00:17 /u02/h12
----------------------------------------------------------------
RMAN> restore tablespace test_tran from tag 'TAG20101218T001715';
Starting restore at 18-DEC-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00006 to /u01/oradata/qqdb/test_tran01.dbf
channel ORA_DISK_1: reading from backup piece /u01/h01
ORA-19870: error reading backup piece /u02/h02
ORA-19505: failed to identify file "/u02/h02"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
failover to previous backup
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/18/2010 00:33:01
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 6 found to restore
RMAN>
可以发现当两个都丢掉的话就不能进行恢复操作。
RMAN> crosscheck backup;
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/h01 recid=22 stamp=738029835
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u02/h02 recid=23 stamp=738029835
-----------------------------------------------------------
[oracle@qqdb u02]$ mv h12 h02
[oracle@qqdb u02]$ ll /u02/h*-rw-r----- 1 oracle dba 163840 Dec 18 00:17 /u02/h02
[oracle@qqdb u02]$
----------------------------------------------------------------
RMAN> crosscheck backup;
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/h01 recid=22 stamp=738029835
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u02/h02 recid=23 stamp=738029835
------------------------------------------------------------------
[oracle@qqdb u02]$ mv /u01/h11 /u01/h01
[oracle@qqdb u02]$ ll /u01/h*-rw-r----- 1 oracle dba 163840 Dec 18 00:17 /u01/h01
-------------------------------------------------------------------
RMAN> crosscheck backup;
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/h01 recid=22 stamp=738029835
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u02/h02 recid=23 stamp=738029835
RMAN> delete backupset of tablespace test_tran tag 'TAG20101218T001715';
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
22 22 1 1 AVAILABLE DISK /u01/h01
23 22 1 2 AVAILABLE DISK /u02/h02
Do you really want to delete the above objects (enter YES or NO)? y
deleted backup piece
backup piece handle=/u01/h01 recid=22 stamp=738029835
deleted backup piece
backup piece handle=/u02/h02 recid=23 stamp=738029835
Deleted 2 objects
RMAN> sql 'alter database open';
sql statement: alter database open
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10130206/viewspace-1043238/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10130206/viewspace-1043238/