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小时做事务日志备份,备份类似这样的情况


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


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

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 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 |

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


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


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

相关推荐
2401_8323655211 小时前
JavaScript中rest参数(...args)取代arguments的优势
jvm·数据库·python
2301_7796224111 小时前
Go语言怎么用信号量控制并发_Go语言semaphore信号量教程【入门】
jvm·数据库·python
2301_7662834412 小时前
c++如何将控制台输出保存到文件_cout重定向到txt【详解】
jvm·数据库·python
北极的冰箱12 小时前
MySQL Ver 8.0.41 for macos14.7密码遗忘
数据库·mysql
XDH_CS12 小时前
MySQL 8.0 安装与 MySQL Workbench 使用全流程(超详细教程)
开发语言·数据库·mysql
里欧跑得慢13 小时前
17. Flutter Hero动画实现:让界面过渡更加优雅
前端·css·flutter·web
treacle田13 小时前
达梦数据库-统计信息收集-记录
数据库·达梦数据库统计信息收集
IT_陈寒13 小时前
Vue的这个响应式陷阱,我debug了一整天才爬出来
前端·人工智能·后端
kyriewen13 小时前
前端测试:别为了100%覆盖率而写测试,那是自欺欺人
前端·javascript·单元测试
去伪存真13 小时前
我自己写的第一个skills--project-core-standards
前端·agent