模拟sql server故障备份完成恢复实现数据0丢失

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:模拟sql server故障备份完成恢复实现数据0丢失

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

在sql server数据库中,使用备份还原,可以用来恢复的备份文件只能是全备、增量备份、事务日志备份,在很多情况下,sql server生产库异常,最后的事务日志没有来得及备份(但是ldf文件存在),这种情况下如何最大限度恢复数据实现数据0丢失,其实最重要的关键点就是对最后异常库的ldf文件的事务日志进行备份,在sql server里面给这个操作起了一个专业的词叫做:备份结尾日志(Tail of log).我这边通过一个实验来模拟整个操作过程.
1. 创建一个库,恢复模式为完整
s1


2.创建表并插入一条记录,然后进行全备
s2
s3

3. 再插入一条记录,并做事务日志备份
s4
s5

4. 再插入一条记录,并在脱机情况下删除掉数据库的mdf文件(模拟故障),在实际生产中如果原机器损坏,可以把在新机器上安装同版本sql,然后创建同名库,把ldf文件替换
s6
s8

5. 进行最后的ldf(事务日志的备份),在sql server中这个备份操作叫做“备份结尾日志(Tail of log)”,先尝试直接使用图形化工具进行备份
s9

6. 图形化这种情况无法直接备份,使用命令行形式成功备份
s10

这里备份命令带WITH NORECOVERY、WITH NO_TRUNCATE、WITH CONTINUE_AFTER_ERROR相关内容官方描述:

如果数据库处于联机状态并且您计划对数据库执行还原操作,则从备份日志结尾开始。 
要避免联机数据库出错,必须使用 BACKUP Transact-SQL 语句的 WITH NORECOVERY 选项。

如果数据库处于脱机状态而无法启动,则需要还原数据库,从备份日志结尾开始。 
由于此时不会发生任何事务,因此请使用 WITH NO_TRUNCATE 选项。 
NO_TRUNCATE 实际上与仅复制事务日志备份相同。 由于此时不会发生任何事务,因此可以选择使用 WITH NORECOVERY。

如果数据库损坏,则尝试使用 WITH CONTINUE_AFTER_ERROR 语句的 BACKUP 选项执行结尾日志备份。

在损坏的数据库上,仅当日志文件未受损、数据库处于支持结尾日志备份的状态并且数据库不包含任何大容量日志更改时,
日志尾部备份才会成功。 如果无法创建结尾日志备份,则最新日志备份后提交的任何事务都将丢失。

7. 进行数据库还原操作(这里先删除了故障库和对应ldf文件),也可以还原成其他库名和不同路径,也可以通过命令行进行还原(全备和除最后一个事务日志之前的备份需要使用WITH NORECOVERY)
s11
s12
s13


基于上述测试,完美的恢复故障之前的所有数据

sql server 事务日志备份异常恢复案例

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:sql server 事务日志备份异常恢复案例

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

有客户的sql server数据库运行在双机环境中,由于心跳网络异常导致双机频繁切换最终数据库损坏DBCC检查报大量错误

DBCC CHECKDB('OLTP') WITH NO_INFOMSGS, ALL_ERRORMSGS

Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 28147935764938752 (type Unknown), page ID (1:33059984) contains an incorrect page ID in its page header. The PageId in the page header = (68:3276868).
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 11540680206712832 (type Unknown), page ID (1:33059985) contains an incorrect page ID in its page header. The PageId in the page header = (102:6488116).
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 16888988233302016 (type Unknown), page ID (1:33059986) contains an incorrect page ID in its page header. The PageId in the page header = (93:6619252).
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 16888988233302016 (type Unknown), page ID (1:33059987) contains an incorrect page ID in its page header. The PageId in the page header = (93:6619252).
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 16888988233302016 (type Unknown), page ID (1:33059988) contains an incorrect page ID in its page header. The PageId in the page header = (93:6619252).
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 28147836977938432 (type Unknown), page ID (1:33059989) contains an incorrect page ID in its page header. The PageId in the page header = (73:6619248).
Msg 8909, Level 16, State 1, Line 1
……………………
Object ID 1961110077, index ID 0, partition ID 72057594217627648, alloc unit ID 72057594256687104 (type In-row data): Page (1:36535484) could not be processed.  See other errors for details.
Msg 8928, Level 16, State 1, Line 1
Object ID 1961110077, index ID 0, partition ID 72057594217627648, alloc unit ID 72057594256687104 (type In-row data): Page (1:36535485) could not be processed.  See other errors for details.
Msg 8928, Level 16, State 1, Line 1
Object ID 1961110077, index ID 0, partition ID 72057594217627648, alloc unit ID 72057594256687104 (type In-row data): Page (1:36535486) could not be processed.  See other errors for details.
Msg 8928, Level 16, State 1, Line 1
Object ID 1961110077, index ID 0, partition ID 72057594217627648, alloc unit ID 72057594256687104 (type In-row data): Page (1:36535487) could not be processed.  See other errors for details.
CHECKDB found 0 allocation errors and 24 consistency errors in table 'CIOMessage' (object ID 1961110077).
CHECKDB found 0 allocation errors and 17955 consistency errors in database 'OLTP'.

Completion time: 2025-11-19T17:13:03.2762122+08:00

客户每天做全库备份,每4小时做事务日志备份,备份类似这样的情况
sql0


客户尝试使用全备进行恢复,结果发现只有13日的全备是好的,可以还原出来数据库,其他备份还原直接报错,基于这样的情况,可以希望把数据恢复到11月19日.我接手这个故障之后,先尝试还原13日的备份
sql6

然后尝试人工应用事务日志备份,类似命令

RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_13_030001_7745248.trn' WITH NORECOVERY
RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_13_060001_3581210.trn' WITH NORECOVERY
RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_13_090001_2856408.trn' WITH NORECOVERY
RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_13_120002_0713663.trn' WITH NORECOVERY
RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_13_150001_7305524.trn' WITH NORECOVERY
RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_13_180000_9123036.trn' WITH NORECOVERY
RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_13_210001_3663138.trn' WITH NORECOVERY
RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_14_000001_1605695.trn' WITH NORECOVERY
RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_14_030001_7280782.trn' WITH NORECOVERY
………………
RESTORE LOG OLTP1121 FROM DISK = 'D:\share\OLTP_backup_2025_11_17_180001_1343952.trn' WITH NORECOVERY

结果在OLTP_backup_2025_11_17_180001_1343952文件位置报错

Processed 0 pages for database 'OLTP_1121', file 'OLTP' on file 1.
Processed 10388 pages for database 'OLTP1121', file 'OLTP_log' on file 1.
Msg 9004, Level 16, State 3, Line 1
An error occurred while processing the log for database 'OLTP_1121'.  If possible, restore from backup. 
If a backup is not available, it might be necessary to rebuild the log.
Msg 3013, Level 16, State 1, Line 1
RESTORE LOG is terminating abnormally.

Completion time: 2025-11-21T13:41:54.2352031+08:00

通过图形化界面进行事务日志恢复也报错
sql7


基于这样的情况,数据库层面的正常恢复途径只能恢复到11月17日18时左右数据,因为后面的日志发生了损坏,无法继续正常恢复,对于这种情况,我们这边使用日志解析工具对剩余事务日志备份进行解析,生成.sql文件
sql3
sql1

然后客户把解析出来的.sql文件依次在会到11月17日18时的库上面去执行,这样顺利吧客户整体数据库恢复到最新状态,完成本次恢复任务(注意后续可能一些类似序列值需要调整)

win平台挂起Oracle数据库启动进程

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:win平台挂起Oracle数据库启动进程

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

对于oracle的有些故障,如果数据库完全open会报错,导致启动失败,这个时候,我们可以尝试在数据库open到一半的过程中把启动过程挂起,然后登录数据库对字典进行修复,然后就可以正常启动数据库。非win平台可以通过gdb挂起数据库启动过程,因为win系统是进程模式,无法通过gdb挂起来实现,通过自己写程序修改oracle内存来实现这个功能

Oracle Recovery Tools工具中,点击修改内存—>检索Oracle数据库进程—>选择需要操作的数据库进程—>挂起Oracle进程 就可以实现oracle数据库在open的过程中挂住
QQ20251208-180202


然后其他会话登录数据库,进行需要的操作,再重新点击取消挂起数据库可以继续open成功
QQ20251208-174237

linux异常磁盘lvm恢复操作演示

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:linux异常磁盘lvm恢复操作演示

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

有客户exsi系统被勒索病毒加密,拷贝出来磁盘文件,通过工具分析,磁盘文件均有部分被破坏,恢复工具无法自动识别
QQ20251206-001609


无法扫描到任何分区信息
QQ20251206-001942

和客户沟通确认三快盘采用的是lvm方式管理,尝试检索lvm信息
lvm1
lvm2

检索lv信息
lvm3

选择合适的lv,进行读取
lvm4

人工选择合适的磁盘作为pv
lvm5

直接查看lv中数据
lvm6

open数据库报ora-600 kdsgrp1故障处理

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:open数据库报ora-600 kdsgrp1故障处理

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

客户服务器异常关机之后,数据库无法正常启动,查看alert日志发现如下报ORA-600 kdsgrp1报错信息导致数据库无法正常open

2025-12-05T16:17:23.315325+08:00
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
stopping change tracking
Undo initialization recovery: err:0 start: 7620046 end: 7620062 diff: 16 ms (0.0 seconds)
Errors in file D:\APP\ADMINISTRATOR\diag\rdbms\his\his\trace\his_ora_9672.trc  (incident=1243378):
ORA-00600: 内部错误代码, 参数: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []
Incident details in: D:\APP\ADMINISTRATOR\diag\rdbms\his\his\incident\incdir_1243378\his_ora_9672_i1243378.trc
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
2025-12-05T16:17:25.341421+08:00
*****************************************************************
An internal routine has requested a dump of selected redo.
This usually happens following a specific internal error, when
analysis of the redo logs will help Oracle Support with the
diagnosis.
It is recommended that you retain all the redo logs generated (by
all the instances) during the past 12 hours, in case additional
redo dumps are required to help with the diagnosis.
*****************************************************************
2025-12-05T16:17:25.533576+08:00
Errors in file D:\APP\ADMINISTRATOR\diag\rdbms\his\his\trace\his_ora_9672.trc  (incident=1243379):
ORA-00600: 内部错误代码, 参数: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []
Incident details in: D:\APP\ADMINISTRATOR\diag\rdbms\his\his\incident\incdir_1243379\his_ora_9672_i1243379.trc
2025-12-05T16:17:27.007101+08:00
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
2025-12-05T16:17:27.008097+08:00
Undo initialization online undo segments: err:600 start: 7620062 end: 7623343 diff: 3281 ms (3.3 seconds)
2025-12-05T16:17:27.008097+08:00
Errors in file D:\APP\ADMINISTRATOR\diag\rdbms\his\his\trace\his_ora_9672.trc:
ORA-00600: 内部错误代码, 参数: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []
2025-12-05T16:17:27.008097+08:00
Errors in file D:\APP\ADMINISTRATOR\diag\rdbms\his\his\trace\his_ora_9672.trc:
ORA-00600: 内部错误代码, 参数: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []
Error 600 happened during db open, shutting down database
Errors in file D:\APP\ADMINISTRATOR\diag\rdbms\his\his\trace\his_ora_9672.trc  (incident=1243380):
ORA-00603: ORACLE 服务器会话因致命错误而终止
ORA-01092: ORACLE 实例终止。强制断开连接
ORA-00600: 内部错误代码, 参数: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []
Incident details in: D:\APP\ADMINISTRATOR\diag\rdbms\his\his\incident\incdir_1243380\his_ora_9672_i1243380.trc
2025-12-05T16:17:28.540363+08:00
opiodr aborting process unknown ospid (9672) as a result of ORA-603

尝试人工启动数据库,报错比较明显也是ORA-600 kdsgrp1错误

C:\Users\Administrator>sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Dec 5 16:45:48 2025
Version 19.3.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> recover datafile 1;
Media recovery complete.
SQL> recover database;
Media recovery complete.
SQL> alter database open ;
alter database open
*
ERROR at line 1:
ORA-00603: ORACLE server session terminated by fatal error
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00600: internal error code, arguments: [kdsgrp1], [], [], [], [], [], [],
[], [], [], [], []
Process ID: 10800
Session ID: 5025 Serial number: 34108

查看报错trace文件

*** CLIENT DRIVER:(SQL*PLUS) 2025-12-05T16:17:23.924647+08:00
 
[TOC00000]
Jump to table of contents
Dump continued from file: D:\APP\ADMINISTRATOR\diag\rdbms\his\his\trace\his_ora_9672.trc
[TOC00001]
ORA-00600: 内部错误代码, 参数: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []

[TOC00001-END]
[TOC00002]
========= Dump for incident 1243378 (ORA 600 [kdsgrp1]) ========
[TOC00003]
----- Beginning of Customized Incident Dump(s) -----
kdsDumpState: cdb: 0 dspdb: 0 type: 1 info: 0x5 flag: 0x0
kdsDumpState: sample type: 0 layer: 0
* kdsgrp1-1: ***********************************************
            row 0x00c02754.24 continuation at: 0x00c02754.24 file# 3 block# 10068 slot 36 not found (dscnt: 0)
 state kdscurrid points to 0x00c28206.17
KDSTABN_GET: 0 ..... ntab: 1
curSlot: 36 ..... nrows: 60
Dumping kcb descriptor:
kcbds 0x1e08fe71510: pdb 0, tsn 1, rdba 0x00c02754, afn 3, objd 11331, cls 1, tidflg 0x8 0x80 0x0

在这里基本上可以确认报ORA-600 错误的是file 3 block 10068,dataobj 为11331,根据经验初步怀疑是sysaux中的wrh$_某个对象异常.对启动过程做10046进一步确认

EXEC #2063975471112:c=17341,e=35163,p=54,cr=283,cu=0,mis=1,r=0,dep=1,og=4,plh=794648223,tim=9717774784
WAIT #2063975471112: nam='db file sequential read' ela= 115 file#=3 block#=11434 blocks=1 obj#=11579 tim=9717774961
WAIT #2063975471112: nam='db file sequential read' ela= 93 file#=3 block#=11435 blocks=1 obj#=11579 tim=9717775098
WAIT #2063975471112: nam='db file sequential read' ela= 89 file#=3 block#=11436 blocks=1 obj#=11579 tim=9717775217
WAIT #2063975471112: nam='db file sequential read' ela= 98 file#=3 block#=11437 blocks=1 obj#=11579 tim=9717775361
WAIT #2063975471112: nam='db file sequential read' ela= 23087 file#=3 block#=11438 blocks=1 obj#=11579 tim=9717798471
WAIT #2063975471112: nam='db file sequential read' ela= 83 file#=3 block#=11439 blocks=1 obj#=11579 tim=9717798681
WAIT #2063975471112: nam='db file sequential read' ela= 183 file#=3 block#=10075 blocks=1 obj#=11332 tim=9717799100
WAIT #2063975471112: nam='db file sequential read' ela= 124 file#=3 block#=10078 blocks=1 obj#=11332 tim=9717799291
WAIT #2063975471112: nam='db file sequential read' ela= 115 file#=3 block#=165702 blocks=1 obj#=11332 tim=9717799460
WAIT #2063975471112: nam='db file sequential read' ela= 109 file#=3 block#=83355 blocks=1 obj#=11332 tim=9717799621
WAIT #2063975471112: nam='db file sequential read' ela= 139 file#=3 block#=165703 blocks=1 obj#=11332 tim=9717799816
WAIT #2063975471112: nam='db file sequential read' ela= 139 file#=3 block#=10079 blocks=1 obj#=11332 tim=9717800074
WAIT #2063975471112: nam='db file sequential read' ela= 112 file#=3 block#=165696 blocks=1 obj#=11332 tim=9717800248
WAIT #2063975471112: nam='db file sequential read' ela= 110 file#=3 block#=165701 blocks=1 obj#=11332 tim=9717800502
WAIT #2063975471112: nam='db file sequential read' ela= 107 file#=3 block#=83354 blocks=1 obj#=11332 tim=9717800665
WAIT #2063975471112: nam='db file sequential read' ela= 109 file#=3 block#=83356 blocks=1 obj#=11332 tim=9717800823
WAIT #2063975471112: nam='db file sequential read' ela= 107 file#=3 block#=83358 blocks=1 obj#=11332 tim=9717800978
WAIT #2063975471112: nam='db file sequential read' ela= 106 file#=3 block#=165698 blocks=1 obj#=11332 tim=9717801133
WAIT #2063975471112: nam='db file sequential read' ela= 106 file#=3 block#=164358 blocks=1 obj#=11331 tim=9717801298
WAIT #2063975471112: nam='db file sequential read' ela= 108 file#=3 block#=10068 blocks=1 obj#=11331 tim=9717801509
2025-12-05T16:52:21.382064+08:00
ORA-00600: internal error code, arguments: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []

FETCH #2063975471112:c=1599462,e=1655487,p=20,cr=26,cu=0,mis=0,r=0,dep=1,og=4,plh=794648223,tim=9719430286
STAT #2063975471112 id=1 cnt=0 pid=0 pos=1 obj=0 op='SORT AGGREGATE (cr=0 pr=0 pw=0 str=1 time=8 us)'
STAT #2063975471112 id=2 cnt=0 pid=1 pos=1 obj=0 op='HASH JOIN  (cr=0 pr=0 pw=0 str=1 time=5 us cost=9 size=34 card=1)'
STAT #2063975471112 id=3 cnt=1 pid=2 pos=1 obj=11579 op='TABLE ACCESS FULL WRM$_SNAPSHOT
 (cr=12 pr=6 pw=0 str=1 time=23966 us cost=4 size=17 card=1)'
STAT #2063975471112 id=4 cnt=1 pid=3 pos=1 obj=0 op='SORT AGGREGATE (cr=6 pr=3 pw=0 str=1 time=23513 us)'
STAT #2063975471112 id=5 cnt=1 pid=4 pos=1 obj=11579 op='TABLE ACCESS FULL WRM$_SNAPSHOT
(cr=6 pr=3 pw=0 str=1 time=23497 us cost=4 size=13 card=1)'
STAT #2063975471112 id=6 cnt=6 pid=2 pos=2 obj=11331 op='TABLE ACCESS BY INDEX ROWID BATCHED WRH$_UNDOSTAT
(cr=13 pr=13 pw=0 str=1 time=2455 us cost=4 size=102 card=6)'
STAT #2063975471112 id=7 cnt=7 pid=6 pos=1 obj=11332 op='INDEX SKIP SCAN WRH$_UNDOSTAT_PK
(cr=12 pr=12 pw=0 str=1 time=2304 us cost=2 size=0 card=6)'
2025-12-05T16:52:23.005928+08:00
ORA-00600: internal error code, arguments: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []

<error barrier> at 0x000000275BED14D0 placed dbsdrv.c@4959
ORA-00600: internal error code, arguments: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []
<error barrier> at 0x000000275BED14D0 placed dbsdrv.c@4959
ORA-00600: internal error code, arguments: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []

到这里基本上可以确认是WRH$_UNDOSTAT_PK去找WRH$_UNDOSTAT中午对应记录,从而出现该问题,对应的具体sql为

PARSING IN CURSOR #2063975471112 len=233 dep=1 uid=0 oct=3 lid=0 tim=9717739563
  hv=517686153 ad='1e1efda1f20' sqlid='d4m7ss0gdqhw9'
select max(maxconcurrency) from sys.wrh$_undostat where instance_number = :1 and dbid = :2 and snap_id in  
(select snap_id from dba_hist_snapshot where end_interval_time >(select max(end_interval_time)-7 from dba_hist_snapshot))

BINDS #2063975471112:

 Bind#0
  oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00
  oacflg=00 fl2=0000 frm=00 csi=00 siz=48 off=0
  kxsbbbfp=8e8646e8  bln=22  avl=02  flg=05
  value=1
 Bind#1
  oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00
  oacflg=00 fl2=0000 frm=00 csi=00 siz=0 off=24
  kxsbbbfp=8e864700  bln=22  avl=06  flg=01
  value=971429521

对于这种问题,处理起来相对比较简单,绕过oracle open过程对该sql的执行,然后open库对该表的index进行rebuild

SQL> recover database;
Media recovery complete.
SQL> alter database open;

Database altered.

SQL> SELECT OWNER, SEGMENT_NAME, SEGMENT_TYPE, TABLESPACE_NAME, A.PARTITION_NAME
  2    FROM DBA_EXTENTS A
  3   WHERE FILE_ID = &FILE_ID
  4     AND &BLOCK_ID BETWEEN BLOCK_ID AND BLOCK_ID + BLOCKS - 1;
Enter value for file_id: 3
old   3:  WHERE FILE_ID = &FILE_ID
new   3:  WHERE FILE_ID = 3
Enter value for block_id: 10068
old   4:    AND &BLOCK_ID BETWEEN BLOCK_ID AND BLOCK_ID + BLOCKS - 1
new   4:    AND 10068 BETWEEN BLOCK_ID AND BLOCK_ID + BLOCKS - 1

OWNER
--------------------------------------------------------------------------------
SEGMENT_NAME
--------------------------------------------------------------------------------
SEGMENT_TYPE       TABLESPACE_NAME
------------------ ------------------------------
PARTITION_NAME
--------------------------------------------------------------------------------
SYS
WRH$_UNDOSTAT
TABLE              SYSAUX



SQL> select index_name from dba_indexes where table_name='WRH$_UNDOSTAT';

INDEX_NAME
--------------------------------------------------------------------------------
WRH$_UNDOSTAT_PK

SQL> alter index WRH$_UNDOSTAT_PK REBUILD ONLINE;

Index altered.

至此该数据库完成恢复任务,重启之后一切正常.

expdp dmp 导出不完整导入ORA-39059 ORA-39246 故障抢救数据

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:expdp dmp 导出不完整导入ORA-39059 ORA-39246 故障抢救数据

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

客户一套nc系统,由于安装时候把库建在了比较小的分区上,运行一些时间之后,出现空间不足,现场技术人员对oracle不太熟悉,经过一系列操作(删除业务表空间,复制pdb,创建表空间等等操作),无法恢复数据库,准备使用备份的dmp进行还原,结果分析发现仅保留的最后一份dmp,是一份导出不完全的dmp文件,无法正常导入(以前处理过一个类似case:ORA-39773: parse of metadata stream failed故障处理,尝试导入报ORA-39246错:

C:\Users\XFF>impdp system/oracle@127.0.0.1/orapdb directory=expdp_dir dumpfile=xxxxx_2025-12-01_0230.dmp logfile=1.log

Import: Release 19.0.0.0.0 - Production on 星期三 12月 3 21:00:19 2025
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

连接到: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
ORA-39002: 操作无效
ORA-39059: 转储文件集不完整
ORA-39246: 无法在提供的转储文件中定位主表

分析当时当初的dmp日志,由于expdp的job表所在表空间不足导致expdp导出失败
dmp1


TABLE:"XIFENFEI"."EOM_MEASURE_POINT"
ORA-30032: 挂起的 (可恢复) 语句已超时
ORA-01691: Lob 段 XIFENFEI.SYS_LOB0000161267C00111$$ 无法通过 32 (在表空间 NNC_DATA01 中) 扩展
ORA-06512: 在 "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: 在 "SYS.KUPW$WORKER", line 12620
ORA-06512: 在 "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: 在 "SYS.KUPW$WORKER", line 11414
----- PL/SQL Call Stack -----
  object      line  object
  handle    number  name
0xda5dae50     33476  package body SYS.KUPW$WORKER.WRITE_ERROR_INFORMATION
0xda5dae50     12641  package body SYS.KUPW$WORKER.DETERMINE_FATAL_ERROR
0xda5dae50     11602  package body SYS.KUPW$WORKER.CREATE_OBJECT_ROWS
0xda5dae50     15268  package body SYS.KUPW$WORKER.FETCH_XML_OBJECTS
0xda5dae50      3907  package body SYS.KUPW$WORKER.UNLOAD_METADATA
0xda5dae50     13736  package body SYS.KUPW$WORKER.DISPATCH_WORK_ITEMS
0xda5dae50      2429  package body SYS.KUPW$WORKER.MAIN
0x6524a4f0         2  anonymous block
KUPW: Object row index into parse items is: 1
KUPW: Parse item count is: 19
KUPW: In function CHECK_FOR_REMAP_NETWORK
KUPW: Nothing to remap
KUPW: In procedure BUILD_OBJECT_STRINGS - non-base info
KUPW: In procedure BUILD_SUBNAME_LIST with TABLE:XIFENFEI.EOM_MEASURE_POINT
KUPW: In function NEXT_PO_NUMBER
KUPW: PO number assigned: 34198
FORALL
KUPW: In procedure DETERMINE_FATAL_ERROR with ORA-30032: 挂起的 (可恢复) 语句已超时
ORA-01691: Lob 段 XIFENFEI.SYS_LOB0000161267C00111$$ 无法通过 32 (在表空间 NNC_DATA01 中) 扩展
作业 "XIFENFEI"."SYS_EXPORT_SCHEMA_01" 因致命错误于 星期一 12月 1 06:33:21 2025 elapsed 0 04:03:18 停止

从导出日志看,在导出大量”0 KB 0 行”记录之后提示表空间不足,expdp的job表无法扩展导致导出挂起然后超时导出终止(这个导出操作没有完全完成),从而在导入的时候出现了ORA-39059: 转储文件集不完整 ORA-39246: 无法在提供的转储文件中定位主表 的错误.对于这种故障,分析导出日志,发现运气不错,所有有数据的表都导出完成,基于这个心中就有了第一层底气,所有表数据不会丢失(因为都导出到了这个dmp中),但是非表的字典数据不完整,要想业务完整跑起来,需要找到一个完整的业务字典信息.对于大量的备份dmp被删除,然后对应分区还写入了很多数据,只能尝试看运气,通过对磁盘文件镜像,然后进行反删除恢复,找出来一个11月26日的dmp的压缩文件是完整的
good-dmp


通过这个dmp导入业务字典信息,然后再利用expdp dmp解析工具(expdp dmp被加密破坏恢复)把所有表数据出来,经过这两者组合,顺利完成数恢复,可以测试业务完全正常

mysql drop database 恢复思路

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:mysql drop database 恢复思路

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

今天有一个客户在在虚拟机环境中使用drop database删除一个业务mysql的库,删除之后,第一时间关闭了该虚拟机系统.接到该case请求之后,让客户提供了虚拟机文件(vmdk),通过工具分析,mysql数据库是放在/分区下面的/data里面(lvm结构,xfs文件系统),但是已经看不到他们删除的数据库(mysql一个库对应一个目录)
mysql


对于这种情况,我们第一步尝试文件系统层面反删除恢复(对数据库所在分区进行文件系统层面扫描,尝试恢复被删除的mysql表文件),运气不错,找到了一些被删除库的ibd文件
ibd

对于这些文件,选择出来客户需要的表,采用discard+import方式进行恢复,类似命令

alter table tablename discard tablespace;
alter table tablename import tablespace;

对于有些部分block损坏的ibd文件,直接这样操作可能会报Data structure corruption错误,这样的情况,可以通过工具解析ibd文件进行恢复


对于有些表,可能在文件系统层面反删除无法恢复,我们通过对磁盘进行mysql的数据块层面扫描(识别在磁盘上没有覆盖的mysql的block),按照pageid的方式进行重组成一个个page文件
page

然后基于这些page进行恢复需要的表数据
11

基本上通过上述的方法实现最大限度mysql删除数据的恢复(比如drop database,drop table,truncate table)
如果MySQL数据库恢复问题,需要专业恢复技术支持,请联系我们提供专业MySql数据库恢复服务:
电话/微信:17813235971    Q Q:107644445QQ咨询惜分飞    E-Mail:dba@xifenfei.com

PRVG-11975 : The I/O scheduler parameter of device “/dev/sdm” did not match the expected value on nodes

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:PRVG-11975 : The I/O scheduler parameter of device “/dev/sdm” did not match the expected value on nodes

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

今天在oracle linux 7.9的系统中装Oracle 19.29集群采用gridSetup applyRU 的方式安装

su – grid
cd $ORACLE_HOME
./gridSetup.sh -applyRU /soft/38298204/

在检测的步骤I/O scheduler warning
PRVG-11975


具体内容类似:

I/O scheduler - This task checks the I/O scheduler parameter configured Error: 
PRVG-11975:The I/O scheduler parameter of device "/dev/sdm" did not match the expected value on nodes "hisdb2,hisdb2". 
[Expected scheduler = "none" ; Found scheduler = "mq-deadline"] ? Cause:?The I/O scheduler parameter of the indicated 
device was not  the expected value on the indicated nodes. ? Action:?Change the I/O scheduler parameter using 
'echo deadline > /sys/block/<device>/queue/scheduler' command of the indicated device to ensure it is the expected value. 

大概的意思是磁盘的I/O scheduler parameter被检查出来是mq-deadline,实际要求为:deadline,并建议使用echo deadline > /sys/block//queue/scheduler命令来修改,检查存储磁盘的实际值

[grid@hisdb1 grid]$ cat /sys/block/sdm/queue/scheduler
[mq-deadline] kyber bfq none

确实I/O scheduler为mq-deadline,查询了相关描述:
mq-deadline 是 deadline 调度器的多队列升级版,核心设计目标一致(按 “截止时间” 调度以保证 I/O 延迟),但适配的硬件场景、性能表现差异显著 —— 简单说:deadline 是为传统单队列设备(如 HDD)设计的老版本,mq-deadline 是为现代多队列设备(如 SSD/NVMe)优化的新版本。
21


客户这边刚好是华为的ssd存储,使用mq-deadline是非常合理的,如果调整为deadline反而不太合理了.初步感觉这个问题应该是Oracle 本身检测不合理导致,进一步查询MOS,Oracle自己也承认了该问题:
bug-36183757

对于ssd环境,可以忽略该警告,继续安装

obet(Oracle Block Editor Tool)第二版发布

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:obet(Oracle Block Editor Tool)第二版发布

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

在几天之前发布了obet的第一个版本(Oracle数据块编辑工具( Oracle Block Editor Tool)-obet),最近对功能进行了一些完善,并发布第二版(下载地址:下载obet),主要增加了以下几个功能:
0) corrupt [block x] 命令主要用于标记坏块功能(在第一版中已经完善)
1) repair [block x] 命令对于坏块的自动修复,主要包括checksum,tailchk,seq_kcbh等
2)增加copy chkscn 命令主要用于对文件头的checkpoint scn相关信息修复
3)增加copy resetlogscn命令主要用于对文件头的resetlogs相关信息修复
4)把之前的copy命令调整为copy data命令格式
5)增加copy block命令主要用于数据文件之间的数据块直接拷贝
该版本的help命令提示

OBET (Oracle Block Editor Tool) commands:
  open <config_file>    - Load file list from config file (format: <num> <path>)
  info                  - Show loaded file list (from open command)
  set filename <path>   - Set target file path (required)
  set file <num>        - Set filename using loaded file number (from open list)
  set blocksize <size>  - Set block size (2048,4096,[8192],16384,32768)
  set block <num>       - Set block number (starts from 0, default: 1)
  set offset <offset>   - Set offset within block (< blocksize, default: 0)
  set count <bytes>     - Set number of bytes to read (default: 32)
  set mode edit/browse  - Enable edit/browse mode
  d/dump [options]      - Display data (options: block X, offset Y, count N)
  m/modify <hex> [opts] - Modify data with hex (opts: block X, offset Y)
  undo                  - Undo last modification
  sum [block X]         - Calculate checksum for block (default: current block)
  sum apply [block X]   - Apply checksum: write calculated value to block
  tailchk [block X]     - Calculate tailchk for block (default: current block)
  tailchk apply [block X] - Apply tailchk: write calculated value to block
  repair [block X]      - Repair bad block (fix seq_kcbh, tailchk, checksum)
  copy data <src> to <dest>  - Copy data between files
    <src> format: file,block,offset,count (e.g., 1,1,10,64)
    <dest> format: file[,block][,offset] (e.g., 3 or 3,1 or 3,1,128)
  copy block file#,block# to file#,block#     - Copy entire data block
  copy chkscn file n to file m         - Copy datafile header checkpoint SCN info
  copy resetlogscn file n to file m    - Copy datafile header resetlogs info
  corrupt [block X]     - Mark block as corrupted (default: current block)
  show                  - Display current settings (filename, blocksize, block, offset, count, mode)
  license               - Show/manage software license (registration code required)
  version               - Show software version and developer information
  p/print <param>       - Print Oracle structure,Use the 'p/print' command to see details
  undo                  - Undo the last copy chkscn or copy resetlogscn operation
  help                  - Show this help message
  quit/exit             - Exit OBET

copy block功能演示
随便把一个block拷贝到文件的另外位置,也可以拷贝到不同文件的其他位置,根据需要调整

OBET> copy block 1,1 to 1,5

Confirm copy block:
Source: file#1 (/u01/xifenfei/system01.dbf), block 1 (entire 8192-byte block)
Target: file#1 (/u01/xifenfei/system01.dbf), block 5 (entire 8192-byte block)
Proceed? (Y/YES to confirm): y
Successfully copied block 1 from file#1 to block 5 in file#1 (8192 bytes).

OBET> set file 1 
filename set to: /u01/xifenfei/system01.dbf (file#1)

OBET> set count 128
count set to: 128

OBET> dump block 1 offset 0

File: /u01/xifenfei/system01.dbf
Block: 1                Offsets:     0 to   127
--------------------------------------------------------------------------------
00002000 01230000 01004000 00000000 00000104 28C60000 00000000 0004200B A2DB266A 
00002020 58494645 4E464549 AC020000 00720100 00200000 01000300 00000000 00000000 
00002040 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
00002060 08024000 07000000 00000000 7DC92131 12345678 87654321 00000000 00000000 

<128 bytes read>

OBET> dump block 5 offset 0

File: /u01/xifenfei/system01.dbf
Block: 5                Offsets:     0 to   127
--------------------------------------------------------------------------------
0000A000 01230000 01004000 00000000 00000104 28C60000 00000000 0004200B A2DB266A 
0000A020 58494645 4E464549 AC020000 00720100 00200000 01000300 00000000 00000000 
0000A040 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
0000A060 08024000 07000000 00000000 7DC92131 12345678 87654321 00000000 00000000 

<128 bytes read>

copy chkscn功能演示

OBET> p kcvfh.kcvfhckp
File: H:\xifenfei\system01.dbf
Size: 8192 bytes
Block: 1
Offset: 484

struct kcvfhckp, 36 bytes                   @484
   struct kcvcpscn, 8 bytes                 @484
      ub4 kscnbas                          @484     0x1BDDBF09
      ub2 kscnwrp                          @488     0x163D
      ub2 kscnwrp2                         @490     0x0000
   ub4 kcvcptim                            @492     0x488361FC
   ub2 kcvcpthr                            @496     0x0001
   union u, 12 bytes                       @500
      struct kcvcprba, 12 bytes            @500
         ub4 kcrbaseq                     @500     0x0006E3D3
         ub4 kcrbabno                     @504     0x0000B44B
         ub2 kcrbabof                     @508     0x0010
   ub1 kcvcpetb[8]                         @512-519 02 00 00 00 00 00 00 00


OBET> p kcvfh.kcvfhckp
File: H:\xifenfei\sysaux01.dbf
Size: 8192 bytes
Block: 1
Offset: 484

struct kcvfhckp, 36 bytes                   @484
   struct kcvcpscn, 8 bytes                 @484
      ub4 kscnbas                          @484     0x67452301
      ub2 kscnwrp                          @488     0x0000
      ub2 kscnwrp2                         @490     0x0000
   ub4 kcvcptim                            @492     0x00000000
   ub2 kcvcpthr                            @496     0x0000
   union u, 12 bytes                       @500
      struct kcvcprba, 12 bytes            @500
         ub4 kcrbaseq                     @500     0x0006E3D3
         ub4 kcrbabno                     @504     0x0000B44B
         ub2 kcrbabof                     @508     0x0010
   ub1 kcvcpetb[8]                         @512-519 02 00 00 00 00 00 00 00

<kcvfh.kcvfhckp structure printed successfully>



OBET> copy chkscn file 1 to file 2

Confirm Modify chkscn:
Source: file#1 (H:\xifenfei\system01.dbf)
Target: file#2 (H:\xifenfei\sysaux01.dbf)
Proceed? (Y/YES to confirm): y
Successfully copied checkpoint SCN information from file#1 to file#2.

OBET> p kcvfh.kcvfhckp
File: H:\xifenfei\sysaux01.dbf
Size: 8192 bytes
Block: 1
Offset: 484

struct kcvfhckp, 36 bytes                   @484
   struct kcvcpscn, 8 bytes                 @484
      ub4 kscnbas                          @484     0x1BDDBF09
      ub2 kscnwrp                          @488     0x163D
      ub2 kscnwrp2                         @490     0x0000
   ub4 kcvcptim                            @492     0x488361FC
   ub2 kcvcpthr                            @496     0x0001
   union u, 12 bytes                       @500
      struct kcvcprba, 12 bytes            @500
         ub4 kcrbaseq                     @500     0x0006E3D3
         ub4 kcrbabno                     @504     0x0000B44B
         ub2 kcrbabof                     @508     0x0010
   ub1 kcvcpetb[8]                         @512-519 02 00 00 00 00 00 00 00

<kcvfh.kcvfhckp structure printed successfully>

copy resetlogscn功能演示

OBET> p kcvfh.kcvfhrlc
File: H:\xifenfei\system01.dbf
Size: 8192 bytes
Block: 1
Offset: 112

ub4 kcvfhrlc                             @112     0x3215EC5C

<kcvfh.kcvfhrlc structure printed successfully>

OBET> p kcvfh.kcvfhrls
File: H:\xifenfei\system01.dbf
Size: 8192 bytes
Block: 1
Offset: 116

struct kcvfhrls, 8 bytes                    @116
   ub4 kscnbas                             @116     0x000E74FF
   ub2 kscnwrp                             @120     0x0000
   ub2 kscnwrp2                            @122     0x0000

<kcvfh.kcvfhrls structure printed successfully>


OBET> p kcvfh.kcvfhrlc
File: H:\xifenfei\sysaux01.dbf
Size: 8192 bytes
Block: 1
Offset: 112

ub4 kcvfhrlc                             @112     0x67452301

<kcvfh.kcvfhrlc structure printed successfully>

OBET> p kcvfh.kcvfhrls
File: H:\xifenfei\sysaux01.dbf
Size: 8192 bytes
Block: 1
Offset: 116

struct kcvfhrls, 8 bytes                    @116
   ub4 kscnbas                             @116     0x43658709
   ub2 kscnwrp                             @120     0x0021
   ub2 kscnwrp2                            @122     0x0000

<kcvfh.kcvfhrls structure printed successfully>

OBET> copy resetlogscn file 1 to file 2

Confirm Modify resetlogscn:
Source: file#1 (H:\xifenfei\system01.dbf)
Target: file#2 (H:\xifenfei\sysaux01.dbf)
Proceed? (Y/YES to confirm): y
Successfully copied resetlog SCN information from file#1 to file#2.

OBET> p kcvfh.kcvfhrlc
File: H:\xifenfei\sysaux01.dbf
Size: 8192 bytes
Block: 1
Offset: 112

ub4 kcvfhrlc                             @112     0x3215EC5C

<kcvfh.kcvfhrlc structure printed successfully>

OBET> p kcvfh.kcvfhrls
File: H:\xifenfei\sysaux01.dbf
Size: 8192 bytes
Block: 1
Offset: 116

struct kcvfhrls, 8 bytes                    @116
   ub4 kscnbas                             @116     0x000E74FF
   ub2 kscnwrp                             @120     0x0000
   ub2 kscnwrp2                            @122     0x0000

<kcvfh.kcvfhrls structure printed successfully>

corrupt [block x]标记坏块功能

C:\Users\XFF>dbv file=h:/xifenfei/users01.dbf

DBVERIFY: Release 11.2.0.4.0 - Production on 星期三 11月 12 21:40:55 2025

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - 开始验证: FILE = H:\XIFENFEI\USERS01.DBF


DBVERIFY - 验证完成

检查的页总数: 26656
处理的页总数 (数据): 23569
失败的页总数 (数据): 0
处理的页总数 (索引): 309
失败的页总数 (索引): 0
处理的页总数 (其他): 720
处理的总页数 (段)  : 0
失败的总页数 (段)  : 0
空的页总数: 2058
标记为损坏的总页数: 0
流入的页总数: 0
加密的总页数        : 0
最高块 SCN            : 2255414715 (18.2255414715)


OBET> corrupt block 10

Confirm modification:
File: h:/xifenfei/users01.dbf
Block: 10
Offset: 14 (file offset: 0x0001400E)
Original value: 01
New value:      FF
Are you sure to set this block corrupted? (Y/YES to proceed): y
Verification successful: Block 10 marked as corrupted (offset 14 set to 0xFF).
Modification successful.

C:\Users\XFF>dbv file=h:/xifenfei/users01.dbf

DBVERIFY: Release 11.2.0.4.0 - Production on 星期三 11月 12 21:41:22 2025

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - 开始验证: FILE = H:\XIFENFEI\USERS01.DBF
页 10 流入 - 很可能是介质损坏
Corrupt block relative dba: 0x0100000a (file 4, block 10)
Fractured block found during dbv:
Data in bad block:
 type: 30 format: 2 rdba: 0x0100000a
 last change scn: 0x0000.00003e78 seq: 0xff flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x3e781e01
 check value in block header: 0x1a6
 computed block checksum: 0xfe



DBVERIFY - 验证完成

检查的页总数: 26656
处理的页总数 (数据): 23569
失败的页总数 (数据): 0
处理的页总数 (索引): 309
失败的页总数 (索引): 0
处理的页总数 (其他): 719
处理的总页数 (段)  : 0
失败的总页数 (段)  : 0
空的页总数: 2058
标记为损坏的总页数: 1
流入的页总数: 1
加密的总页数        : 0
最高块 SCN            : 2255414715 (18.2255414715)

repair [block x]修复坏块功能

C:\Users\XFF>dbv file=h:/xifenfei/undo01.dbf

DBVERIFY: Release 11.2.0.4.0 - Production on 星期日 11月 16 00:06:59 2025

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - 开始验证: FILE = H:\XIFENFEI\UNDO01.DBF
页 2 流入 - 很可能是介质损坏
Corrupt block relative dba: 0x02000002 (file 8, block 2)
Fractured block found during dbv:
Data in bad block:
 type: 29 format: 2 rdba: 0x02000002
 last change scn: 0x163d.1bddbcfa seq: 0xff flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0xbcfa1d02
 check value in block header: 0xec11
 computed block checksum: 0xfd



DBVERIFY - 验证完成

检查的页总数: 4880
处理的页总数 (数据): 0
失败的页总数 (数据): 0
处理的页总数 (索引): 0
失败的页总数 (索引): 0
处理的页总数 (其他): 4372
处理的总页数 (段)  : 11
失败的总页数 (段)  : 0
空的页总数: 507
标记为损坏的总页数: 1
流入的页总数: 1
加密的总页数        : 0
最高块 SCN            : 467517187 (5693.467517187)

OBET> repair

Repairing block 2 in file H:\xifenfei\undo01.dbf...

Repair analysis for block 2:
1. seq_kcbh check: 0xFF -> needs repair (0x01)
2. Tailchk check: 0x021DFABC -> needs repair (0x011DFABC)
3. Checksum check: 0x11EC -> OK

Confirm repair operations:
File: H:\xifenfei\undo01.dbf
Block: 2
Operations needed: fix offset14, fix tailchk
Confirm? (Y/YES to proceed): y

Verification after repair:
1. seq_kcbh: 0x01 OK
2. Tailchk: 0x011DFABC OK
3. Checksum: 0x11EC OK

Block 2 repair completed successfully.


C:\Users\XFF>dbv file=h:/xifenfei/undo01.dbf

DBVERIFY: Release 11.2.0.4.0 - Production on 星期日 11月 16 00:07:29 2025

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - 开始验证: FILE = H:\XIFENFEI\UNDO01.DBF


DBVERIFY - 验证完成

检查的页总数: 4880
处理的页总数 (数据): 0
失败的页总数 (数据): 0
处理的页总数 (索引): 0
失败的页总数 (索引): 0
处理的页总数 (其他): 4373
处理的总页数 (段)  : 11
失败的总页数 (段)  : 0
空的页总数: 507
标记为损坏的总页数: 0
流入的页总数: 0
加密的总页数        : 0
最高块 SCN            : 467517187 (5693.467517187)

Oracle数据块编辑工具( Oracle Block Editor Tool)-obet

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:Oracle数据块编辑工具( Oracle Block Editor Tool)-obet

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

由于oracle后续版本对于bbed的支持不是太友好(从10g之后无法直接编译使用,win版本偏移量错误等),基于这些情况,结合当前ai的便利,自己动手写了一个基础版的obet(Oracle Block Editor Tool),用来实现在某些情况下Oracle 数据块的编辑工作.目前(2025年11月7日)发布第一版主要功能有:
1. 通过16进制查看数据文件任何偏移量位置的数据(d/dump)
2. 通过16进制编辑数据文件任何偏移量位置的数据(m/modify)
3. 对oracle 数据块的tailchk自动修复(tailchk apply)
4. 对oracle 数据块的checksum自动修复(sum apply)
5. 数据文件之间部分数据拷贝功能(coopy)

启动软件界面

[root@iZbp11c0qyuuo1gr7j98upZ tmp]# ./obet
=============================================
Welcome to Oracle Block Editor Tool (OBET)
=============================================

***** !!! For Oracle Internal Use only !!! *****

[Software Function Description]
- View and edit data block in hexadecimal format
- Automatically repair tailchk and checksum
- Copy data between different data files
- Mark data block as corrupted block

[Developer Information]
- Name: XiFenFei
- Phone: +86-17813235971
- Email: dba@xifenfei
- Q Q: 107644445
- WeChat: 17813235971
- Website: https://www.xifenfei.com

[Version Details]
- Software Version: v2025.11.001
- Build Date: 2025.11.07

=============================================
Type 'help' for command list | 'exit' to quit
=============================================

==================================================
Software License Status: Authorized
==================================================

使用说明

OBET> help
OBET (Oracle Block Editor Tool) commands:
  open <config_file>    - Load file list from config file (format: <num> <path>)
  info                  - Show loaded file list (from open command)
  set filename <path>   - Set target file path (required)
  set file <num>        - Set filename using loaded file number (from open list)
  set blocksize <size>  - Set block size (2048,4096,[8192],16384,32768)
  set block <num>       - Set block number (starts from 0, default: 1)
  set offset <offset>   - Set offset within block (< blocksize, default: 0)
  set count <bytes>     - Set number of bytes to read (default: 32)
  set mode edit/browse  - Enable edit/browse mode
  d/dump [options]      - Display data (options: block X, offset Y, count N)
  m/modify <hex> [opts] - Modify data with hex (opts: block X, offset Y)
  undo                  - Undo last modification
  sum [block X]         - Calculate checksum for block (default: current block)
  sum apply [block X]   - Apply checksum: write calculated value to block
  tailchk [block X]     - Calculate tailchk for block (default: current block)
  tailchk apply [block X] - Apply tailchk: write calculated value to block
  copy <src> to <dest>  - Copy data between files
    <src> format: file,block,offset,count (e.g., 1,1,10,64)
    <dest> format: file[,block][,offset] (e.g., 3 or 3,1 or 3,1,128)
  corrupt [block X]     - Mark block as corrupted (default: current block)
  show                  - Display current settings (filename, blocksize, block, offset, count, mode)
  license               - Show/manage software license (registration code required)
  version               - Show software version and developer information
  help                  - Show this help message
  quit/exit             - Exit OBET

加载数据文件

--使用open打开数据文件列表(格式: 编号  路径)
OBET> open /tmp/3.txt
Loaded 4 files from config file '/tmp/3.txt'.

OBET> info

Loaded files (4 total):
----------------------------------------
Number  Path
----------------------------------------
     1  /u01/xifenfei/system01.dbf
     2  /u01/xifenfei/sysaux01.dbf
     3  /u01/xifenfei/undotbs01.dbf
     4  /u01/xifenfei/users01.dbf
----------------------------------------

OBET> set file 1
filename set to: /u01/xifenfei/system01.dbf (file#1)

--或者直接使用 set filename
OBET> set filename /tmp/system01.dbf
filename set to: /tmp/system01.dbf

进入数据文件特定位置

OBET> set file 2
filename set to: /u01/xifenfei/sysaux01.dbf (file#2)

OBET> set block 5
block set to: 5

OBET> set offset 128
offset set to: 128

16进制方式查看数据

OBET> d

File: /u01/xifenfei/system01.dbf
Block: 1                Offsets:     0 to    31
--------------------------------------------------------------------------------
00002000 0BA20000 01004000 00000000 00000104 224D0000 00000000 0004200B A2DB266A 

<32 bytes read>

OBET> dump block 521 offset 128

File: /u01/xifenfei/system01.dbf
Block: 521                Offsets:   128 to   159
--------------------------------------------------------------------------------
00412080 5E068D05 C6040000 00000000 00000000 00000000 00000000 00000000 00000000 

<32 bytes read>

OBET> set count 128
count set to: 128

OBET> d

File: /u01/xifenfei/system01.dbf
Block: 1                Offsets:     0 to   127
--------------------------------------------------------------------------------
00002000 0BA20000 01004000 00000000 00000104 224D0000 00000000 0004200B A2DB266A 
00002020 58494645 4E464549 AC020000 00720100 00200000 01000300 00000000 00000000 
00002040 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
00002060 08024000 07000000 00000000 7DC92131 64676345 06200E00 00000000 00000000 

<128 bytes read>

16进制方式修改数据块内容(一般修改数据块内容之后建议校验tailchk和sum)

OBET> d

File: /u01/xifenfei/system01.dbf
Block: 1                Offsets:     0 to   127
--------------------------------------------------------------------------------
00002000 0BA20000 01004000 00000000 00000104 224D0000 00000000 0004200B A2DB266A 
00002020 58494645 4E464549 AC020000 00720100 00200000 01000300 00000000 00000000 
00002040 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
00002060 08024000 07000000 00000000 7DC92131 64676345 06200E00 00000000 00000000 

<128 bytes read>

OBET> m 0123

Confirm modification:
File: /u01/xifenfei/system01.dbf
Block: 1
Offset: 0 (file offset: 0x00002000)
Original value: 0B
New value:      0123
Confirm? (Y/YES to proceed): y
Verification successful: Data written correctly.
Modified 2 bytes at offset 0x00002000 successfully.

OBET> d

File: /u01/xifenfei/system01.dbf
Block: 1                Offsets:     0 to   127
--------------------------------------------------------------------------------
00002000 01230000 01004000 00000000 00000104 224D0000 00000000 0004200B A2DB266A 
00002020 58494645 4E464549 AC020000 00720100 00200000 01000300 00000000 00000000 
00002040 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
00002060 08024000 07000000 00000000 7DC92131 64676345 06200E00 00000000 00000000 

<128 bytes read>

tail和checksum修改

OBET> tailchk
Check tailchk for File /u01/xifenfei/system01.dbf, Block 1:
current = 0x010B0000, required = 0x01010000

OBET> sum
Check value for File /u01/xifenfei/system01.dbf, Block 1:
current = 0x224D, required = 0x28CC

OBET> tailchk apply

Confirm applying tailchk:
File: /u01/xifenfei/system01.dbf
Block: 1
Offset in block: 8188 (file offset: 0x00003FFC)
Original value: 0x010B0000
New value:      0x01010000
Confirm? (Y/YES to proceed): y
Verification successful: Stored tailchk matches calculated value (0x01010000).
Tailchk applied successfully.

OBET> sum apply

Confirm applying checksum:
File: /u01/xifenfei/system01.dbf
Block: 1
Offset in block: 16 (file offset: 0x00002010)
Original value: 0x224D
New value:      0x28C6
Confirm? (Y/YES to proceed): y
Verification successful: Stored checksum matches calculated value (0x28C6).
Checksum applied successfully.

两个数据文件之前拷贝数据(一般copy数据之后建议校验tailchk和sum)
一般情况下文件之间的拷贝就是数据号不一样,比如修改checkpoint,resetlog信息等,这里支持不一样偏移量,不一样数据块的拷贝

OBET> copy 1,1,0,128 to 3,5,128

Confirm copy:
Source: file#1 (/u01/xifenfei/system01.dbf), block 1, offset 0, 128 bytes
Target: file#3 (/u01/xifenfei/undotbs01.dbf), block 5, offset 128
Proceed? (Y/YES to confirm): y
Copy successful: 128 bytes copied from file #1 to file #3.

OBET> set file 3
filename set to: /u01/xifenfei/undotbs01.dbf (file#3)

OBET> d block 5 offset 128

File: /u01/xifenfei/undotbs01.dbf
Block: 5                Offsets:   128 to   255
--------------------------------------------------------------------------------
0000A080 0BA20000 01004000 00000000 00000104 224D0000 00000000 0004200B A2DB266A 
0000A0A0 58494645 4E464549 AC020000 00720100 00200000 01000300 00000000 00000000 
0000A0C0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
0000A0E0 08024000 07000000 00000000 7DC92131 64676345 06200E00 00000000 00000000 

<128 bytes read>

OBET> set file 1
filename set to: /u01/xifenfei/system01.dbf (file#1)

OBET> dump block 1 offset 0

File: /u01/xifenfei/system01.dbf
Block: 1                Offsets:     0 to   127
--------------------------------------------------------------------------------
00002000 0BA20000 01004000 00000000 00000104 224D0000 00000000 0004200B A2DB266A 
00002020 58494645 4E464549 AC020000 00720100 00200000 01000300 00000000 00000000 
00002040 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
00002060 08024000 07000000 00000000 7DC92131 64676345 06200E00 00000000 00000000 

<128 bytes read>

标记数据块为坏块功能


OBET> show 

Current settings:
File: /u01/xifenfei/system01.dbf
Blocksize: 8192 bytes
Block: 1
Offset in block: 0 (file offset: 0x00002000)
Count: 128 bytes
Mode: edit
Loaded files: 4 (use 'info' to list)

OBET> corrupt

Confirm modification:
File: /u01/xifenfei/system01.dbf
Block: 1
Offset: 14 (file offset: 0x0000200E)
Original value: 01
New value:      FF
Are you sure to set this block corrupted? (Y/YES to proceed): y
Verification successful: Block 1 marked as corrupted (offset 14 set to 0xFF).
Modification successful.

由于该工具直接编辑Oracle 底层数据块操作具有一定的破坏性和风险性,所以在没有授权的情况下无法对数据块进行修改(只能查看),具体授权操作

OBET> license

========================================
           Software Registration        
========================================

Your Hardware ID: XXXXXXXX  ----->提供给我

Please send your Hardware ID to XiFenFei to register.
Website: https://www.xifenfei.com 
Tel/WX: +86-17813235971 

Enter Registration Code: XXXXXX-XXXXXXXX <-----输入注册码进行授权
Registration successful!