使用dd备份和恢复ASM中的数据文件头

联系:QQ(5163721)

标题:使用dd备份和恢复ASM中的数据文件头

作者:Lunar©版权所有[文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.]

今天看了飞总微博上的备份ASM中数据文件头(http://www.xifenfei.com/5888.html),觉得有意思
佩服飞总专业的钻研精神,那么多X$的internal视图……O(∩_∩)O哈哈~
这里用大家随处可见的(除了extent分布的x$kffxp需要百度和google外),其余都是文档中有详细记载的常用ASM视图来实现同样功能:

下面的用于从ASM中备份数据文件头:
[grid@lunarnew1 ~]$ ss

SQL*Plus: Release 11.2.0.4.0 Production on Sat May 16 20:03:11 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Automatic Storage Management option

SQL> set linesize 200
SQL> set pages 9999
SQL> col "backup(dd) fileheader from asm" for a200
SQL> SELECT 'dd if='||d.path||' of=&backup_path/'||e.GROUP_KFFXP||'_'||e.DISK_KFFXP||'_'
  2  ||a.file_number||'.asm'||' count=1 conv=notrunc bs='||G.ALLOCATION_UNIT_SIZE||' skip='||e.AU_KFFXP "backup(dd) fileheader from asm"
  3  FROM x$kffxp e, v$asm_file f, v$asm_alias a, v$asm_disk d, V$ASM_DISKGROUP G
  4  WHERE e.number_kffxp=a.file_number
  5  and e.GROUP_KFFXP=a.GROUP_NUMBER
  6  and f.group_number=a.group_number 
  7  and f.file_number=a.file_number 
  8  and e.DISK_KFFXP=d.DISK_NUMBER
  9  and e.GROUP_KFFXP=d.GROUP_NUMBER
 10  and a.SYSTEM_CREATED='Y'
 11  and f.type='DATAFILE'
 12  and e.XNUM_KFFXP=0
 13  AND D.GROUP_NUMBER=G.GROUP_NUMBER
 14  ;
Enter value for backup_path: /tmp
old   1: SELECT 'dd if='||d.path||' of=&backup_path/'||e.GROUP_KFFXP||'_'||e.DISK_KFFXP||'_'
new   1: SELECT 'dd if='||d.path||' of=/tmp/'||e.GROUP_KFFXP||'_'||e.DISK_KFFXP||'_'

backup(dd) fileheader from asm
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dd if=/dev/asm-disk1 of=/tmp/1_0_258.asm count=1 conv=notrunc bs=1048576 skip=45
dd if=/dev/asm-disk1 of=/tmp/1_0_260.asm count=1 conv=notrunc bs=1048576 skip=700
dd if=/dev/asm-disk1 of=/tmp/1_0_261.asm count=1 conv=notrunc bs=1048576 skip=749
dd if=/dev/asm-disk1 of=/tmp/1_0_263.asm count=1 conv=notrunc bs=1048576 skip=1101
dd if=/dev/asm-disk2 of=/tmp/1_1_262.asm count=1 conv=notrunc bs=1048576 skip=978
dd if=/dev/asm-disk2 of=/tmp/1_1_259.asm count=1 conv=notrunc bs=1048576 skip=103

6 rows selected.

SQL> 
下面的用于使用bbed修改文件头后放回到ASM中:
SQL> set linesize 200
SQL> set pages 9999
SQL> col"Restore(dd) fileheader to asm" for a200
SQL> SELECT 'dd of='||d.path||' if=&backup_path/'||e.GROUP_KFFXP||'_'||e.DISK_KFFXP||'_'
  2  ||a.file_number||'.asm'||' count=1 conv=notrunc bs='||G.ALLOCATION_UNIT_SIZE||' seek='||e.AU_KFFXP "Restore(dd) fileheader to asm"
  3  FROM x$kffxp e, v$asm_file f, v$asm_alias a, v$asm_disk d, V$ASM_DISKGROUP G
  4  WHERE e.number_kffxp=a.file_number
  5  and e.GROUP_KFFXP=a.GROUP_NUMBER
  6  and f.group_number=a.group_number 
  7  and f.file_number=a.file_number 
  8  and e.DISK_KFFXP=d.DISK_NUMBER
  9  and e.GROUP_KFFXP=d.GROUP_NUMBER
 10  and a.SYSTEM_CREATED='Y'
 11  and f.type='DATAFILE'
 12  and e.XNUM_KFFXP=0
 13  AND D.GROUP_NUMBER=G.GROUP_NUMBER
 14  ;
Enter value for backup_path: /tmp
old   1: SELECT 'dd of='||d.path||' if=&backup_path/'||e.GROUP_KFFXP||'_'||e.DISK_KFFXP||'_'
new   1: SELECT 'dd of='||d.path||' if=/tmp/'||e.GROUP_KFFXP||'_'||e.DISK_KFFXP||'_'

Restore(dd) fileheader to asm
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dd of=/dev/asm-disk1 if=/tmp/1_0_258.asm count=1 conv=notrunc bs=1048576 seek=45
dd of=/dev/asm-disk1 if=/tmp/1_0_260.asm count=1 conv=notrunc bs=1048576 seek=700
dd of=/dev/asm-disk1 if=/tmp/1_0_261.asm count=1 conv=notrunc bs=1048576 seek=749
dd of=/dev/asm-disk1 if=/tmp/1_0_263.asm count=1 conv=notrunc bs=1048576 seek=1101
dd of=/dev/asm-disk2 if=/tmp/1_1_262.asm count=1 conv=notrunc bs=1048576 seek=978
dd of=/dev/asm-disk2 if=/tmp/1_1_259.asm count=1 conv=notrunc bs=1048576 seek=103

6 rows selected.

SQL> 
此条目发表在 未分类 分类目录,贴了 标签。将固定链接加入收藏夹。

评论功能已关闭。