标签云
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 2131 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)
- 操作系统 (102)
- 数据库 (1,682)
- DB2 (22)
- MySQL (73)
- Oracle (1,544)
- Data Guard (52)
- EXADATA (8)
- GoldenGate (24)
- ORA-xxxxx (159)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (15)
- ORACLE 21C (3)
- Oracle 23ai (7)
- Oracle ASM (67)
- Oracle Bug (8)
- Oracle RAC (53)
- Oracle 安全 (6)
- Oracle 开发 (28)
- Oracle 监听 (28)
- Oracle备份恢复 (565)
- Oracle安装升级 (92)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (79)
- PostgreSQL (18)
- PostgreSQL恢复 (6)
- SQL Server (27)
- SQL Server恢复 (8)
- TimesTen (7)
- 达梦数据库 (2)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (37)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (20)
-
最近发表
- 断电引起的ORA-08102: 未找到索引关键字, 对象号 39故障处理
- ORA-00227: corrupt block detected in control file
- 手工删除19c rac
- 解决oracle数据文件路径有回车故障
- .wstop扩展名勒索数据库恢复
- Oracle Recovery Tools工具一键解决ORA-00376 ORA-01110故障(文件offline)
- OGG-02771 Input trail file format RELEASE 19.1 is different from previous trail file form at RELEASE 11.2.
- OGG-02246 Source redo compatibility level 19.0.0 requires trail FORMAT 12.2 or higher
- GoldenGate 19安装和打patch
- dd破坏asm磁盘头恢复
- 删除asmlib磁盘导致磁盘组故障恢复
- Kylin Linux 安装19c
- ORA-600 krse_arc_complete.4
- Oracle 19c 202410补丁(RUs+OJVM)
- ntfs MFT损坏(ntfs文件系统故障)导致oracle异常恢复
- .mkp扩展名oracle数据文件加密恢复
- 清空redo,导致ORA-27048: skgfifi: file header information is invalid
- A_H_README_TO_RECOVER勒索恢复
- 通过alert日志分析客户自行对一个数据库恢复的来龙去脉和点评
- ORA-12514: TNS: 监听进程不能解析在连接描述符中给出的SERVICE_NAME
标签归档:异常恢复备份
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/对应目录.
Oracle异常恢复前备份保护现场建议—FileSystem环境
无论是在各种会议上,还是在朋友/网友私下请教Oracle数据库恢复的问题之时,我都强调,如果你没有十足的把握,请你对您的现场进行备份,确保别对现场进行二次损坏。你不能恢复数据库,但绝对不能再次破坏数据库,给二次恢复增加难度.这里对恢复前备份提供一些指导思想和简单脚本,希望对大家有帮助.
哪些文件需要备份
熟悉数据库恢复的朋友可能都情况,Oracle在异常恢复的过程中主要修改的是system表空间里面数据,其他数据文件,redo数据,控制文件(当然由于redo,undo导致其他数据文件内部的block也可能发生改变)。在备份时间,备份空间允许的情况下,是对这些文件全部备份为好
完整备份文件
set lines 150 set pages 10000 select name from v$datafile union all select name from v$controlfile union all select member from v$logfile;
有些情况下:比如如果全部备份时间过长,备份空间不足等情况下,我们该如何备份,尽量减少因为异常恢复导致对原环境的损坏.备份最核心的system表空间,数据文件头,redo file,control file等数据,由于这个不是简单的拷贝操作,因此在生成备份语句同时,也生成还原语句,切不可生成了备份语句后,无恢复语句,导致后面还原故障现场难度增大.
无法全备情况下linux/unix数据库恢复前备份
set lines 150 set pages 10000 select 'dd if='||name||' of=&&back_dir/'||ts#||'_'||file#||'.dbf bs=1048576 count=10' from v$datafile where ts#<>0 union all select 'dd if='||name||' of=&&back_dir/'||ts#||'_'||file#||'.dbf' from v$datafile where ts#=0 union all select 'dd if='||name||' of=&&back_dir/control0'||rownum||'.ctl' from v$controlfile union all select 'dd if='||member||' of=&&back_dir/'||thread#||'_'||a.group#||'_'||sequence#||'_'||substr(member, instr(member,'/',-1)+1) FROM v$log a, v$logfile b WHERE a.group# = B.GROUP#;
无法全备情况下linux/unix使用备份还原
set lines 150 set pages 1000 select 'dd of='||name||' if=&&back_dir/'||ts#||'_'||file#||'.dbf bs=1048576 count=10 conv=notrunc' from v$datafile where ts#<>0 union all select 'dd if='||name||' if=&&back_dir/'||ts#||'_'||file#||'.dbf' from v$datafile where ts#=0 union all select 'dd of='||name||' if=&&back_dir/control0'||rownum||'.ctl' from v$controlfile union all select 'dd of='||member||' if=&&back_dir/'||thread#||'_'||a.group#||'_'||sequence#||'_'||substr(member, instr(member,'/',-1)+1) FROM v$log a, v$logfile b WHERE a.group# = B.GROUP#;
由于win路径斜杠不一样(/和\的区别),因此在无法全备情况下win备份语句
set lines 150 set pages 10000 select 'dd if='||name||' of=&&back_dir\'||ts#||'_'||file#||'.dbf bs=1048576 count=10' from v$datafile where ts#<>0 union all select 'dd if='||name||' of=&&back_dir\'||ts#||'_'||file#||'.dbf' from v$datafile where ts#=0 union all select 'dd if='||name||' of=&&back_dir\control0'||rownum||'.ctl' from v$controlfile union all select 'dd if='||member||' of=&&back_dir\'||thread#||'_'||a.group#||'_'||sequence#||'_'||substr(member, instr(member,'\',-1)+1) FROM v$log a, v$logfile b WHERE a.group# = B.GROUP#;
在无法全备情况下win还原语句
set lines 150 set pages 1000 select 'dd of='||name||' if=&&back_dir\'||ts#||'_'||file#||'.dbf bs=1048576 count=10 conv=notrunc' from v$datafile where ts#<>0 union all select 'dd if='||name||' if=&&back_dir\'||ts#||'_'||file#||'.dbf' from v$datafile where ts#=0 union all select 'dd of='||name||' if=&&back_dir\control0'||rownum||'.ctl' from v$controlfile union all select 'dd of='||member||' if=&&back_dir\'||thread#||'_'||a.group#||'_'||sequence#||'_'||substr(member, instr(member,'\',-1)+1) FROM v$log a, v$logfile b WHERE a.group# = B.GROUP#;
这里提供win环境下dd命令程序win环境dd命令工具
备注:对于asm情况异常情况恢复,备份情况请不要参考该文章,具体请见后续文章,具体见Oracle异常恢复前备份保护现场建议—ASM环境