备份ASM磁盘头
ASM磁盘头信息保存在每个磁盘的前4K里面,磁盘头信息如果损坏,如果没有有效的备份,那么数据库将永久的起不来(曾经发生过相关案例)。
所以,磁盘头的备份还是非常重要的。一般情况下都用dd命令来直接备份。在此转一个也是利用dd备份的脚本:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#!/bin/sh mkdir /tmp/HC 2> /dev/null rm -f /tmp/HC/asmdisks.lst 2> /dev/null rm -f /tmp/HC/asm_diskh.sh 2> /dev/null echo " " echo "############################################" echo " 1) Collecting Information About the Disks:" echo "############################################" sqlplus '/nolog' <<eof connect / as sysdba set linesize 90 col path format a60 set heading off set head off set feedback off spool /tmp/HC/asmdisks.lst select group_number,disk_number,path from v\$asm_disk_stat where group_number > 0 order by group_number,disk_number; spool off; eof echo " " echo " " ls -l /tmp/HC/asmdisks.lst echo " " echo "############################################" echo " 2) Generating "asm_diskh.sh" script." echo "############################################" echo " " grep -v SQL /tmp/HC/asmdisks.lst > /tmp/HC/asmdisks_tmp.lst mv /tmp/HC/asmdisks_tmp.lst /tmp/HC/asmdisks.lst sed 's/ORCL:/\/dev\/oracleasm\/disks\//g' </tmp/HC/asmdisks.lst>/tmp/HC/asmdisks_NEW.lst mv /tmp/HC/asmdisks_NEW.lst /tmp/HC/asmdisks.lst cat /tmp/HC/asmdisks.lst|while read LINE do comm=`echo $LINE|awk '{print "dd if="$3 " of=/tmp/HC/dsk_"$1"_"$2".dd bs=1048576 count=1"}'` echo $comm >> /tmp/HC/asm_diskh.sh done chmod 700 /tmp/HC/asm_diskh.sh ls -l /tmp/HC/asm_diskh.sh echo " " echo "############################################" echo " 3) Executing asm_diskh.sh script to " echo " generate dd dumps." echo "############################################" echo " " ### For display only /tmp/HC/asm_diskh.sh 2> /dev/null ls -l /tmp/HC/*dd echo " " echo "############################################" echo " 4) Compressing dd dumps in the next format:" echo " (asm_dd_header_all_<date_time>.tar)" echo "############################################" echo " " NOW=$(date +"%m-%d-%Y_%T") tar -cvf /tmp/HC/asm_dd_header_all_$NOW.tar /tmp/HC/*.dd 2> /dev/null compress /tmp/HC/asm_dd_header_all_$NOW.tar ls -l /tmp/HC/*.Z |
测试如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
[grid@rac1 ~]$ ls GetAsmDH.sh GetAsmDH.sh [grid@rac1 ~]$ sh GetAsmDH.sh ############################################ 1) Collecting Information About the Disks: ############################################ SQL*Plus: Release 11.2.0.2.0 Production on Sat Feb 8 14:23:07 2014 Copyright (c) 1982, 2010, Oracle. All rights reserved. SQL> Connected. SQL> SQL> SQL> SQL> SQL> SQL> SQL> 1 0 /dev/raw/raw2 2 0 /dev/raw/raw3 2 1 /dev/raw/raw4 2 2 /dev/raw/raw5 3 0 /dev/raw/raw1 SQL> SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Real Application Clusters and Automatic Storage Management options -rw-r--r-- 1 grid oinstall 593 Feb 8 14:23 /tmp/HC/asmdisks.lst ############################################ 2) Generating asm_diskh.sh script. ############################################ -rwx------ 1 grid oinstall 351 Feb 8 14:23 /tmp/HC/asm_diskh.sh ############################################ 3) Executing asm_diskh.sh script to generate dd dumps. ############################################ -rw-r--r-- 1 grid oinstall 1048576 Feb 8 14:23 /tmp/HC/dsk_1_0.dd -rw-r--r-- 1 grid oinstall 1048576 Feb 8 14:23 /tmp/HC/dsk_2_0.dd -rw-r--r-- 1 grid oinstall 1048576 Feb 8 14:23 /tmp/HC/dsk_2_1.dd -rw-r--r-- 1 grid oinstall 1048576 Feb 8 14:23 /tmp/HC/dsk_2_2.dd -rw-r--r-- 1 grid oinstall 1048576 Feb 8 14:23 /tmp/HC/dsk_3_0.dd ############################################ 4) Compressing dd dumps in the next format: (asm_dd_header_all_<date_time>.tar) ############################################ /tmp/HC/dsk_1_0.dd /tmp/HC/dsk_2_0.dd /tmp/HC/dsk_2_1.dd /tmp/HC/dsk_2_2.dd /tmp/HC/dsk_3_0.dd -rw-r--r-- 1 grid oinstall 45973 Feb 8 14:23 /tmp/HC/asm_dd_header_all_02-08-2014_14:23:08.tar.Z [grid@rac1 ~]$ |