ITPub博客

首页 > 数据库 > Oracle > RMAN的crosscheck和obsolete的用法

RMAN的crosscheck和obsolete的用法

原创 Oracle 作者:辛勤的小胖 时间:2014-03-10 12:28:31 0 删除 编辑
我一直对rman的crosschcek和obsolete的用法理解的不清楚,而且有点混乱,这样对rman的备份集甚至备份的管理造成很大的影响,今天还是及时测试一下,及时弥补这个重要环节
RMAN> show all;

RMAN configuration parameters for database with db_unique_name XUPENG are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
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 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 COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0.3/db_1/dbs/snapcf_xupeng.f'; # default
---默认策略就保留一份

---当前数据库无备份集备份
RMAN> list backup summary;

specification does not match any backup in the repository 

做一次全备!
RMAN> backup database format '/u01/backup/ora_full_%U';

Starting backup at 10-MAR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
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/app/oracle/oradata/XUPENG/users01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/XUPENG/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/XUPENG/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/XUPENG/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/XUPENG/tools.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/XUPENG/test.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/XUPENG/xupeng.dbf
channel ORA_DISK_1: starting piece 1 at 10-MAR-14
channel ORA_DISK_1: finished piece 1 at 10-MAR-14
piece handle=/u01/backup/ora_full_01p2qnrf_1_1 tag=TAG20140310T105231 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/XUPENG/fuck.dbf
channel ORA_DISK_1: starting piece 1 at 10-MAR-14
channel ORA_DISK_1: finished piece 1 at 10-MAR-14
piece handle=/u01/backup/ora_full_02p2qnrm_1_1 tag=TAG20140310T105231 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 10-MAR-14
channel ORA_DISK_1: finished piece 1 at 10-MAR-14
piece handle=/u01/backup/ora_full_03p2qnrn_1_1 tag=TAG20140310T105231 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 10-MAR-14

--备份数据文件system
RMAN> backup datafile 1 format '/u01/backup/ora_system_%U';

Starting backup at 10-MAR-14
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=00001 name=/u01/app/oracle/oradata/XUPENG/system01.dbf
channel ORA_DISK_1: starting piece 1 at 10-MAR-14
channel ORA_DISK_1: finished piece 1 at 10-MAR-14
piece handle=/u01/backup/ora_system_04p2qnuc_1_1 tag=TAG20140310T105404 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 10-MAR-14
channel ORA_DISK_1: finished piece 1 at 10-MAR-14
piece handle=/u01/backup/ora_system_05p2qnuf_1_1 tag=TAG20140310T105404 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 10-MAR-14
----所有的备份都会包括控制文件和spfile

---查看所有备份集
RMAN> list backup summary;

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
1       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105231
2       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105231
3       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105231
4       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105404
5       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105404

---这里用corsscheck 检查备份的可用性
RMAN> crosscheck backup;

using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_full_01p2qnrf_1_1 RECID=1 STAMP=841834351
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_full_02p2qnrm_1_1 RECID=2 STAMP=841834358
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_full_03p2qnrn_1_1 RECID=3 STAMP=841834360
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_system_04p2qnuc_1_1 RECID=4 STAMP=841834444
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_system_05p2qnuf_1_1 RECID=5 STAMP=841834448
Crosschecked 5 objects
---都是‘available’


---违背备份策略查看
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
-------------------- ------ ------------------ --------------------
Archive Log          1      10-MAR-14          /u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_34_824748936.dbf
Archive Log          2      10-MAR-14          /u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_35_824748936.dbf
Archive Log          3      10-MAR-14          /u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_36_824748936.dbf
Archive Log          4      10-MAR-14          /u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_37_824748936.dbf
Backup Set           3      10-MAR-14         
  Backup Piece       3      10-MAR-14          /u01/backup/ora_full_03p2qnrn_1_1
Backup Set           4      10-MAR-14         
  Backup Piece       4      10-MAR-14          /u01/backup/ora_system_04p2qnuc_1_1
Backup Set           5      10-MAR-14         
  Backup Piece       5      10-MAR-14          /u01/backup/ora_system_05p2qnuf_1_1
--这里备份了两次system,违背备份规则。。

[oracle@11g ~]$ cd /u01/backup/
[oracle@11g backup]$ ls -ltr
-rw-r----- 1 oracle oinstall   1130496 03-10 10:52 ora_full_02p2qnrm_1_1
-rw-r----- 1 oracle oinstall 298704896 03-10 10:52 ora_full_01p2qnrf_1_1
-rw-r----- 1 oracle oinstall   9601024 03-10 10:52 ora_full_03p2qnrn_1_1
-rw-r----- 1 oracle oinstall 211337216 03-10 10:54 ora_system_04p2qnuc_1_1
-rw-r----- 1 oracle oinstall   9601024 03-10 10:54 ora_system_05p2qnuf_1_1
-rw-r----- 1 oracle oinstall 211337216 03-10 10:59 ora_system_06p2qo9d_1_1
-rw-r----- 1 oracle oinstall   9601024 03-10 11:00 ora_system_07p2qo9g_1_1
[oracle@11g backup]$ mv ora_system_04p2qnuc_1_1 ora_system_04p2qnuc_1_1.bak --我们这里mv重命名后等与破坏了备份集
[oracle@11g backup]$ ls -ltr
-rw-r----- 1 oracle oinstall   1130496 03-10 10:52 ora_full_02p2qnrm_1_1
-rw-r----- 1 oracle oinstall 298704896 03-10 10:52 ora_full_01p2qnrf_1_1
-rw-r----- 1 oracle oinstall   9601024 03-10 10:52 ora_full_03p2qnrn_1_1
-rw-r----- 1 oracle oinstall 211337216 03-10 10:54 ora_system_04p2qnuc_1_1.bak
-rw-r----- 1 oracle oinstall   9601024 03-10 10:54 ora_system_05p2qnuf_1_1
-rw-r----- 1 oracle oinstall 211337216 03-10 10:59 ora_system_06p2qo9d_1_1
-rw-r----- 1 oracle oinstall   9601024 03-10 11:00 ora_system_07p2qo9g_1_1

[oracle@11g backup]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Mar 10 11:02:54 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: XUPENG (DBID=874511048)
RMAN> crosscheck backup;

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_full_01p2qnrf_1_1 RECID=1 STAMP=841834351
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_full_02p2qnrm_1_1 RECID=2 STAMP=841834358
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_full_03p2qnrn_1_1 RECID=3 STAMP=841834360
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/backup/ora_system_04p2qnuc_1_1 RECID=4 STAMP=841834444
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_system_05p2qnuf_1_1 RECID=5 STAMP=841834448
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_system_06p2qo9d_1_1 RECID=6 STAMP=841834797
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_system_07p2qo9g_1_1 RECID=7 STAMP=841834801
Crosschecked 7 objects
---这里发现有备份片‘EXPIRED’无效。

RMAN> list backup summary;

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
1       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105231
2       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105231
3       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105231
4       B  F  X DISK        10-MAR-14       1       1       NO         TAG20140310T105404
5       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105404
6       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105956
7       B  F  A DISK        10-MAR-14       1       1       NO         TAG20140310T105956
---出现X

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
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log          1      10-MAR-14          /u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_34_824748936.dbf
Archive Log          2      10-MAR-14          /u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_35_824748936.dbf
Archive Log          3      10-MAR-14          /u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_36_824748936.dbf
Archive Log          4      10-MAR-14          /u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_37_824748936.dbf
Backup Set           3      10-MAR-14         
  Backup Piece       3      10-MAR-14          /u01/backup/ora_full_03p2qnrn_1_1
Backup Set           4      10-MAR-14         
  Backup Piece       4      10-MAR-14          /u01/backup/ora_system_04p2qnuc_1_1
Backup Set           5      10-MAR-14         
  Backup Piece       5      10-MAR-14          /u01/backup/ora_system_05p2qnuf_1_1
deleted archived log
archived log file name=/u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_34_824748936.dbf RECID=1 STAMP=841833741
deleted archived log
archived log file name=/u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_35_824748936.dbf RECID=2 STAMP=841833743
deleted archived log
archived log file name=/u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_36_824748936.dbf RECID=3 STAMP=841833746
deleted archived log
archived log file name=/u01/app/oracle/product/11.2.0.3/db_1/dbs/arch1_37_824748936.dbf RECID=4 STAMP=841833748
deleted backup piece
backup piece handle=/u01/backup/ora_full_03p2qnrn_1_1 RECID=3 STAMP=841834360
deleted backup piece
backup piece handle=/u01/backup/ora_system_04p2qnuc_1_1 RECID=4 STAMP=841834444
deleted backup piece
backup piece handle=/u01/backup/ora_system_05p2qnuf_1_1 RECID=5 STAMP=841834448
Deleted 7 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> crosscheck backup;

using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_full_01p2qnrf_1_1 RECID=1 STAMP=841834351
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_full_02p2qnrm_1_1 RECID=2 STAMP=841834358
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_system_06p2qo9d_1_1 RECID=6 STAMP=841834797
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_system_07p2qo9g_1_1 RECID=7 STAMP=841834801
Crosschecked 4 objects
----无效的备份集已删除!!!!
通过此次试验得出结论crosscheck只能够检测备份集是否有效(最常见的情况就是物理上是否还存在),并且可以用它来删除失效(expired)的备份集,而不是用来删除违背备份策略(obsolete)的备份集,如果要删除违背备份策略(废弃)的备份集,需要使用obsolete操作。出现这个问题的主要原因应该是expired和obsolete翻译成中文的时候理解的出入导致的,是我理解上混淆概念!!

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28883355/viewspace-1104477/,如需转载,请注明出处,否则将追究法律责任。

上一篇: oradebug命令详解
请登录后发表评论 登录
全部评论

注册时间:2013-05-13

  • 博文量
    12
  • 访问量
    284195