标签云
asm 恢复 asm恢复 bbed bootstrap$ dul In Memory kcbzib_kcrsds_1 kccpb_sanity_check_2 kfed MySQL恢复 ORA-00312 ORA-00607 ORA-00704 ORA-01110 ORA-01555 ORA-01578 ORA-08103 ORA-600 2662 ORA-600 2663 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 ORACLE恢复 Oracle 恢复 ORACLE数据库恢复 oracle 比特币 OSD-04016 YOUR FILES ARE ENCRYPTED 勒索恢复 比特币加密文章分类
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (100)
- 数据库 (1,597)
- DB2 (22)
- MySQL (70)
- Oracle (1,463)
- Data Guard (49)
- EXADATA (7)
- GoldenGate (21)
- ORA-xxxxx (158)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (13)
- ORACLE 21C (3)
- Oracle ASM (65)
- Oracle Bug (7)
- Oracle RAC (47)
- Oracle 安全 (6)
- Oracle 开发 (27)
- Oracle 监听 (27)
- Oracle备份恢复 (530)
- Oracle安装升级 (84)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (75)
- PostgreSQL (17)
- PostgreSQL恢复 (5)
- SQL Server (27)
- SQL Server恢复 (8)
- TimesTen (7)
- 达梦数据库 (2)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (36)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (19)
-
最近发表
- Oracle 19c/21c最新patch信息-202404
- PostgreSQL恢复系列:pg_filedump批量处理
- PostgreSQL部分主要字典信息
- PostgreSQL恢复系列:pg_filedump恢复字典构造
- PostgreSQL 16 源码安装
- ORA-00742 ORA-00312 恢复
- 数据库open成功后报ORA-00353 ORA-00354错误引起的一系列问题(本质ntfs文件系统异常)
- ORA-600 ktsiseginfo1故障
- ORA-00600: internal error code, arguments: [16703], [1403], [4] 原因
- 最近遇到几起ORA-600 16703故障(tab$被清空),请引起重视
- ORA-600 2662快速恢复之Patch scn工具
- TNS-12518: TNS:listener could not hand off client connection
- ora.storage无法启动报ORA-12514故障处理
- 断电引起文件scn异常数据库恢复
- ORA-16188: LOG_ARCHIVE_CONFIG settings inconsistent with previously started instance
- .[hudsonL@cock.li].mkp勒索加密数据库完美恢复
- 模拟带库实现rman远程备份
- 又一例:ORA-600 kclchkblk_4和2662故障
- Oracle误删除数据文件恢复
- Oracle 19C 备库DML重定向—DML Redirection
月归档:五月 2015
init.cssd startcheck—HP Service Guard未启动导致CRS无法正常启动
早上到客户现场,客户告知有一套环境替换OCR和VOTEDISK之后,crs无法启动,让我看看。环境:HP RAC(只用一个节点)+10.2.0.5 Oracle 数据库
start crs显示正常,但是无法启动
# /app/oracle/product/10.2.0/crs/bin/crsctl start crs Attempting to start CRS stack The CRS stack will be started shortly # ps -ef|grep crs root 6461 1 0 May 19 ? 0:00 /bin/sh /sbin/init.d/init.crsd run root 29719 23678 0 10:04:51 pts/tc 0:00 grep crs
也无任何日志
[xifenfei01][orawj][/root/xifenfei]#ls -ltr total 148 drwxr-x--- 2 oracle dba 96 May 15 2014 admin drwxr-x--- 2 root dba 96 May 15 2014 crsd drwxr-x--- 2 oracle dba 96 May 15 2014 evmd drwxrwxr-t 5 oracle dba 1024 Jun 4 2014 racg drwxr-x--- 5 oracle dba 1024 May 17 22:50 cssd -rw-rw-r-- 1 root dba 61568 May 24 15:26 alertxifenfei01.log drwxr-x--- 2 oracle dba 3072 May 24 15:43 client [xifenfei01][orawj][/root/xifenfei]#date Mon, May 25, 2015 11:30:09 AM
表决磁盘和OCR信息
[xifenfei01][orawj][/root/xifenfei]#ocrcheck Status of Oracle Cluster Registry is as follows : Version : 2 Total space (kbytes) : 1441492 Used space (kbytes) : 5972 Available space (kbytes) : 1435520 ID : 1714667730 Device/File Name : /dev/vgc01/rCMPR_VGC01_OCR1 Device/File integrity check succeeded Device/File Name : /dev/vgc02/rCMPR_VGC02_OCR2 Device/File integrity check succeeded Cluster registry integrity check succeeded [xifenfei01][orawj][/root/xifenfei]#crsctl query css votedisk 0. 0 /dev/vgc01/rCMPR_VGC01_VOTE1 1. 0 /dev/vgc02/rCMPR_VGC02_VOTE2 2. 0 /dev/vgc03/rCMPR_VGC03_VOTE3 located 3 votedisk(s).
ocr.loc文件路径
# more /var/opt/oracle/ocr.loc #Device/file /dev/vgc02/rCMPR_VGC02_OCR2 getting replaced by device /dev/vgc02/rCMPR_VGC02_OCR2 ocrconfig_loc=/dev/vgc01/rCMPR_VGC01_OCR1 ocrmirrorconfig_loc=/dev/vgc02/rCMPR_VGC02_OCR2 local_only=false
这里可以看出来表决磁盘和ocr等相关信息正常
显示init.cssd startcheck进程
[xifenfei01][orawj][/root/xifenfei]#ps -ef|grep init root 1 0 0 May 19 ? 0:03 init root 119 0 0 May 19 ? 0:00 pagetable_init_daemon root 115 0 0 May 19 ? 0:00 mdep_initiator_thread root 26820 26792 0 10:49:53 ? 0:00 /bin/sh /sbin/init.d/init.cssd startcheck root 26791 1 0 10:49:53 ? 0:00 /bin/sh /sbin/init.d/init.crsd run root 27183 23698 0 10:50:23 ? 0:00 /bin/sh /sbin/init.d/init.cssd startcheck root 26792 1 0 10:49:53 ? 0:00 /bin/sh /sbin/init.d/init.cssd fatal root 23698 1 0 10:45:23 ? 0:00 /bin/sh /sbin/init.d/init.evmd run root 26816 26791 0 10:49:53 ? 0:00 /bin/sh /sbin/init.d/init.cssd startcheck oracle 20534 11033 0 11:30:35 pts/ta 0:00 grep init
这里的init.cssd startcheck大部分情况下,是由于不能访问存储或者第三方集群件无法访问导致
查看vg状态
VG Name /dev/vgc01 VG Write Access read/write VG Status available Max LV 255 Cur LV 9 Open LV 9 Max PV 255 Cur PV 1 Act PV 1 Max PE per PV 3200 VGDA 2 PE Size (Mbytes) 32 Total PE 3199 Alloc PE 736 Free PE 2463 Total PVG 0 Total Spare PVs 0 Total Spare PVs in use 0 VG Version 1.0 VG Max Size 25500g VG Max Extents 816000 VG Name /dev/vgc02 VG Write Access read/write VG Status available Max LV 255 Cur LV 9 Open LV 9 Max PV 255 Cur PV 1 Act PV 1 Max PE per PV 3200 VGDA 2 PE Size (Mbytes) 32 Total PE 3199 Alloc PE 736 Free PE 2463 Total PVG 0 Total Spare PVs 0 Total Spare PVs in use 0 VG Version 1.0 VG Max Size 25500g VG Max Extents 816000 VG Name /dev/vgc03 VG Write Access read/write VG Status available Max LV 255 Cur LV 6 Open LV 6 Max PV 255 Cur PV 1 Act PV 1 Max PE per PV 3200 VGDA 2 PE Size (Mbytes) 32 Total PE 3199 Alloc PE 448 Free PE 2751 Total PVG 0 Total Spare PVs 0 Total Spare PVs in use 0 VG Version 1.0 VG Max Size 25500g VG Max Extents 816000
这里可以看到,三个存放表决磁盘和ocr的vg都是available的
看votedisk和ocr权限
# ls -l /dev/vgc0*/rCMPR*|grep -v .dbf|grep -v .log|grep -v .ctl crw-r----- 1 oracle dba 64 0x020008 May 24 14:40 /dev/vgc01/rCMPR_VGC01_OCR1 crw-r----- 1 oracle dba 64 0x020009 May 24 14:41 /dev/vgc01/rCMPR_VGC01_VOTE1 crw-r----- 1 oracle dba 64 0x030008 May 24 14:41 /dev/vgc02/rCMPR_VGC02_OCR2 crw-r----- 1 oracle dba 64 0x030009 May 24 14:41 /dev/vgc02/rCMPR_VGC02_VOTE2 crw-r----- 1 oracle dba 64 0x040006 May 24 14:41 /dev/vgc03/rCMPR_VGC03_VOTE3
直接修改权限为777,然后尝试
# chmod 777 /dev/vgc0*/rCMPR*|grep -v .dbf|grep -v .log|grep -v .ctl # ls -l /dev/vgc0*/rCMPR*|grep -v .dbf|grep -v .log|grep -v .ctl crwxrwxrwx 1 oracle dba 64 0x020008 May 24 14:40 /dev/vgc01/rCMPR_VGC01_OCR1 crwxrwxrwx 1 oracle dba 64 0x020009 May 24 14:41 /dev/vgc01/rCMPR_VGC01_VOTE1 crwxrwxrwx 1 oracle dba 64 0x030008 May 24 14:41 /dev/vgc02/rCMPR_VGC02_OCR2 crwxrwxrwx 1 oracle dba 64 0x030009 May 24 14:41 /dev/vgc02/rCMPR_VGC02_VOTE2 crwxrwxrwx 1 oracle dba 64 0x040006 May 24 14:41 /dev/vgc03/rCMPR_VGC03_VOTE3
kill相关进程重试
# ps -ef|grep init root 1 0 0 May 19 ? 0:03 init root 119 0 0 May 19 ? 0:00 pagetable_init_daemon root 115 0 0 May 19 ? 0:00 mdep_initiator_thread root 6458 1 0 May 19 ? 0:00 /bin/sh /sbin/init.d/init.evmd run root 20975 1 0 10:40:11 ? 0:00 /bin/sh /sbin/init.d/init.crsd run root 20976 1 0 10:40:11 ? 0:00 /bin/sh /sbin/init.d/init.cssd fatal root 21006 20976 0 10:40:11 ? 0:00 /bin/sh /sbin/init.d/init.cssd startcheck root 20997 20975 0 10:40:11 ? 0:00 /bin/sh /sbin/init.d/init.cssd startcheck root 21152 23678 0 10:40:18 pts/tc 0:00 grep init vi /etc/inittab #h1:3:respawn:/sbin/init.d/init.evmd run >/dev/null 2>&1 </dev/null #h2:3:respawn:/sbin/init.d/init.cssd fatal >/dev/null 2>&1 </dev/null #h3:3:respawn:/sbin/init.d/init.crsd run >/dev/null 2>&1 </dev/null # /sbin/init q # ps -ef|grep init.c | grep -v grep | awk '{print $2}' |xargs kill -9 # ps -ef|grep init root 1 0 0 May 19 ? 0:03 init root 119 0 0 May 19 ? 0:00 pagetable_init_daemon root 115 0 0 May 19 ? 0:00 mdep_initiator_thread root 21744 23678 1 10:42:31 pts/tc 0:00 grep init
重新启动init进程
vi /etc/inittab h1:3:respawn:/sbin/init.d/init.evmd run >/dev/null 2>&1 </dev/null h2:3:respawn:/sbin/init.d/init.cssd fatal >/dev/null 2>&1 </dev/null h3:3:respawn:/sbin/init.d/init.crsd run >/dev/null 2>&1 </dev/null ~ # /sbin/init q # ps -ef|grep init root 1 0 0 May 19 ? 0:03 init root 119 0 0 May 19 ? 0:00 pagetable_init_daemon root 115 0 0 May 19 ? 0:00 mdep_initiator_thread root 23737 23706 0 10:45:23 ? 0:00 /bin/sh /sbin/init.d/init.cssd startcheck root 23731 23698 0 10:45:23 ? 0:00 /bin/sh /sbin/init.d/init.cssd startcheck root 23706 1 0 10:45:23 ? 0:00 /bin/sh /sbin/init.d/init.crsd run root 23698 1 0 10:45:23 ? 0:00 /bin/sh /sbin/init.d/init.evmd run root 23887 23678 1 10:45:28 pts/tc 0:00 grep init root 23746 23700 0 10:45:23 ? 0:00 /bin/sh /sbin/init.d/init.cssd startcheck root 23700 1 0 10:45:23 ? 0:00 /bin/sh /sbin/init.d/init.cssd fatal
证明修改lv权限,问题依旧,不是votedisk和ocr的权限和所有者导致,通过dd和strings读相关文件,发现都OK.
调试/sbin/init.d/init.cssd startcheck进程
[xifenfei01][orawj][/root/xifenfei]#sh -x /sbin/init.d/init.cssd startcheck + ORA_CRS_HOME=/app/oracle/product/10.2.0/crs + ORACLE_USER=oracle + ORACLE_HOME=/app/oracle/product/10.2.0/crs + export ORACLE_HOME + export ORA_CRS_HOME + export ORACLE_USER + DISABLE_OPROCD=false + OPROCD_DEFAULT_TIMEOUT=1000 + OPROCD_DEFAULT_MARGIN=500 + OPROCD_CHECK_TIMEOUT=2000 + OPROCD_STOP_TIMEOUT=2000 + OPROCD_DEFAULT_HISTORGRAM= + HOSTN=/bin/hostname + EXPRN=/usr/bin/expr + CUT=/usr/bin/cut + AWK=/bin/awk + ECHO=echo + TR=/bin/tr + /bin/uname + [ SunOS = HP-UX ] + /bin/uname + [ Linux = HP-UX ] + + /bin/hostname HOST=xifenfei01 + + /usr/bin/expr xifenfei01 : .* len1=8 + + /usr/bin/expr match xifenfei01 [0-9]*\.[0-9]*\.[0-9]*\.[0-9]* len2=0 + [ 8 != 0 ] + + echo xifenfei01 + /usr/bin/cut -d. -f1 HOST=xifenfei01 + + echo xifenfei01 + /bin/tr [:upper:] [:lower:] HOST=xifenfei01 + PS=/bin/ps + PSE=/bin/ps -e + PSEF=/bin/ps -ef + HEAD=/bin/head + GREP=/bin/grep + KILL=/bin/kill + KILLTERM=/bin/kill -TERM + KILLDIE=/bin/kill -9 + KILLCHECK=/bin/kill -0 5852 + SLEEP=/bin/sleep + NULL=/dev/null + UNAME=/bin/uname + CAT=/bin/cat ……………… + eval /bin/true + /bin/true + [ 0 != 0 ] + eval /bin/ps -ef | /bin/grep '/usr/lbin/cm[g]msd' 1>/dev/null 2>/dev/null + /bin/grep /usr/lbin/cm[g]msd + /bin/ps -ef + 1> /dev/null 2> /dev/null + RC=1 + [ 1 -ne 0 ] + /bin/logger -puser.err Oracle Cluster Ready Services waiting for HP-UX Service Guard to start. + /bin/sleep 60
这里可以通过-x调试shell脚本,发现crs在等待HP-UX Service Guard启动,从而可以确定是由于HP-UX Service Guard未启动
检查HP-UX Service Guard是否启动
[xifenfei01][orawj][/root/xifenfei]#cmviewcl CLUSTER STATUS crmdb_b_cluster down NODE STATUS STATE xifenfei01 down unknown crmdbb02 down unknown UNOWNED_PACKAGES PACKAGE STATUS STATE AUTO_RUN NODE pkg1 down halted enabled unowned pkg2 down halted enabled unowned
通过这里,结合客户描述(只启动了一个节点,另外一个节点的vg未激活),可以判断出来由于只使用一个节点,在未启动Service Guard的情况下,直接激活vg,由于Service Guard未启动导致crs无法启动
Oracle 12C TABLE ACCESS BY INDEX ROWID BATCHED
从Oracle 12C开始执行计划中可能会出现TABLE ACCESS BY INDEX ROWID BATCHED,官方的解释:TABLE ACCESS BY INDEX ROWID BATCHED:means that the database retrieves a few rowids from the index, and then attempts to access rows in block order to improve the clustering and reduce the number of times that the database must access a block.主要意思:对于一个块中多个rowid,通过批量减少访问快的次数.而作为12.1的新特性,数据库是通过_optimizer_batch_table_access_by_rowid来控制的
数据库版本12.1
SQL> select * from v$version; BANNER CON_ID -------------------------------------------------------------------------------- ---------- Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0 PL/SQL Release 12.1.0.2.0 - Production 0 CORE 12.1.0.2.0 Production 0 TNS for IBM/AIX RISC System/6000: Version 12.1.0.2.0 - Production 0 NLSRTL Version 12.1.0.2.0 - Production 0
TABLE ACCESS BY INDEX ROWID BATCHED执行计划
SQL> set autot traceonly exp stat; SQL> var b1 number; SQL> set lines 150 SQL> set pages 10000 SQL> exec :b1:=18868701138; PL/SQL procedure successfully completed. SQL> SELECT BRAND_ID FROM T_USERTYPE_FULLNO WHERE BILL_ID= LTRIM(:B1 ,'0') AND ROWNUM < 2; Execution Plan ---------------------------------------------------------- Plan hash value: 942613467 ----------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 15 | 2 (0)| 00:00:01 | |* 1 | COUNT STOPKEY | | | | | | | 2 | TABLE ACCESS BY INDEX ROWID BATCHED| XIFENFEI | 1 | 15 | 2 (0)| 00:00:01 | |* 3 | INDEX RANGE SCAN | IND_XIFENFEI | 1 | | 2 (0)| 00:00:01 | ----------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter(ROWNUM<2) 3 - access("BILL_ID"=LTRIM(:B1,'0')) Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 5 consistent gets 0 physical reads 0 redo size 559 bytes sent via SQL*Net to client 552 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed
_optimizer_batch_table_access_by_rowid参数为true
SQL> col name for a32 SQL> col value for a24 col description for a70 set linesize 150 select a.ksppinm name,b.ksppstvl value,a.ksppdesc description SQL> SQL> SQL> 2 from x$ksppi a,x$ksppcv b 3 where a.inst_id = USERENV ('Instance') 4 and b.inst_id = USERENV ('Instance') 5 and a.indx = b.indx 6 and upper(a.ksppinm) LIKE upper('%¶m%') 7 order by name 8 / Enter value for param: _optimizer_batch_table_access_by_rowid old 6: and upper(a.ksppinm) LIKE upper('%¶m%') new 6: and upper(a.ksppinm) LIKE upper('%_optimizer_batch_table_access_by_rowid%') NAME VALUE DESCRIPTION ------------------------------------- ------------------------ ---------------------------------------------- _optimizer_batch_table_access_by_rowid TRUE enable table access by ROWID IO batching
设置_optimizer_batch_table_access_by_rowid为false,执行计划由TABLE ACCESS BY INDEX ROWID BATCHED变为TABLE ACCESS BY INDEX ROWID
SQL> set autot traceonly exp stat; SQL> var b1 number; SQL> set lines 150 SQL> set pages 10000 SQL> exec :b1:=18868701138; PL/SQL procedure successfully completed. SQL> alter session set "_optimizer_batch_table_access_by_rowid"=false; Session altered. SQL> SELECT BRAND_ID FROM XIFENFEI WHERE BILL_ID= LTRIM(:B1 ,'0') AND ROWNUM < 2; Execution Plan ---------------------------------------------------------- Plan hash value: 2797551150 --------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 15 | 2 (0)| 00:00:01 | |* 1 | COUNT STOPKEY | | | | | | | 2 | TABLE ACCESS BY INDEX ROWID| XIFENFEI | 1 | 15 | 2 (0)| 00:00:01 | |* 3 | INDEX RANGE SCAN | IND_XIFENFEI | 1 | | 2 (0)| 00:00:01 | --------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter(ROWNUM<2) 3 - access("BILL_ID"=LTRIM(:B1,'0')) Statistics ---------------------------------------------------------- 1 recursive calls 0 db block gets 5 consistent gets 0 physical reads 0 redo size 559 bytes sent via SQL*Net to client 552 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed
optimizer_features_enable修改为11.2之后,_optimizer_batch_table_access_by_rowid会联锁变为fasle
SQL> alter session set optimizer_features_enable = '11.2.0.3'; Session altered. SQL> col name for a52 col value for a24 col description for a50 set linesize 150 select a.ksppinm name,b.ksppstvl value,a.ksppdesc description from x$ksppi a,x$ksppcv b where a.inst_idSQL> SQL> SQL> SQL> 2 3 = USERENV ('Instance') and b.inst_id = USERENV ('Instance') and a.indx = b.indx and upper(a.ksppinm) LIKE upper('%¶m%') order by name 4 5 6 7 8 / Enter value for param: _optimizer_batch_table_access_by old 6: and upper(a.ksppinm) LIKE upper('%¶m%') new 6: and upper(a.ksppinm) LIKE upper('%_optimizer_batch_table_access_by%') NAME VALUE DESCRIPTION ------------------------------------------ -------------- ----------------------------------------- _optimizer_batch_table_access_by_rowid FALSE enable table access by ROWID IO batching
这里可以看出来,在调整optimizer_features_enable参数后,会直接影响某些数据库相关的优化器参数,例如:_optimizer_batch_table_access_by_rowid
Oracle异常恢复前备份保护现场建议—ASM环境
在上一篇中写道了文件系统的库,在进行异常恢复前的备份方法(Oracle异常恢复前备份保护现场建议—FileSystem环境),对于asm库,因为asm 里面的数据文件无法直接dd文件头,因此备份方式也有所改变.对于asm是mount,但是数据库不能打开,使用rman或者asm的cp命令全部备份数据文件也来不及或者空间不足,这样的情况下,你可以考虑使用rman或者cp命令备份控制文件和system表空间文件,cp命令备份redo,dd命令备份文件头,来完成asm情况下数据库异常恢复前备份
控制文件备份
11.2及其以后版本使用asmcmd cp命令处理
select 'asmcmd cp '||name||' &&backup_dir/' from v$datafile where ts#=0 union all select 'asmcmd cp '||name||' &&backup_dir/crontrofile_'||rownum||'.ctl' from v$controlfile union all select 'asmcmd cp '||member||' &&backup_dir/'||thread#||'_'||a.group#||'_'||sequence#||'_'||substr(member, instr(member,'/',-1)+1) FROM v$log a, v$logfile b WHERE a.group# = B.GROUP#;
其他版本使用rman命令处理
--rman备份控制文件(/tmp目录自己修改) copy current controlfile to '/tmp/ctl.ctl'; --rman备份system表空间 select 'copy datafile '||file#||' to ''&backup_dir/system_'||file#||'.dbf'';' from v$datafile where ts#=0; --redo无法直接备份
备份文件头
[grid@xifenfei ~]$ ss SQL*Plus: Release 11.2.0.4.0 Production on Fri May 1 04:15:18 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 lines 150 SQL> select 'dd if='||c.PATH_KFDSK||' of=&&backup_path/'||a.GROUP_KFFXP||'_'||a.disk_kffxp||'_'|| 2 b.NUMBER_KFFIL||'.asm count=1 bs='|| d.AUSIZE_KFGRP||' skip='||a.au_kffxp backup_dd_cmd 3 FROM x$kffxp a, X$KFFIL b,X$KFDSK c,X$KFGRP d WHERE 4 a.GROUP_KFFXP=b.GROUP_KFFIL 5 and a.NUMBER_KFFXP=b.NUMBER_KFFIL 6 and b.FTYPE_KFFIL in(2,12) 7 and b.NUMBER_KFFIL>255 8 and a.xnum_kffxp=0 9 and a.GROUP_KFFXP=c.GRPNUM_KFDSK 10 and a.disk_kffxp=c.NUMBER_KFDSK 11 and a.GROUP_KFFXP=d.NUMBER_KFGRP; Enter value for backup_path: /tmp old 1: select 'dd if='||c.PATH_KFDSK||' of=&&backup_path/'||a.GROUP_KFFXP||'_'||a.disk_kffxp||'_'|| new 1: select 'dd if='||c.PATH_KFDSK||' of=/tmp/'||a.GROUP_KFFXP||'_'||a.disk_kffxp||'_'|| BACKUP_DD_CMD ------------------------------------------------------------------------------------------------------------------ dd if=/dev/asm-disk1 of=/tmp/1_0_256.asm count=1 bs=1048576 skip=29 dd if=/dev/asm-disk2 of=/tmp/1_1_257.asm count=1 bs=1048576 skip=404 dd if=/dev/asm-disk2 of=/tmp/1_1_258.asm count=1 bs=1048576 skip=641 dd if=/dev/asm-disk1 of=/tmp/1_0_259.asm count=1 bs=1048576 skip=648 dd if=/dev/asm-disk3 of=/tmp/2_0_256.asm count=1 bs=1048576 skip=51
还原文件头
SQL> set lines 150 SQL> select 'dd of='||c.PATH_KFDSK||' if=&&backup_path/'||a.GROUP_KFFXP||'_'||a.disk_kffxp|| 2 '_'||b.NUMBER_KFFIL||'.asm count=1 conv=notrunc bs='|| d.AUSIZE_KFGRP||' seek='||a.au_kffxp restore_dd_cmd 3 FROM x$kffxp a, X$KFFIL b,X$KFDSK c,X$KFGRP d WHERE 4 a.GROUP_KFFXP=b.GROUP_KFFIL 5 and a.NUMBER_KFFXP=b.NUMBER_KFFIL 6 and b.FTYPE_KFFIL in(2,12) 7 and b.NUMBER_KFFIL>255 8 and a.xnum_kffxp=0 9 and a.GROUP_KFFXP=c.GRPNUM_KFDSK 10 and a.disk_kffxp=c.NUMBER_KFDSK 11 and a.GROUP_KFFXP=d.NUMBER_KFGRP; old 1: select 'dd of='||c.PATH_KFDSK||' if=&&backup_path/'||a.GROUP_KFFXP||'_'||a.disk_kffxp|| new 1: select 'dd of='||c.PATH_KFDSK||' if=/tmp/'||a.GROUP_KFFXP||'_'||a.disk_kffxp|| RESTORE_DD_CMD ----------------------------------------------------------------------------------------------------------------- dd of=/dev/asm-disk1 if=/tmp/1_0_256.asm count=1 conv=notrunc bs=1048576 seek=29 dd of=/dev/asm-disk2 if=/tmp/1_1_257.asm count=1 conv=notrunc bs=1048576 seek=404 dd of=/dev/asm-disk2 if=/tmp/1_1_258.asm count=1 conv=notrunc bs=1048576 seek=641 dd of=/dev/asm-disk1 if=/tmp/1_0_259.asm count=1 conv=notrunc bs=1048576 seek=648 dd of=/dev/asm-disk3 if=/tmp/2_0_256.asm count=1 conv=notrunc bs=1048576 seek=51 SQL>
备份还原文件头测试–通过测试证明该方法备份文件头是ok的
关闭数据库,使用dd备份文件头
[oracle@xifenfei ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Fri May 1 04:21:49 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 Partitioning, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down.
dul查看当前dbname值为XIFENFEI
[oracle@xifenfei dul]$ ./dul Data UnLoader: 10.2.0.6.5 - Internal Only - on Fri May 1 04:37:43 2015 with 64-bit io functions Copyright (c) 1994 2015 Bernard van Duijnen All rights reserved. Strictly Oracle Internal Use Only Disk group DATA, dul group_cid 0 Discovered disk /dev/asm-disk1 as diskgroup DATA, disk number 0 size 3922 Mb File1 starts at 2, dul_disk_cid 0 Discovered disk /dev/asm-disk2 as diskgroup DATA, disk number 1 size 3922 Mb without File1 meta data, dul_disk_cid 1 Disk group XIFENFEI, dul group_cid 1 Discovered disk /dev/asm-disk3 as diskgroup XIFENFEI, disk number 0 size 4439 Mb File1 starts at 2, dul_disk_cid 2 DUL: Warning: Dictionary cache DC_ASM_EXTENTS is empty Probing for attributes in File9, the attribute directory, for disk group DATA attribute name "_extent_sizes", value "1 4 16" attribute name "_extent_counts", value "20000 20000 2147483647" Oracle data file size 775954432 bytes, block size 8192 Found db_id = 1495013434 Found db_name = XIFENFEI <-----db name DUL: Error: Filedir block not allocated, file does not exist DUL: Error: Could not load asm meta data for group XIFENFEI file 9 Probing for filenames in File6, the alias directory, for disk group XIFENFEI +XIFENFEI/XIFENFEI/DATAFILE/XIFENFEI.256.878397315 Probing for database datafiles in File1, the file directory, for disk group XIFENFEI File 256 datafile size 104865792, block size 8192 Disk group XIFENFEI has one file of type datafile
使用dd备份1文件头
[oracle@xifenfei tmp]$ dd if=/dev/asm-disk1 of=/tmp/1_0_256.asm count=1 bs=1048576 skip=29 1+0 records in 1+0 records out 1048576 bytes (1.0 MB) copied, 0.0168209 seconds, 62.3 MB/s
尝试把dbname从XIFENFEI修改为ORCL
SQL> select dump('XIFENFEI',16) from dual; DUMP('XIFENFEI',16) ------------------------------------- Typ=96 Len=8: 58,49,46,45,4e,46,45,49 SQL> SELECT DUMP('ORCL',16) FROM DUAL; DUMP('ORCL',16) ------------------------- Typ=96 Len=4: 4f,52,43,4c SQL>
bbed修改XIFENFEI为ORCL
[oracle@xifenfei tmp]$ bbed filename='/tmp/1_0_256.asm' mode=edit Password: BBED: Release 2.0.0.0.0 - Limited Production on Fri May 1 04:24:06 2015 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. ************* !!! For Oracle Internal Use only !!! *************** BBED> set blocksize 8192 BLOCKSIZE 8192 BBED> set block 1 BLOCK# 1 BBED> map File: /tmp/1_0_256.asm (0) Block: 1 Dba:0x00000000 ------------------------------------------------------------ Data File Header struct kcvfh, 860 bytes @0 ub4 tailchk @8188 BBED> p kcvfhhdr struct kcvfhhdr, 76 bytes @20 ub4 kccfhswv @20 0x00000000 ub4 kccfhcvn @24 0x0b200400 ub4 kccfhdbi @28 0x591c183a text kccfhdbn[0] @32 X text kccfhdbn[1] @33 I text kccfhdbn[2] @34 F text kccfhdbn[3] @35 E text kccfhdbn[4] @36 N text kccfhdbn[5] @37 F text kccfhdbn[6] @38 E text kccfhdbn[7] @39 I BBED> d seek 32 File: /tmp/1_0_256.asm (0) Block: 1 seeks: 32 to 63 Dba:0x00000000 ------------------------------------------------------------------------ 58494645 4e464549 12040000 00720100 00200000 01000300 00000000 00000000 <32 bytes per line>
dd把修改的block还原到asm中
[oracle@xifenfei dul]$ dd of=/dev/asm-disk1 if=/tmp/1_0_256.asm count=1 conv=notrunc bs=1048576 seek=29 1+0 records in 1+0 records out 1048576 bytes (1.0 MB) copied, 0.00253244 seconds, 414 MB/s
dul验证dbname 修改为ORCL成功
[oracle@xifenfei dul]$ ./dul Data UnLoader: 10.2.0.6.5 - Internal Only - on Fri May 1 04:41:33 2015 with 64-bit io functions Copyright (c) 1994 2015 Bernard van Duijnen All rights reserved. Strictly Oracle Internal Use Only Disk group DATA, dul group_cid 0 Discovered disk /dev/asm-disk1 as diskgroup DATA, disk number 0 size 3922 Mb File1 starts at 2, dul_disk_cid 0 Discovered disk /dev/asm-disk2 as diskgroup DATA, disk number 1 size 3922 Mb without File1 meta data, dul_disk_cid 1 Disk group XIFENFEI, dul group_cid 1 Discovered disk /dev/asm-disk3 as diskgroup XIFENFEI, disk number 0 size 4439 Mb File1 starts at 2, dul_disk_cid 2 DUL: Warning: Dictionary cache DC_ASM_EXTENTS is empty Probing for attributes in File9, the attribute directory, for disk group DATA attribute name "_extent_sizes", value "1 4 16" attribute name "_extent_counts", value "20000 20000 2147483647" Oracle data file size 775954432 bytes, block size 8192 Found db_id = 1495013434 Found db_name = ORCL <----修改后的dbname DUL: Error: Filedir block not allocated, file does not exist DUL: Error: Could not load asm meta data for group XIFENFEI file 9 Probing for filenames in File6, the alias directory, for disk group XIFENFEI +XIFENFEI/XIFENFEI/DATAFILE/XIFENFEI.256.878397315 Probing for database datafiles in File1, the file directory, for disk group XIFENFEI File 256 datafile size 104865792, block size 8192 Disk group XIFENFEI has one file of type datafile
对于asm无法mount情况下备份asm disk header
asm磁盘的备份主要是备份磁盘头100M空间,使用dd命令直接备份
set lines 150 set pages 1000 select 'dd if='||path||' of=&asmbackup_dir/'||group_number||'_'||disk_number||'.asm bs=1048576 count=100' from v$asm_disk;
set lines 150 set pages 1000 select 'dd of='||path||' if=&asmbackup_dir/'||group_number||'_'||disk_number||'.asm bs=1048576 count=100 conv=notrunc' from v$asm_disk;
asmlib需要注意把ORCL:替换为/dev/oracleasm/disks/对应目录.