解决 SQLLocalDB 中的模型数据库损坏问题

本文介绍 SQLLocalDB 实用工具 中由于数据库损坏 Model 而阻止 ADSync 服务启动的已知问题。 此问题主要影响连接 2 Microsoft Entra。在 Microsoft SQL Server 2019 LocalDB 上运行的 x 服务器。

此问题是由SQL Server备份逻辑中的 bug 引起的,该错误在 SQL Server Model 数据库起始页中创建不一致的状态。 备份发生后, Model 数据库将设置为 FULL 恢复模式 (dbi_status == 0x40010000) , (dbi_dbbackupLSN 数据库备份) 的日志序列号 (LSN) 设置为指向日志文件的值。 但是,由 Master 数据库管理的实际恢复模式是 SIMPLE

SIMPLE 恢复模式下,数据库日志会自动截断。 在 FULL 恢复模式下,日志仅在备份后被截断。 在日志文件被截断后重启 SQLLocalDB 时,它会检测到早于最早日志文件的备份 LSN。 因此,它不会启动服务。

查看后续部分中的指南,了解如何执行以下任务:

  • 正确标识 Microsoft Entra Connect 服务 (ADSync) 是否由于Model数据库损坏而无法启动。

  • 通过从损坏状态恢复 Model 数据库来缓解此问题。

  • 应用永久修复,确保不再发生此 Model 数据库损坏。

症状

可以验证问题是否基于 Microsoft Entra Connect 服务器中的以下事件:

  • 事件查看器:Application,EventID 528,源:SQLLocalDB 15.0

    WaitForMultipleObjects
    575
    {Application Error}
    The application was unable to start correctly (0x%lx). Click OK to close the application.
    3714
    
  • 事件查看器:Application、EventIDs 2005 和 6226,源:ADSync

    0x8023044a
    OriginalError=0x80004005 OLEDB Provider error(s):
    Description  = 'Login timeout expired'
    Failure Code = 0x80004005 
    
  • ADSync 服务配置文件路径>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\ADSync2019 中的< SQLLocalDB error.log文件

    <yyyy-MM-dd HH:mm:ss.##> spid14s     The resource database build version is 15.00.4138. This is an informational message only. No user action is required.
    <yyyy-MM-dd HH:mm:ss.##> spid8s      Starting up database 'msdb'.
    <yyyy-MM-dd HH:mm:ss.##> spid14s     Starting up database 'model'.
    <yyyy-MM-dd HH:mm:ss.##> spid14s     Error: 9003, Severity: 20, State: 1.
    <yyyy-MM-dd HH:mm:ss.##> spid14s     The log scan number (41:488:1) passed to log scan in database 'model' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.
    <yyyy-MM-dd HH:mm:ss.##> spid14s     SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
    

缓解

重要

仅当出现以下所有情况时,才应用此处所述的缓解步骤:

  • Microsoft Entra Connect 的版本为 2.0。x.x

  • Microsoft Entra Connect 随 SQL LocalDB 一起安装。

  • 存在症状中列出的所有条件。

若要从损坏状态恢复 Model 数据库,请执行以下步骤:

  1. 转到以下 ADSync 服务配置文件位置之一,具体取决于运行 (的服务帐户,例如域帐户、虚拟服务帐户或托管服务帐户) :

    • C:\Users\<service account>\
    • C:\Users\ADSyncMSAxxxx$\
    • C:\Windows\ServiceProfiles\ADSync\
  2. 在以下目录路径中打开 ADSync2019 实例文件夹中的 error.log 文件:

    <服务配置文件路径>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\ADSync2019\

  3. 在日志中找到以下错误条目,验证 Model 数据库是否已损坏:

    <yyyy-MM-dd HH:mm:ss.##> spid14s     Error: 9003, Severity: 20, State: 1.
    <yyyy-MM-dd HH:mm:ss.##> spid14s     The log scan number (41:488:1) passed to log scan in database 'model' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.   
    
  4. 如果此条目中存在错误“9003”,请将此文件夹中 的 model.mdfmodellog.ldf 文件分别重命名为 old_model.mdfold_modellog.ldf

  5. C:\Program Files\Microsoft SQL Server\150\LocalDB\Binn\Templates 处打开 SQL 模板文件夹。

  6. model.mdfmodellog.ldf 文件复制到步骤 2 中的 ADSync2019 实例文件夹。

  7. 启动 ADSync 服务。

解决方案

Microsoft 已在 Microsoft Entra Connect 版本 2.1.1.0 中引入了此问题的修补程序。 如果无法启动同步服务 (ADSync) ,则需要先应用“缓解”部分中的步骤,然后才能升级Microsoft Entra Connect。

若要防止 SQLLocalDB Model 数据库中出现损坏问题,请安装最新的 Microsoft Entra Connect 内部版本,该版本在 Microsoft Entra Connect: 版本发布历史记录中提供。

联系我们寻求帮助

如果你有任何疑问或需要帮助,请创建支持请求联系 Azure 社区支持。 还可以向 Azure 反馈社区提交产品反馈。