oracle还原txt,[20171121]rman使用copy image恢复.txt

本文探讨了RMAN在使用copyimage恢复数据文件时,文件头备份策略的重要性,以及ascopy备份方式与常规备份的区别。通过实验验证了不同备份方式对恢复过程的影响,并解释了Oracle设计背后的考虑。
摘要由CSDN通过智能技术生成

[20171121]rman使用copy image恢复.txt

--//上个星期做数据文件块头恢复时,提到使用rman备份数据文件时,文件头数据库信息是最后写入备份集文件的,在filesperset=1的情况

--//下写入备份集文件中的倒数第2块就是文件头的备份.参考链接:

--//而且我最后还做了测试证明如果resotre数据文件,实际上文件头也是最后更新到数据文件的.

--//我当时的分析是oracle这样设计有它一定道理.因为没有正确写入文件头,dbv检查报坏块.这个数据文件是"无用".

--//另外一个原因就是假设restore时发生中断,而这个时候文件头已经前期正常写入,很可能可以online该数据文件.

--//而最后写入,保证这个restore的数据文件是完整的.

--//这个就带来另外的问题oracle的备份还有另外模式backup as copy实现image的拷贝,

--//我的测试:

--//先建立空文件,然后"格式化"新块,然后顺序从数据文件写入备份文件.也就是as copy备份方式不是最后写入文件头,我前面的推测错

--//误页.

--//继续测试恢复的情况:

1.环境:

SCOTT@book> @ &r/ver1

PORT_STRING                    VERSION        BANNER

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

x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

$ cat dump_head.sh

#! /bin/bash

for i in $(seq 1000)

do

#   echo $i

xxd -c32 -g 2 -s 8192 -l 32 $1 >> /tmp/sysaux_head.txt 2>/dev/null

sleep 0.1

done

SYS@book> shutdown immediate ;

Database closed.

Database dismounted.

ORACLE instance shut down.

SYS@book> startup mount ;

ORACLE instance started.

Total System Global Area    634732544 bytes

Fixed Size                    2255792 bytes

Variable Size               197133392 bytes

Database Buffers            427819008 bytes

Redo Buffers                  7524352 bytes

Database mounted.

$ cd /mnt/ramdisk/book/

$ mv sysaux01.dbf sysaux01.dbf_20171120

2.测试:

--//首先启动dump_head.sh脚本,session 1:

$ rm /tmp/sysaux_head.txt

$ .  dump_head.sh /mnt/ramdisk/book/sysaux01.dbf

--//在sesion 2,在rman下执行恢复:

RMAN> restore datafile 2;

Starting restore at 2017-11-20 10:24:10

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=14 device type=DISK

allocated channel: ORA_DISK_3

channel ORA_DISK_3: SID=28 device type=DISK

channel ORA_DISK_1: restoring datafile 00002

input datafile copy RECID=16 STAMP=960545822 file name=/home/oracle/backup/sysaux01.dbf

destination for restore of datafile 00002: /mnt/ramdisk/book/sysaux01.dbf

channel ORA_DISK_1: copied datafile copy of datafile 00002

output file name=/mnt/ramdisk/book/sysaux01.dbf RECID=0 STAMP=0

Finished restore at 2017-11-20 10:24:19

$ .  dump_head.sh /mnt/ramdisk/book/sysaux01.dbf

^C

3.检查/tmp/sysaux_head.txt文件:

$ uniq -c /tmp/sysaux_head.txt

18 0002000: 00a2 0000 0100 8000 0000 0000 0000 0105 81a7 0000 0000 0000 0000 0000 0000 0000  ................................

46 0002000: 0ba2 0000 0100 8000 0000 0000 0000 0104 3238 0000 0000 0000 0004 200b 6e21 b74f  ................28........ .n!.O

--//我又将脚本sleep 改成0.01.重复测试:

$ grep "^0002000" /tmp/sysaux_head.txt | uniq -c

1 0002000: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  ................................

119 0002000: 00a2 0000 0100 8000 0000 0000 0000 0105 81a7 0000 0000 0000 0000 0000 0000 0000  ................................

208 0002000: 0ba2 0000 0100 8000 0000 0000 0000 0104 3238 0000 0000 0000 0004 200b 6e21 b74f  ................28........ .n!.O

--//resotre datafile 使用copy image,先建立空文件,然后"格式化"新块,然后顺序从备份文件写入数据文件.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值