自動關閉組態

Microsoft.SQLServer.2014.Database.Configuration.AutoClose (UnitMonitor)

監視資料庫的 [自動關閉] 設定。附註: 預設會停用此監視器。必要時請使用覆寫加以啟用。

Knowledge Base article:

摘要

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

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

資料庫鏡像需要 AUTO_CLOSE OFF。

只有當您確定應用程式使用模式將使資料庫保持關閉相當長一段時間時,Autoclose 才有意義。主控狀況的一些單一使用者應用程式和多重租賃資料庫,可能從 AUTO_CLOSE ON 獲益。如果是所有其他使用方式,則通常不適用,除非您真的了解應用程式和使用模式。

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

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

組態

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

AUTO_CLOSE {ON | OFF}

原因

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

解決方式

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

或者,如果此監視與這個資料庫無關::

可覆寫的參數

名稱

描述

預設值

已啟用

 

停用 SQL Express 檢查

這只能設為 'true' 或 'false'。如果設為 'true',工作流程就不會考慮 SQL Server Express 版本。

1

預期的值

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

關閉

產生警示

 

間隔 (秒)

執行工作流程的週期性時間間隔 (秒)。

43200

逾時 (秒)

指定允許工作流程在關閉且標示為失敗之前執行的時間。

300

Element properties:

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

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2014.Database.Configuration.AutoClose" Accessibility="Public" Enabled="false" Target="SQL2014Core!Microsoft.SQLServer.2014.Database" ParentMonitorID="Microsoft.SQLServer.2014.Database.AutomaticConfiguration" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2014.DBConfigurationStatus" ConfirmDelivery="false">
<Category>ConfigurationHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2014.Database.Configuration.AutoClose.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.Database"]/DatabaseName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.ServerRole"]/InstanceName$</AlertParameter2>
<AlertParameter3>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="ConfigurationValueOK" MonitorTypeStateID="ConfigurationValueOK" HealthState="Success"/>
<OperationalState ID="ConfigurationValueNotOK" MonitorTypeStateID="ConfigurationValueNotOK" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<ConnectionString>$Target/Host/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.DBEngine"]/ConnectionString$</ConnectionString>
<DatabaseName>$Target/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.Database"]/DatabaseName$</DatabaseName>
<IntervalSeconds>43200</IntervalSeconds>
<SyncTime/>
<ConfigValue>AutoClose</ConfigValue>
<ExpectedValue>OFF</ExpectedValue>
<ExcludeOnExpress>true</ExcludeOnExpress>
<SQLSKU>$Target/Host/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.DBEngine"]/Edition$</SQLSKU>
<TimeoutSeconds>300</TimeoutSeconds>
</Configuration>
</UnitMonitor>