博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
rman本库恢复性测试
阅读量:2387 次
发布时间:2019-05-10

本文共 6120 字,大约阅读时间需要 20 分钟。

在实际工作当中,有很多数据库是使用的unix平台,但又没有多余的相同平台的服务器做rman恢复性测试,rman备份是否可用就成了难题,但rman提供了相应的测试命令,可以在不损坏当前库的前提下验证数据库是否可用。

命令很简单,首先用preview字句来模拟需要什么备份

RMAN> run{

set until time “to_date(’2013-03-10:15:26:00′,’yyyy-dd-mm:hh24:mi:ss’)”;
restore database preview;
}

此命令只是让rman告诉你需要哪些文件来完成restore

然后用validate验证备份是否可用

RMAN> run{

set until time “to_date(’2013-03-10:15:26:00′,’yyyy-dd-mm:hh24:mi:ss’)”;
restore database validate;
}

上面命令会使用备份集来模拟restore过程,检查rman备份集是否有坏块,validate关键字还可以模拟archivedlog的resotre

RMAN> run

{
allocate channel c1 type disk;
restore archivelog from sequence xxx until sequence yyy validate;
}

下面做一个小实验验证

[oracle@rac1 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 – Production on Sun Mar 10 15:21:43 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: RACDB (DBID=794291024)

RMAN> backup check logical datafile 1;

Starting backup at 2013-03-10 15:23:05

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=142 instance=racdb1 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=00001 name=+DATA/racdb/datafile/system.259.796674269
channel ORA_DISK_1: starting piece 1 at 2013-03-10 15:24:03
channel ORA_DISK_1: finished piece 1 at 2013-03-10 15:25:13
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1 tag=TAG20130310T152347 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:10
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 2013-03-10 15:25:22
channel ORA_DISK_1: finished piece 1 at 2013-03-10 15:25:25
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/08o46cap_1_1 tag=TAG20130310T152347 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2013-03-10 15:25:25

这里为了节省时间只备份一个数据文件

RMAN> run{

set until time “to_date(’2013-03-10:15:26:00′,’yyyy-dd-mm:hh24:mi:ss’)”;
restore datafile 1 preview;
}2> 3> 4>

executing command: SET until clause

Starting restore at 2013-03-10 15:30:15

using channel ORA_DISK_1

List of Backup Sets

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

BS Key Type LV Size Device Type Elapsed Time Completion Time

——- —- — ———- ———– ———— ——————-
2 Full 588.20M DISK 00:01:14 2013-03-10 15:25:08
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20130310T152347
Piece Name: /u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
—- — —- ———- ——————- —-
1 Full 1205371 2013-03-10 15:24:09 +DATA/racdb/datafile/system.259.796674269

archived logs generated after SCN 1205371 not found in repository

Media recovery start SCN is 1205371
Recovery must be done beyond SCN 1205371 to clear datafile fuzziness
Finished restore at 2013-03-10 15:32:20

可以看到用的rman备份文件为/u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1

[grid@rac1 dbs]$ du -sh *

18M 06o462ob_1_1
589M 07o46c8c_1_1
18M 08o46cap_1_1

RMAN> run{

allocate channel c1 type disk;
set until time “to_date(’2013-03-10:15:26:00′,’yyyy-dd-mm:hh24:mi:ss’)”;
restore datafile 1 validate;
}2> 3> 4> 5>

allocated channel: c1

channel c1: SID=14 instance=racdb1 device type=DISK

executing command: SET until clause

Starting restore at 2013-03-10 15:34:32

using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of datafile backup set

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1 tag=TAG20130310T152347
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:03:15
Finished restore at 2013-03-10 15:38:15

上面输出证明此备份集是可用的,用dd命令模拟破坏rman备份

[root@rac1 ~]# dd if=/dev/zero of=/u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1 bs=1024 count=10 skip=51200

10+0 records in
10+0 records out
10240 bytes (10 kB) copied, 0.00018 seconds, 56.9 MB/s

下面验证preview和validate的结果

RMAN> run{

set until time “to_date(’2013-03-10:15:26:00′,’yyyy-dd-mm:hh24:mi:ss’)”;
restore datafile 1 preview;
}2> 3> 4>

executing command: SET until clause

Starting restore at 2013-03-10 15:42:06

using channel ORA_DISK_1

List of Backup Sets

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

BS Key Type LV Size Device Type Elapsed Time Completion Time

——- —- — ———- ———– ———— ——————-
2 Full 588.20M DISK 00:01:14 2013-03-10 15:25:08
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20130310T152347
Piece Name: /u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
—- — —- ———- ——————- —-
1 Full 1205371 2013-03-10 15:24:09 +DATA/racdb/datafile/system.259.796674269

archived logs generated after SCN 1205371 not found in repository

Media recovery start SCN is 1205371
Recovery must be done beyond SCN 1205371 to clear datafile fuzziness
Finished restore at 2013-03-10 15:42:21

RMAN>

RMAN> run{
allocate channel c1 type disk;
set until time “to_date(’2013-03-10:15:25:00′,’yyyy-dd-mm:hh24:mi:ss’)”;
restore datafile 1 validate;
}
2> 3> 4> 5>

allocated channel: c1

channel c1: SID=79 instance=racdb1 device type=DISK

executing command: SET until clause

Starting restore at 2013-03-10 15:43:27

using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of datafile backup set

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1
ORA-19505: failed to identify file “/u01/app/oracle/product/11.2.0/db_1/dbs/07o46c8c_1_1″
ORA-27048: skgfifi: file header information is invalid
Additional information: 23

failover to previous backup

datafile 1 will be created automatically during restore operation

Finished restore at 2013-03-10 15:44:26

rman备份文件损坏,validate检查出备份不可用,preview只是从控制文件中检查用哪些备份,但不做检查。

小结:在没有测试环境的情况下,用以上命令可以检查备份情况,但最好还是完善数据库环境,实际演练rman恢复。

转载地址:http://uyvab.baihongyu.com/

你可能感兴趣的文章
FileServlet supporting resume and caching and GZIP
查看>>
spring boot etag header example
查看>>
关于大数据的两个大分支
查看>>
spring boot Websocket
查看>>
关于企业到个人的转账
查看>>
Angular4中调用js代码
查看>>
JAVA8-用lamda表达式和增强版Comparator进行排序
查看>>
spring boot 2.0 使用Hikari连接池——号称java平台最快的,替换druid
查看>>
GnuPG Java Wrapper API - Sample code
查看>>
HTTP Cache 总结及Nginx Cache配置
查看>>
基于现有 TensorFlow 模型构建 Android 应用
查看>>
Building an Ionic OCR App with Tesseract
查看>>
Spring boot with Apache Hive
查看>>
使用awr来诊断数据库性能问题
查看>>
exp-00056 exp-00000 导出终止失败的处理
查看>>
oracle impdp network_link直接导入数据报ora-39064 ora-29285
查看>>
oracle 11g rac asm ORA-15064错误
查看>>
Oracle ASM Disk Header
查看>>
Oracle ASM Disk Directory
查看>>
Oracle 12C 跨网络传输数据库
查看>>