自動關閉組態

Microsoft.SQLServer.Linux.Monitor.Database.AutoCloseConfiguration (UnitMonitor)

監視 Linux 上資料庫的 [自動關閉] 設定。注意: 根據預設會停用此監視器。如有需要,請使用覆寫加以啟用。

Knowledge Base article:

摘要

此監視器會檢查此資料庫的 [自動關閉] 設定。因為此監視器是整體標準需求的一部分,所以若設定不符合指定的標準,就會產生警示。

對於桌面資料庫而言,AUTO_CLOSE 選項非常有用,因為它可讓您將資料庫檔案當做一般檔案來管理。您可以移動它們、複製它們來建立備份,甚至可以用電子郵件將它們傳給其他使用者。然而,當資料庫設為 AUTOCLOSE = ON 時,起始自動資料庫關閉的作業會清除 SQL Server 執行個體的計畫快取。清除計畫快取會導致重新編譯所有後續執行計畫,而且可能會造成查詢效能突然暫時下降。

資料庫鏡像需要 AUTO_CLOSE OFF。

只有當您確定應用程式使用模式將使資料庫保持關閉相當長一段時間時,自動關閉才有意義。某些單一使用者應用程式與多重租用戶資料庫的裝載狀況,可能非常適用於 AUTO_CLOSE ON。對於其他所有使用方式,則除非您真的了解應用程式行為以及使用模式,否則通常不適用

  • 線上叢書中的設計/實作注意事項

  • 若未啟動資料庫,Microsoft SQL Server 透過直接存取資料庫 (而非從中繼資料擷取值) 所擷取的屬性會傳回 NULL。也就是說,若資料庫的 AUTO_CLOSE 設成 ON,否則資料庫會離線。

設定

當 [自動關閉] 設定為 ON 時,資料庫會在最後一個使用者結束之後完全關機並釋放其資源。

AUTO_CLOSE {ON | OFF}

原因

若 [自動關閉] 選項與必要設定不符,將會引發警告警示。根據預設,此監視器設定為當此設定設為 “ON” 時,要產生警示。

解決方式

請按照下列方式解決此問題:

若此監視器與此資料庫無關:

可覆寫的參數

名稱

描述

預設值

警示優先順序

定義警示優先順序。

標準

警示嚴重性

定義警示嚴重性。

警告

已啟用

啟用或停用該工作流程。

預期值

資料庫組態設定需要的值。若要檢視一組適用的值,請參閱此監視的知識庫之<組態>一節。

關閉

產生警示

定義工作流程是否要產生警示。

間隔 (秒)

每次重複執行工作流程之間的時間間隔 (秒)。

43200

同步處理時間

同步處理時間使用 24 小時制。可予省略。

 

逾時 (秒)

指定流程被關閉及標示為失敗之前,允許執行的時間。

300

資料庫連線的逾時 (秒)

若工作流程無法在指定的期限之內存取資料庫,將會失敗並登錄一則事件。

15

Element properties:

TargetMicrosoft.SQLServer.Linux.Database
Parent MonitorMicrosoft.SQLServer.Linux.Rollup.Database.AutomaticConfiguration
CategoryConfigurationHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.Linux.MonitorType.Database.DBConfigurationStatus
RemotableTrue
AccessibilityPublic
Alert Message
Linux 上的 MSSQL: 自動關閉設定錯誤
電腦 "{2}" 上 SQL 執行個體 "{1}" 中資料庫 "{0}" 的 [自動關閉] 設定未依照最佳做法設定。
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.Linux.Monitor.Database.AutoCloseConfiguration" Accessibility="Public" Enabled="false" Target="SqlDiscL!Microsoft.SQLServer.Linux.Database" ParentMonitorID="Microsoft.SQLServer.Linux.Rollup.Database.AutomaticConfiguration" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.Linux.MonitorType.Database.DBConfigurationStatus" ConfirmDelivery="false">
<Category>ConfigurationHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.Linux.Monitor.Database.AutoCloseConfiguration.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/MachineName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/InstanceName$</AlertParameter2>
<AlertParameter3>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.Database"]/DatabaseName$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="ConfigurationValueOK" MonitorTypeStateID="ConfigurationValueOK" HealthState="Success"/>
<OperationalState ID="ConfigurationValueNotOK" MonitorTypeStateID="ConfigurationValueNotOK" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<MachineName>$Target/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/MachineName$</MachineName>
<NetbiosComputerName>$Target/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/NetbiosComputerName$</NetbiosComputerName>
<InstanceName>$Target/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/InstanceName$</InstanceName>
<DatabaseName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.Database"]/DatabaseName$</DatabaseName>
<ConfigName>AutoClose</ConfigName>
<ExpectedValue>OFF</ExpectedValue>
<ConnectionString>$Target/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/ConnectionString$</ConnectionString>
<InstanceVersion>$Target/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/Version$</InstanceVersion>
<InstanceEdition>$Target/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/Edition$</InstanceEdition>
<SqlTimeoutSeconds>15</SqlTimeoutSeconds>
<TimeoutSeconds>300</TimeoutSeconds>
<IntervalSeconds>43200</IntervalSeconds>
<SyncTime/>
</Configuration>
</UnitMonitor>