解決 SQLLocalDB 中的模型資料庫損毀

本文說明 SQLLocalDB 公用程式 中的已知問題,可防止 ADSync 服務因為資料庫損毀 Model 而啟動。 此問題主要影響 connect 2 Microsoft Entra。在 Microsoft SQL Server 2019 LocalDB 上執行的 x 伺服器。

此問題是由 SQL Server 備份邏輯中的錯誤所造成,該錯誤會在 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 伺服器中的下列事件來確認問題:

  • 事件檢視器:應用程式、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
    
  • 事件檢視器:應用程式、EventID 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. 從步驟 2 將 model.mdfmodellog.ldf 檔案複製到 ADSync2019 實例資料夾。

  7. 啟動ADSync服務。

解決方案

Microsoft 已在 Microsoft Entra Connect 2.1.1.0 版中引進此問題的修正程式。 如果無法啟動 ADSync) (同步處理服務,您必須先套用風險降低一節中的步驟,才能升級 Microsoft Entra Connect。

若要防止 SQLLocalDB Model 資料庫中的損毀問題,請安裝最新的 Microsoft Entra Connect 組建,其可在 Microsoft Entra Connect: 版本發行歷程記錄中取得。

與我們連絡,以取得說明

如果您有問題或需要相關協助,請建立支援要求,或詢問 Azure community 支援。 您也可以將產品意見反應提交給 Azure 意應見反社群