`
helloyesyes
  • 浏览: 1306571 次
  • 性别: Icon_minigender_2
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

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

阅读更多

有关备份验证的官网链接如下:

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的验证有三种方法:

1VALIDATE

2BACKUP ... VALIDATE

3RESTORE ... 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:

1Check datafiles for physical and logical block corruption

2Confirm 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

--验证归档

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current control file in backupset

including current SPFILE in backupset

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 01-JUN-11

如果数据库较大,检查的时间会较长。

In the preceding examples, the RMAN client displays the same output that it would if it were really backing up the files. If RMAN cannot back up one or more of the files, then it issues an error message.

如果RMAN 不能备份某个文件,则报如下错误:

For example, RMAN may show output similar to the following:

RMAN-00571: ==============================================

RMAN-00569: ======== ERROR MESSAGE STACK FOLLOWS =======

RMAN-00571: ==============================================

RMAN-03002: failure of backup command at 08/29/2007 14:33:47

ORA-19625: error identifying file /oracle/oradata/trgt/arch/archive1_6.dbf

ORA-27037: unable to obtain file status

SVR4 Error: 2: No such file or directory

Additional information: 3

2.3 使用 RESTORE ... VALIDATE 命令

You can run RESTORE ... VALIDATE to test whether RMAN can restore a specific file or set of files from a backup. RMAN chooses which backups to use.

The database must be mounted or open for this command. You do not have to take datafiles offline when validating the restore of datafiles, because validation of backups of the datafiles only reads the backups and does not affect the production datafiles.

-- validate 只读取backup file,不影响production datafiles

When validating files on disk or tape, RMAN reads all blocks in the backup piece or image copy. RMAN also validates offsite backups. The validation is identical to a real restore operation except that RMAN does not write output files.

To validate backups with the RESTORE command:

Run the RESTORE command with the VALIDATE option.

1. This following example illustrates validating the restore of the database and all archived redo logs:

RESTORE DATABASE VALIDATE;

RESTORE ARCHIVELOG ALL VALIDATE;

If you do not see an RMAN error stack, then skip the subsequent steps. The lack of error messages means that RMAN had confirmed that it can use these backups successfully during a real restore and recovery.

2. If you see error messages in the output and the RMAN-06026 message, then investigate the cause of the problem. If possible, correct the problem that is preventing RMAN from validating the backups and retry the validation.

The following error means that RMAN cannot restore one or more of the specified files from your available backups:

RMAN-06026: some targets not found - aborting restore

The following sample output shows that RMAN encountered a problem reading the specified backup:

RMAN-03009: failure of restore command on c1 channel at 12-DEC-06 23:22:30

ORA-19505: failed to identify file "oracle/dbs/1fafv9gl_1_1"

ORA-27037: unable to obtain file status

SVR4 Error: 2: No such file or directory

Additional information: 3

示例:

--验证控制文件

RMAN> restore controlfile validate;

Starting restore at 01-JUN-11

using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of datafile backupset

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

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/backup/ctl_file_0omdpvv7_1_1_20110601 tag=BAK_CTLFILE

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

Finished restore at 01-JUN-11

--验证spfile 有效性

RMAN> restore spfile validate;

Starting restore at 01-JUN-11

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_spfile_0pmdpvva_1_1_20110601

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/backup/dave_spfile_0pmdpvva_1_1_20110601 tag=SPFILE

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

Finished restore at 01-JUN-11

--验证数据库

RMAN> restore database validate;

Starting restore at 01-JUN-11

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_lev0_10mdqqtd_1_1_20110601

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/backup/dave_lev0_10mdqqtd_1_1_20110601 tag=DAVE_LEV0

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

channel ORA_DISK_1: starting validation of datafile backupset

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

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/backup/dave_lev0_0vmdqqtd_1_1_20110601 tag=DAVE_LEV0

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

Finished restore at 01-JUN-11

在验证这块的时候有个小插曲,参考:

RMAN-06023 : no backup or copy of datafile found to restore 说明

http://blog.csdn.net/tianlesoftware/archive/2011/06/02/6460459.aspx

--验证归档有效性

开始验证的是所有的归档文件,但是no backup found的错误。如下:

RMAN> restore archivelog all validate;

Starting restore at 01-JUN-11

using channel ORA_DISK_1

RMAN-00571: ====================================

RMAN-00569: ========ERROR MESSAGE STACK FOLLOWS ========

RMAN-00571: ==============================================

RMAN-03002: failure of restore command at 06/01/2011 22:10:42

RMAN-06026: some targets not found - aborting restore

RMAN-06025: no backup of log thread 2 seq 3 lowscn 1829719 found to restore

RMAN-06025: no backup of log thread 2 seq 2 lowscn 1746388 found to restore

RMAN-06025: no backup of log thread 2 seq 1 lowscn 946447 found to restore

.....

RMAN-06025: no backup of log thread 1 seq 2 lowscn 480030 found to restore

RMAN-06025: no backup of log thread 1 seq 1 lowscn 460026 found to restore

RMAN-06025: no backup of log thread 1 seq 3 lowscn 460020 found to restore

RMAN-06025: no backup of log thread 1 seq 2 lowscn 451150 found to restore

因为我之前已经删除了一些归档的备份,我这次备份只有3个归档,查看了一下日志的最大序列数:

SYS@anqing1(rac1)> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)

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

47

所以从45 开始验证,执行通过:

RMAN> restore archivelog sequence 45 validate;

</s

分享到:
评论

相关推荐

    rman数据备份

    3. 表空间和数据文件备份:针对特定表空间或数据文件进行备份,适用于需要保护特定部分数据库的情况。 二、RMAN备份策略 1. 镜像副本:RMAN可以直接复制数据文件到另一个位置,创建镜像副本,提供快速恢复的手段。 ...

    三思Oracle_RMAN数据备份恢复

    RMAN是Oracle Database 9i引入的一个特性,它提供了对数据库、控制文件、归档日志、数据文件以及参数文件等关键组件的全面备份和恢复功能。RMAN可以使用多种备份类型,包括完整备份、增量备份和差异备份,同时支持...

    rman备份还原亲测成功

    在Oracle数据库管理中,RMAN(Recovery Manager)是一个强大的工具,主要用于数据库的备份与恢复操作。本教程基于Oracle 11g R2...记得定期测试备份的完整性和有效性,以确保在真正需要时能够迅速、准确地恢复数据库。

    oracle10g rman 备份

    6. **验证备份**:使用`VERIFY`命令可以验证备份集的完整性,确保备份可用。 7. **恢复操作**:在需要恢复时,RMAN提供了一系列恢复命令,如`RESTORE`和`RECOVER`。恢复操作可能涉及到数据文件、控制文件或整个...

    rman备份概念文档

    RMAN (Recovery Manager) 是Oracle数据库管理系统中的一个重要工具,用于执行数据库的备份和恢复操作。这个文档将深入讲解RMAN的基本概念、操作步骤...同时,记得定期测试备份的完整性和恢复过程,以验证备份的有效性。

    RMAN备份与恢复

    "rman1.pdf"可能详细阐述了RMAN的基本命令和操作流程,包括连接数据库、创建备份集、恢复数据文件、验证备份的完整性以及执行数据库恢复。RMAN的恢复过程通常涉及还原备份、应用redo日志和打开数据库等步骤。在恢复...

    Linux 平台下 RMAN 全备 和 增量备份 shell 脚本

    - **备份验证**:定期验证备份的有效性非常重要,可以通过 `CROSSCHECK` 命令检查备份文件是否仍然可用。 综上所述,在 Linux 平台上使用 RMAN 进行数据库备份是一项重要的运维任务。通过编写自动化脚本,不仅可以...

    linux下rman备份笔记

    2. **验证备份**:备份后立即进行一致性验证,确认备份的完整性。 3. **备份策略**:根据业务需求制定合适的备份策略,定期清理过期备份。 4. **网络设置**:如果使用网络备份,需要配置网络环境和相关服务。 综上...

    Oracle 9i 培训资料:使用RMAN的高级备份和恢复

    2. **备份集和映像副本**:备份集是RMAN特有的备份格式,它能将多个数据文件或控制文件合并到一个物理文件中,减少备份占用的空间。映像副本则是直接复制数据文件的物理拷贝,适用于快速恢复。 3. **备份验证**:...

    oracle 11g rman 备份与恢复

    8. **验证**:RMAN提供了备份集和映像副本的验证功能,确保备份文件的完整性和可恢复性。 9. **闪回技术**:结合Oracle的闪回功能,RMAN可以实现快速的数据恢复,即使在没有完整备份的情况下,也能通过闪回日志恢复...

    rman备份脚本(已测试)

    在测试和生产环境中,一个经过验证的RMAN备份脚本能够确保数据的安全性和可恢复性。 首先,了解RMAN备份脚本的基本结构。一个典型的RMAN脚本通常包含以下部分: 1. **连接信息**:指定要备份的数据库实例,可能...

    利用SHELL脚本来验证Oracle的RMAN备份集和定期恢复实验.pdf

    RMAN可以备份Oracle数据库的物理文件,也可以备份和恢复数据文件、控制文件、归档日志等。 - RMAN支持增量备份,能够有效地管理备份数据。它还能够进行备份集的校验,确保备份的有效性,以及在需要时进行恢复操作。...

    ORACLE rman备份与恢复

    通过RMAN备份与恢复的测试,我们可以验证备份策略的有效性,确保在实际灾难情况下能够快速恢复数据库服务。测试涵盖了从备份配置、备份执行、到不同情况下的恢复步骤,全面评估了RMAN的功能和性能。 在实际操作中...

    Rman初学者了解很有 帮助的文件

    RMAN(Recovery Manager)是Oracle数据库管理系统中的一个重要工具,专为数据库备份、恢复和维护设计。对于初学者来说,理解和...在实际操作中,结合RMAN提供的日志和报告功能,可以有效地监控和管理数据库的备份策略。

    Oracle 11g 部署rman定时备份文档(windows+linux).docx

    Oracle 11g 的 RMAN (Recovery Manager) 是一种强大的数据库备份和恢复工具,它提供了灵活、自动化的备份方案。在 Windows 和 Linux ...同时,对于生产环境,建议定期测试备份恢复流程,以验证备份的完整性和有效性。

    oracle_9i_rman_备份与恢复技术

    通过以上对Oracle 9i RMAN备份与恢复技术的学习,我们可以了解到如何有效地利用RMAN来保障数据库的安全性和可用性。无论是基本的备份与恢复操作,还是高级的恢复技术,RMAN都提供了强大的支持。在实际应用中,根据...

    RMAN备份技术解决方案.pdf

    总而言之,文档中的内容强调了RMAN备份技术的灵活性和强大功能,包括备份控制文件、数据库、归档日志的压缩备份,以及增量备份的能力。此外,还演示了如何利用Cron作业来自动化备份流程,并确保备份操作的定时和高效...

    oracle_9i_rman_backup_restore.rar

    Oracle 9i RMAN( Recovery ...总之,Oracle 9i RMAN提供了一套全面的备份和恢复解决方案,确保了企业级数据库的安全性和可靠性。通过合理配置和使用RMAN,可以有效降低数据丢失的风险,快速恢复服务,保障业务连续性。

    ORACLE RMAN备份脚本

    ### ORACLE RMAN备份脚本知识点解析 #### 一、RMAN简介 RMAN(Recovery Manager)是...企业应根据自身业务特点和数据量大小来定制合适的备份方案,同时也要关注备份过程中的细节问题,确保备份的有效性和可靠性。

Global site tag (gtag.js) - Google Analytics