议rman的crosscheck和obsolete
生活随笔
收集整理的這篇文章主要介紹了
议rman的crosscheck和obsolete
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
今天有朋友對于crosscheck和obsolete理解的不太清楚,網上查找了一些資料,也發現很多錯誤,其中典型的理解就是:crosscheck 可以檢測/刪除違背(obsolete)備份策略的備份集
--登錄rman
[oracle@node1 ~]$ $ORACLE_HOME/bin/rman target /
?
Recovery Manager: Release 10.2.0.5.0 - Production on Tue Nov 8 13:39:17 2011
?
Copyright (c) 1982, 2007, Oracle. ?All rights reserved.
?
connected to target database: ECP (DBID=1669273445)
?
RMAN> show all;
?
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 2048 M;
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 '/opt/oracle/product/10.2.0/db_1/dbs/snapcf_ecp.f'; # default
--發現配置的策略是保留1份
?
--全庫備份
RMAN> list backup summary;
--當前數據庫無備份集備份
?
RMAN> backup database format '/opt/backup/ecp_full_%U';
?
Starting backup at 2011-11-08 13:22:06
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=536 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=534 devtype=DISK
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/opt/oracle/oradata/ecp/users01.dbf
input datafile fno=00003 name=/opt/oracle/oradata/ecp/sysaux01.dbf
input datafile fno=00008 name=/opt/oracle/oradata/ecp/TS_Public_1.003.dbf
input datafile fno=00009 name=/opt/oracle/oradata/ecp/TS_Index_Base.001.dbf
input datafile fno=00010 name=/opt/oracle/oradata/ecp/TS_Index_Base.002.dbf
input datafile fno=00011 name=/opt/oracle/oradata/ecp/TS_Index_Base.003.dbf
channel ORA_DISK_1: starting piece 1 at 2011-11-08 13:22:07
channel ORA_DISK_2: starting compressed full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
input datafile fno=00002 name=/opt/oracle/oradata/ecp/undotbs01.dbf
input datafile fno=00001 name=/opt/oracle/oradata/ecp/system01.dbf
input datafile fno=00012 name=/opt/oracle/oradata/ecp/OGG.001.dbf
input datafile fno=00005 name=/opt/oracle/oradata/ecp/example01.dbf
input datafile fno=00006 name=/opt/oracle/oradata/ecp/TS_Public_1.001.dbf
input datafile fno=00007 name=/opt/oracle/oradata/ecp/TS_Public_1.002.dbf
channel ORA_DISK_2: starting piece 1 at 2011-11-08 13:22:07
channel ORA_DISK_1: finished piece 1 at 2011-11-08 13:22:22
piece handle=/opt/backup/ecp_full_11mr52bv_1_1 tag=TAG20111108T132207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 2011-11-08 13:22:23
channel ORA_DISK_1: finished piece 1 at 2011-11-08 13:22:24
piece handle=/opt/backup/ecp_full_13mr52ce_1_1 tag=TAG20111108T132207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 2011-11-08 13:22:25
channel ORA_DISK_1: finished piece 1 at 2011-11-08 13:22:26
piece handle=/opt/backup/ecp_full_14mr52cg_1_1 tag=TAG20111108T132207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_2: finished piece 1 at 2011-11-08 13:22:41
piece handle=/opt/backup/ecp_full_12mr52bv_1_1 tag=TAG20111108T132207 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:34
Finished backup at 2011-11-08 13:22:41
?
--備份sysdata01.dbf文件
RMAN> backup datafile 1 format '/opt/backup/ecp_system_%U';
?
Starting backup at 2011-11-08 13:23:44
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/opt/oracle/oradata/ecp/system01.dbf
channel ORA_DISK_1: starting piece 1 at 2011-11-08 13:23:45
channel ORA_DISK_2: starting compressed full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_2: starting piece 1 at 2011-11-08 13:23:45
channel ORA_DISK_2: finished piece 1 at 2011-11-08 13:23:46
piece handle=/opt/backup/ecp_system_16mr52f1_1_1 tag=TAG20111108T132344 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_2: starting compressed full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_2: starting piece 1 at 2011-11-08 13:23:47
channel ORA_DISK_2: finished piece 1 at 2011-11-08 13:23:48
piece handle=/opt/backup/ecp_system_17mr52f2_1_1 tag=TAG20111108T132344 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: finished piece 1 at 2011-11-08 13:24:13
piece handle=/opt/backup/ecp_system_15mr52f1_1_1 tag=TAG20111108T132344 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:28
Finished backup at 2011-11-08 13:24:13
--注:所有備份system空間,都是會自動備份spfile和控制文件
?
RMAN> list backup summary;
?
List of Backups
===============
Key ? ? TY LV S Device Type Completion Time ? ? #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
28 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:19 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
29 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:23 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
30 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:25 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
31 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:35 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
32 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:23:45 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
33 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:23:47 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
34 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:24:03 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
--查看所有備份集情況
?
RMAN> crosscheck backup;
?
using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_11mr52bv_1_1 recid=28 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_13mr52ce_1_1 recid=29 stamp=766675343
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_14mr52cg_1_1 recid=30 stamp=766675345
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_12mr52bv_1_1 recid=31 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_16mr52f1_1_1 recid=32 stamp=766675425
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_17mr52f2_1_1 recid=33 stamp=766675427
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_15mr52f1_1_1 recid=34 stamp=766675425
--查看全部有效
?
RMAN> report obsolete;
?
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type ? ? ? ? ? ? ? ? Key ? ?Completion Time ? ?Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set ? ? ? ? ? 29 ? ? 2011-11-08 13:22:23
??Backup Piece ? ? ? 29 ? ? 2011-11-08 13:22:23 /opt/backup/ecp_full_13mr52ce_1_1
Backup Set ? ? ? ? ? 30 ? ? 2011-11-08 13:22:25
??Backup Piece ? ? ? 30 ? ? 2011-11-08 13:22:25 /opt/backup/ecp_full_14mr52cg_1_1
--因為system01.dbf備份了兩次,所以違背了備份策略
?
drwxr-xr-x ?2 root ? ?root ? ? ?4096 07-12 15:54 vmdir
[root@node1 opt]# cd /opt/backup/
[root@node1 backup]# ll
總計 265356
-rw-r----- 1 oracle oinstall ?47497216 11-08 13:22 ecp_full_11mr52bv_1_1
-rw-r----- 1 oracle oinstall 129433600 11-08 13:22 ecp_full_12mr52bv_1_1
-rw-r----- 1 oracle oinstall ? 1130496 11-08 13:22 ecp_full_13mr52ce_1_1
-rw-r----- 1 oracle oinstall ? ? 98304 11-08 13:22 ecp_full_14mr52cg_1_1
-rw-r----- 1 oracle oinstall ?92012544 11-08 13:24 ecp_system_15mr52f1_1_1
-rw-r----- 1 oracle oinstall ? 1130496 11-08 13:23 ecp_system_16mr52f1_1_1
-rw-r----- 1 oracle oinstall ? ? 98304 11-08 13:23 ecp_system_17mr52f2_1_1
[root@node1 backup]# mv ecp_system_15mr52f1_1_1 ecp_system_15mr52f1_1_1_bak
[root@node1 backup]# ll
總計 265356
-rw-r----- 1 oracle oinstall ?47497216 11-08 13:22 ecp_full_11mr52bv_1_1
-rw-r----- 1 oracle oinstall 129433600 11-08 13:22 ecp_full_12mr52bv_1_1
-rw-r----- 1 oracle oinstall ? 1130496 11-08 13:22 ecp_full_13mr52ce_1_1
-rw-r----- 1 oracle oinstall ? ? 98304 11-08 13:22 ecp_full_14mr52cg_1_1
-rw-r----- 1 oracle oinstall ?92012544 11-08 13:24 ecp_system_15mr52f1_1_1_bak
-rw-r----- 1 oracle oinstall ? 1130496 11-08 13:23 ecp_system_16mr52f1_1_1
-rw-r----- 1 oracle oinstall ? ? 98304 11-08 13:23 ecp_system_17mr52f2_1_1
--對備份集中的其中一個文件重命名
?
RMAN> crosscheck backup;
?
using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_11mr52bv_1_1 recid=28 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_13mr52ce_1_1 recid=29 stamp=766675343
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_14mr52cg_1_1 recid=30 stamp=766675345
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_12mr52bv_1_1 recid=31 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_16mr52f1_1_1 recid=32 stamp=766675425
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_17mr52f2_1_1 recid=33 stamp=766675427
Crosschecked 6 objects
?
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/backup/ecp_system_15mr52f1_1_1 recid=34 stamp=766675425
Crosschecked 1 objects
--發現一個無效的備份集
?
RMAN> list backup summary;
?
List of Backups
===============
Key ? ? TY LV S Device Type Completion Time ? ? #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
28 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:19 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
29 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:23 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
30 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:25 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
31 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:35 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
32 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:23:45 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
33 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:23:47 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
34 ? ? ?B ?F ?X DISK ? ? ? ?2011-11-08 13:24:03 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
--也標志為無效'X'
?
RMAN> report obsolete;
?
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type ? ? ? ? ? ? ? ? Key ? ?Completion Time ? ?Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set ? ? ? ? ? 29 ? ? 2011-11-08 13:22:23
??Backup Piece ? ? ? 29 ? ? 2011-11-08 13:22:23 /opt/backup/ecp_full_13mr52ce_1_1
Backup Set ? ? ? ? ? 30 ? ? 2011-11-08 13:22:25
??Backup Piece ? ? ? 30 ? ? 2011-11-08 13:22:25 /opt/backup/ecp_full_14mr52cg_1_1
--策略還是顯示這兩個備份集違背規則
?
RMAN> DELETE NOPROMPT OBSOLETE;
?
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
using channel ORA_DISK_2
Deleting the following obsolete backups and copies:
Type ? ? ? ? ? ? ? ? Key ? ?Completion Time ? ?Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set ? ? ? ? ? 29 ? ? 2011-11-08 13:22:23
??Backup Piece ? ? ? 29 ? ? 2011-11-08 13:22:23 /opt/backup/ecp_full_13mr52ce_1_1
Backup Set ? ? ? ? ? 30 ? ? 2011-11-08 13:22:25
??Backup Piece ? ? ? 30 ? ? 2011-11-08 13:22:25 /opt/backup/ecp_full_14mr52cg_1_1
deleted backup piece
backup piece handle=/opt/backup/ecp_full_13mr52ce_1_1 recid=29 stamp=766675343
deleted backup piece
backup piece handle=/opt/backup/ecp_full_14mr52cg_1_1 recid=30 stamp=766675345
Deleted 2 objects
?
RMAN> report obsolete;
?
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
no obsolete backups found
--刪除違法策略的備份集
?
RMAN> delete ?NOPROMPT ?expired backup;
?
using channel ORA_DISK_1
using channel ORA_DISK_2
?
List of Backup Pieces
BP Key ?BS Key ?Pc# Cp# Status ? ? ?Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
34 ? ? ?34 ? ? ?1 ? 1 ? EXPIRED ? ? DISK ? ? ? ?/opt/backup/ecp_system_15mr52f1_1_1
deleted backup piece
backup piece handle=/opt/backup/ecp_system_15mr52f1_1_1 recid=34 stamp=766675425
Deleted 1 EXPIRED objects
?
RMAN> crosscheck backup;
?
using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_11mr52bv_1_1 recid=28 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_12mr52bv_1_1 recid=31 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_16mr52f1_1_1 recid=32 stamp=766675425
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_17mr52f2_1_1 recid=33 stamp=766675427
Crosschecked 4 objects
--刪除無效的備份集
通過實驗說明:crosscheck只能夠檢測備份集是否有效(最常見的情況就是物理上是否還存在),并且可以用它來刪除失效(expired)的備份集,而不是用來刪除違背備份策略(obsolete)的備份集,如果要刪除違背備份策略(廢棄)的備份集,需要使用obsolete操作。出現這個問題的主要原因應該是expired和obsolete翻譯成中文的時候理解的出入導致。
--登錄rman
[oracle@node1 ~]$ $ORACLE_HOME/bin/rman target /
?
Recovery Manager: Release 10.2.0.5.0 - Production on Tue Nov 8 13:39:17 2011
?
Copyright (c) 1982, 2007, Oracle. ?All rights reserved.
?
connected to target database: ECP (DBID=1669273445)
?
RMAN> show all;
?
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 2048 M;
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 '/opt/oracle/product/10.2.0/db_1/dbs/snapcf_ecp.f'; # default
--發現配置的策略是保留1份
?
--全庫備份
RMAN> list backup summary;
--當前數據庫無備份集備份
?
RMAN> backup database format '/opt/backup/ecp_full_%U';
?
Starting backup at 2011-11-08 13:22:06
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=536 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=534 devtype=DISK
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/opt/oracle/oradata/ecp/users01.dbf
input datafile fno=00003 name=/opt/oracle/oradata/ecp/sysaux01.dbf
input datafile fno=00008 name=/opt/oracle/oradata/ecp/TS_Public_1.003.dbf
input datafile fno=00009 name=/opt/oracle/oradata/ecp/TS_Index_Base.001.dbf
input datafile fno=00010 name=/opt/oracle/oradata/ecp/TS_Index_Base.002.dbf
input datafile fno=00011 name=/opt/oracle/oradata/ecp/TS_Index_Base.003.dbf
channel ORA_DISK_1: starting piece 1 at 2011-11-08 13:22:07
channel ORA_DISK_2: starting compressed full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
input datafile fno=00002 name=/opt/oracle/oradata/ecp/undotbs01.dbf
input datafile fno=00001 name=/opt/oracle/oradata/ecp/system01.dbf
input datafile fno=00012 name=/opt/oracle/oradata/ecp/OGG.001.dbf
input datafile fno=00005 name=/opt/oracle/oradata/ecp/example01.dbf
input datafile fno=00006 name=/opt/oracle/oradata/ecp/TS_Public_1.001.dbf
input datafile fno=00007 name=/opt/oracle/oradata/ecp/TS_Public_1.002.dbf
channel ORA_DISK_2: starting piece 1 at 2011-11-08 13:22:07
channel ORA_DISK_1: finished piece 1 at 2011-11-08 13:22:22
piece handle=/opt/backup/ecp_full_11mr52bv_1_1 tag=TAG20111108T132207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 2011-11-08 13:22:23
channel ORA_DISK_1: finished piece 1 at 2011-11-08 13:22:24
piece handle=/opt/backup/ecp_full_13mr52ce_1_1 tag=TAG20111108T132207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 2011-11-08 13:22:25
channel ORA_DISK_1: finished piece 1 at 2011-11-08 13:22:26
piece handle=/opt/backup/ecp_full_14mr52cg_1_1 tag=TAG20111108T132207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_2: finished piece 1 at 2011-11-08 13:22:41
piece handle=/opt/backup/ecp_full_12mr52bv_1_1 tag=TAG20111108T132207 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:34
Finished backup at 2011-11-08 13:22:41
?
--備份sysdata01.dbf文件
RMAN> backup datafile 1 format '/opt/backup/ecp_system_%U';
?
Starting backup at 2011-11-08 13:23:44
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/opt/oracle/oradata/ecp/system01.dbf
channel ORA_DISK_1: starting piece 1 at 2011-11-08 13:23:45
channel ORA_DISK_2: starting compressed full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_2: starting piece 1 at 2011-11-08 13:23:45
channel ORA_DISK_2: finished piece 1 at 2011-11-08 13:23:46
piece handle=/opt/backup/ecp_system_16mr52f1_1_1 tag=TAG20111108T132344 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_2: starting compressed full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_2: starting piece 1 at 2011-11-08 13:23:47
channel ORA_DISK_2: finished piece 1 at 2011-11-08 13:23:48
piece handle=/opt/backup/ecp_system_17mr52f2_1_1 tag=TAG20111108T132344 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: finished piece 1 at 2011-11-08 13:24:13
piece handle=/opt/backup/ecp_system_15mr52f1_1_1 tag=TAG20111108T132344 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:28
Finished backup at 2011-11-08 13:24:13
--注:所有備份system空間,都是會自動備份spfile和控制文件
?
RMAN> list backup summary;
?
List of Backups
===============
Key ? ? TY LV S Device Type Completion Time ? ? #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
28 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:19 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
29 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:23 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
30 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:25 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
31 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:35 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
32 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:23:45 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
33 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:23:47 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
34 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:24:03 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
--查看所有備份集情況
?
RMAN> crosscheck backup;
?
using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_11mr52bv_1_1 recid=28 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_13mr52ce_1_1 recid=29 stamp=766675343
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_14mr52cg_1_1 recid=30 stamp=766675345
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_12mr52bv_1_1 recid=31 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_16mr52f1_1_1 recid=32 stamp=766675425
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_17mr52f2_1_1 recid=33 stamp=766675427
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_15mr52f1_1_1 recid=34 stamp=766675425
--查看全部有效
?
RMAN> report obsolete;
?
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type ? ? ? ? ? ? ? ? Key ? ?Completion Time ? ?Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set ? ? ? ? ? 29 ? ? 2011-11-08 13:22:23
??Backup Piece ? ? ? 29 ? ? 2011-11-08 13:22:23 /opt/backup/ecp_full_13mr52ce_1_1
Backup Set ? ? ? ? ? 30 ? ? 2011-11-08 13:22:25
??Backup Piece ? ? ? 30 ? ? 2011-11-08 13:22:25 /opt/backup/ecp_full_14mr52cg_1_1
--因為system01.dbf備份了兩次,所以違背了備份策略
?
drwxr-xr-x ?2 root ? ?root ? ? ?4096 07-12 15:54 vmdir
[root@node1 opt]# cd /opt/backup/
[root@node1 backup]# ll
總計 265356
-rw-r----- 1 oracle oinstall ?47497216 11-08 13:22 ecp_full_11mr52bv_1_1
-rw-r----- 1 oracle oinstall 129433600 11-08 13:22 ecp_full_12mr52bv_1_1
-rw-r----- 1 oracle oinstall ? 1130496 11-08 13:22 ecp_full_13mr52ce_1_1
-rw-r----- 1 oracle oinstall ? ? 98304 11-08 13:22 ecp_full_14mr52cg_1_1
-rw-r----- 1 oracle oinstall ?92012544 11-08 13:24 ecp_system_15mr52f1_1_1
-rw-r----- 1 oracle oinstall ? 1130496 11-08 13:23 ecp_system_16mr52f1_1_1
-rw-r----- 1 oracle oinstall ? ? 98304 11-08 13:23 ecp_system_17mr52f2_1_1
[root@node1 backup]# mv ecp_system_15mr52f1_1_1 ecp_system_15mr52f1_1_1_bak
[root@node1 backup]# ll
總計 265356
-rw-r----- 1 oracle oinstall ?47497216 11-08 13:22 ecp_full_11mr52bv_1_1
-rw-r----- 1 oracle oinstall 129433600 11-08 13:22 ecp_full_12mr52bv_1_1
-rw-r----- 1 oracle oinstall ? 1130496 11-08 13:22 ecp_full_13mr52ce_1_1
-rw-r----- 1 oracle oinstall ? ? 98304 11-08 13:22 ecp_full_14mr52cg_1_1
-rw-r----- 1 oracle oinstall ?92012544 11-08 13:24 ecp_system_15mr52f1_1_1_bak
-rw-r----- 1 oracle oinstall ? 1130496 11-08 13:23 ecp_system_16mr52f1_1_1
-rw-r----- 1 oracle oinstall ? ? 98304 11-08 13:23 ecp_system_17mr52f2_1_1
--對備份集中的其中一個文件重命名
?
RMAN> crosscheck backup;
?
using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_11mr52bv_1_1 recid=28 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_13mr52ce_1_1 recid=29 stamp=766675343
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_14mr52cg_1_1 recid=30 stamp=766675345
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_12mr52bv_1_1 recid=31 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_16mr52f1_1_1 recid=32 stamp=766675425
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_17mr52f2_1_1 recid=33 stamp=766675427
Crosschecked 6 objects
?
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/backup/ecp_system_15mr52f1_1_1 recid=34 stamp=766675425
Crosschecked 1 objects
--發現一個無效的備份集
?
RMAN> list backup summary;
?
List of Backups
===============
Key ? ? TY LV S Device Type Completion Time ? ? #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
28 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:19 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
29 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:23 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
30 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:25 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
31 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:22:35 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132207
32 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:23:45 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
33 ? ? ?B ?F ?A DISK ? ? ? ?2011-11-08 13:23:47 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
34 ? ? ?B ?F ?X DISK ? ? ? ?2011-11-08 13:24:03 1 ? ? ? 1 ? ? ? YES ? ? ? ?TAG20111108T132344
--也標志為無效'X'
?
RMAN> report obsolete;
?
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type ? ? ? ? ? ? ? ? Key ? ?Completion Time ? ?Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set ? ? ? ? ? 29 ? ? 2011-11-08 13:22:23
??Backup Piece ? ? ? 29 ? ? 2011-11-08 13:22:23 /opt/backup/ecp_full_13mr52ce_1_1
Backup Set ? ? ? ? ? 30 ? ? 2011-11-08 13:22:25
??Backup Piece ? ? ? 30 ? ? 2011-11-08 13:22:25 /opt/backup/ecp_full_14mr52cg_1_1
--策略還是顯示這兩個備份集違背規則
?
RMAN> DELETE NOPROMPT OBSOLETE;
?
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
using channel ORA_DISK_2
Deleting the following obsolete backups and copies:
Type ? ? ? ? ? ? ? ? Key ? ?Completion Time ? ?Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set ? ? ? ? ? 29 ? ? 2011-11-08 13:22:23
??Backup Piece ? ? ? 29 ? ? 2011-11-08 13:22:23 /opt/backup/ecp_full_13mr52ce_1_1
Backup Set ? ? ? ? ? 30 ? ? 2011-11-08 13:22:25
??Backup Piece ? ? ? 30 ? ? 2011-11-08 13:22:25 /opt/backup/ecp_full_14mr52cg_1_1
deleted backup piece
backup piece handle=/opt/backup/ecp_full_13mr52ce_1_1 recid=29 stamp=766675343
deleted backup piece
backup piece handle=/opt/backup/ecp_full_14mr52cg_1_1 recid=30 stamp=766675345
Deleted 2 objects
?
RMAN> report obsolete;
?
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
no obsolete backups found
--刪除違法策略的備份集
?
RMAN> delete ?NOPROMPT ?expired backup;
?
using channel ORA_DISK_1
using channel ORA_DISK_2
?
List of Backup Pieces
BP Key ?BS Key ?Pc# Cp# Status ? ? ?Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
34 ? ? ?34 ? ? ?1 ? 1 ? EXPIRED ? ? DISK ? ? ? ?/opt/backup/ecp_system_15mr52f1_1_1
deleted backup piece
backup piece handle=/opt/backup/ecp_system_15mr52f1_1_1 recid=34 stamp=766675425
Deleted 1 EXPIRED objects
?
RMAN> crosscheck backup;
?
using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_11mr52bv_1_1 recid=28 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_full_12mr52bv_1_1 recid=31 stamp=766675327
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_16mr52f1_1_1 recid=32 stamp=766675425
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/opt/backup/ecp_system_17mr52f2_1_1 recid=33 stamp=766675427
Crosschecked 4 objects
--刪除無效的備份集
通過實驗說明:crosscheck只能夠檢測備份集是否有效(最常見的情況就是物理上是否還存在),并且可以用它來刪除失效(expired)的備份集,而不是用來刪除違背備份策略(obsolete)的備份集,如果要刪除違背備份策略(廢棄)的備份集,需要使用obsolete操作。出現這個問題的主要原因應該是expired和obsolete翻譯成中文的時候理解的出入導致。
總結
以上是生活随笔為你收集整理的议rman的crosscheck和obsolete的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Oracle执行计划显示
- 下一篇: Expdp/Impdp 并行导入导出详细