ITPub博客

首页 > 数据库 > Oracle > RMAN 验证 数据文件 和 备份 的有效性

RMAN 验证 数据文件 和 备份 的有效性

Oracle 作者:zhzhypg 时间:2014-11-09 22:48:50 0 删除 编辑

转载地址:http://blog.csdn.net/tianlesoftware/article/details/6460464
有关备份验证的官网链接如下:

       Validating Database Files and Backups

      http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/rcmvalid.htm#BRADV90064

 

       Rman 对数据文件的验证,主要是验证坏块,包括逻辑坏块和物理坏块。 关于坏块的说明,参考我的Blog:

       Oracle 坏块 总结

       http://blog.csdn.net/tianlesoftware/archive/2009/12/17/5024966.aspx

 

 

一. 备份DB并查看备份

 

备份脚本参考:

              Nocatalog 下的RMAN 增量备份 shell脚本

              http://blog.csdn.net/tianlesoftware/archive/2011/01/26/6164931.aspx

 

RMAN> list backup summary;

 

using target database control file instead of recovery catalog

 

List of Backups

===============

Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

------- -- -- - ----------- --------------- ------- ------- ---------- ---

9   b  1  a disk    01-jun-11       1       1       no         dave_lev1

10  b  1  a disk    01-jun-11       1       1       no         dave_lev1

13  b  a  a disk    01-jun-11       1       1       no         arc_bak

14  b  a  a disk    01-jun-11       1       1       no         arc_bak

15  b  a  a disk    01-jun-11       1       1       no         arc_bak

16  b  a  a disk    01-jun-11       1       1       no         arc_bak

17   b  a  a disk   01-jun-11       1       1       no         arc_bak

18   b  a  a disk   01-jun-11       1       1       no         arc_bak

19   b  a  a disk   01-jun-11       1       1       no         arc_bak

20   b  a  a disk   01-jun-11       1       1       no         arc_bak

21   b  a  a disk   01-jun-11       1       1       no         arc_bak

22  b  f  a disk    01-jun-11       1       1       no         bak_ctlfile

23  b  f  a disk    01-jun-11       1       1       no         spfile

 

 

二. 验证备份

 

RMAN的验证有三种方法:

       (1)VALIDATE

       (2)BACKUP ... VALIDATE

       (3)RESTORE ... VALIDATE

 

2.1 使用Validate 命令

       You can use the VALIDATE command to manually check for physical and logical corruptions in database files. This command performs the same types of checks as BACKUP VALIDATE, but VALIDATE can check a larger selection of objects.

       For example, you can validate individual blocks with the VALIDATE DATAFILE ... BLOCK command.

 

       When validating whole files, RMAN checks every block of the input files. If the backup validation discovers previously unmarked corrupt blocks, then RMAN updates the V$DATABASE_BLOCK_CORRUPTION view with rows describing the corruptions.

     -- 如果backup validation 发现了之前没有标记为corrupt 的block,则更新V$database_block_corruption 表。

 

 

验证示例:

       Use VALIDATE BACKUPSET when you suspect that one or more backup pieces in a backup set are missing or have been damaged. This command checks every block in a backup set to ensure that the backup can be restored. If RMAN finds block corruption, then it issues an error and terminates the validation. The command VALIDATE BACKUPSET enables you to choose which backups to check, whereas the VALIDATE option of the RESTORE command lets RMAN choose.

 

       For example, to validate all datafiles and control files (and the server parameter file if one is in use), execute the following command at the RMAN prompt:

       RMAN> VALIDATE DATABASE;

 

       Alternatively, you can validate a particular backup set by using the form of the command shown in the following example (sample output included).

 

RMAN> list backupset summary;

--查看backupset 的编号

List of Backups

===============

Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

------- -- -- - ----------- --------------- ------- ------- ---------- ---

9   b  1  a disk    01-jun-11       1       1       no         dave_lev1

10  b  1  a disk    01-jun-11       1       1       no         dave_lev1

13  b  a  a disk    01-jun-11       1       1       no         arc_bak

14  b  a  a disk    01-jun-11       1       1       no         arc_bak

15  b  a  a disk    01-jun-11       1       1       no         arc_bak

16  b  a  a disk    01-jun-11       1       1       no         arc_bak

17   b  a  a disk   01-jun-11       1       1       no         arc_bak

18   b  a  a disk   01-jun-11       1       1       no         arc_bak

19   b  a  a disk   01-jun-11       1       1       no         arc_bak

20   b  a  a disk   01-jun-11       1       1       no         arc_bak

21   b  a  a disk   01-jun-11       1       1       no         arc_bak

22  b  f  a disk    01-jun-11       1       1       no         bak_ctlfile

23  b  f  a disk    01-jun-11       1       1       no         spfile

 

RMAN> validate backupset 9;

-- 验证某一个validate

using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of datafile backupset

channel ORA_DISK_1: reading from backup piece /u01/backup/dave_lev1_0cmdpuof_1_1_20110601

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/backup/dave_lev1_0cmdpuof_1_1_20110601 tag=DAVE_LEV1

channel ORA_DISK_1: validation complete, elapsed time: 00:00:03

 

       The following example illustrates how you can check individual data blocks within a datafile for corruption.

-- validate 某一个数据块

 

RMAN> VALIDATE DATAFILE 1 BLOCK 10;

-- 这个功能据说是oracle 11g才有的。 我才10g里测试确实没有。

Starting validate at 17-AUG-06

using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of datafile

channel ORA_DISK_1: specifying datafile(s) for validation

input datafile file number=00001 name=/disk1/oracle/dbs/tbs_01.f

channel ORA_DISK_1: validation complete, elapsed time: 00:00:01

List of Datafiles

=================

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN

---- ------ -------------- ------------ --------------- ----------

1    OK     0              2            127             481907

  File Name: /disk1/oracle/dbs/tbs_01.f

  Block Type Blocks Failing Blocks Processed

  ---------- -------------- ----------------

  Data       0              36

  Index      0              31

  Other      0              58

 

Finished validate at 17-AUG-06

 

Make Parallel the Validation of a Datafile

       If you need to validate a large datafile, then RMAN can make the work parallel by dividing the file into sections and processing each file section in parallel. If multiple channels are configured or allocated, and if you want the channels to make parallel the validation, then specify the SECTION SIZE parameter of the VALIDATE command.

       If you specify a section size that is larger than the size of the file, then RMAN does not create file sections. If you specify a small section size that would produce more than 256 sections, then RMAN increases the section size to a value that results in exactly 256 sections.

 

To make parallel the validation of a datafile:

       Run VALIDATE with the SECTION SIZE parameter. The following example allocates two channels and validates a large datafile. The section size is 1200 MB.

 

       RUN

       {

            ALLOCATE CHANNEL c1 DEVICE TYPE DISK;

            ALLOCATE CHANNEL c2 DEVICE TYPE DISK;

            VALIDATE DATAFILE 1 SECTION SIZE 1200M;

       }

 

2.2  使用BACKUP ... VALIDATE 命令

You can use the BACKUP VALIDATE command to do the following:

       (1)Check datafiles for physical and logical block corruption

       (2)Confirm that all database files exist and are in the correct locations

 

       When you run BACKUP VALIDATE, RMAN reads the files to be backed up in their entirety, as it would during a real backup. RMAN does not, however, actually produce any backup sets or image copies.

 

       You cannot use the BACKUPSET, MAXCORRUPT, or PROXY parameters with BACKUP VALIDATE. To validate specific backup sets, run the VALIDATE command.

 

To validate files with the BACKUP VALIDATE command:

       1.Start RMAN and connect to a target database and recovery catalog (if used).

       2.Run the BACKUP VALIDATE command.

 

       For example, you can validate that all database files and archived logs can be backed up by running a command as shown in the following example. This command checks for physical corruptions only.

RMAN>backup validate database archivelog all;

 

To check for logical corruptions in addition to physical corruptions, run the following variation of the preceding command:

RMAN>backup validate check logical database archivelog all;

 

注意: 如果加上了archivelog all,就必须要有归档文件存在,如果没有归档文件,会报如下错误:

 

RMAN> backup validate database archivelog all;

starting backup at 01-jun-11

using channel ora_disk_1

rman-00571: ========================================

rman-00569: ========= error message stack follows ==========

rman-00571: ========================================

rman-03002: failure of backup command at 06/01/2011 18:49:11

rman-20242: specification does not match any archive log in the recovery catalog

 

 

示例:

RMAN> backup validate check logical database archivelog all;

 

Starting backup at 01-JUN-11

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00002 name=+DATA/anqing/datafile/undotbs01.dbf

input datafile fno=00005 name=+DATA/anqing/datafile/undotbs02.dbf

input datafile fno=00001 name=+DATA/anqing/datafile/system01.dbf

input datafile fno=00003 name=+DATA/anqing/datafile/sysaux01.dbf

input datafile fno=00004 name=+DATA/anqing/datafile/users.273.751548233

channel ORA_DISK_1: backup set complete, elapsed time: 00:07:25

channel ORA_DISK_1: starting archive log backupset

channel ORA_DISK_1: specifying archive log(s) in backup set

input archive log thread=1 sequence=44 recid=51 stamp=752698203

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

上一篇: Latch free等待事件
请登录后发表评论 登录
全部评论

注册时间:2014-09-01

  • 博文量
    62
  • 访问量
    161362