Zabbix的監控出現告警,具體的告警信息以下:「SQL Instance MSSQLSERVER: Could not allocate a new page」和「D::Disk space is low(used > 80%)"數據庫
第一個告警是Zabbix template for Microsoft SQL Server模板發出的告警,查看其具體信息,能夠看到以下具體信息:服務器
Msg 1101 or 1105 was logged in the Windows Application Event Log. These errors indicate that SQL server could not allocate a new page for database because of insufficient disk space in filegroup. Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting Autogrowth on for existing files in the filegroup.app
簡單一點說,就是由於服務器因爲磁盤空間不足或數據庫文件限制了最大大小,致使SQL Server沒法爲數據庫分配新的頁面,請檢查磁盤空間是否足夠或給數據庫文件設置自動增加。ide
可是其不能明確的提示是那個數據庫出現問題,雖然結合磁盤空間告警,咱們已經可以猜想是tempdb出現了問題,另外,SQL Server Alert也發出了告警郵件,具體信息以下,這個告警就能明確是那個數據庫出現問題了:spa
DATE/TIME: 2020/11/11 9:35:343d
DESCRIPTION: Could not allocate space for object '<temporary system object: 1225067284549599232>' in database 'tempdb' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.code
其實綜合上面信息,就是由於一些問題SQL,在短期內消耗了數據庫tempdb大量的空間,致使tempdb數據庫大小短期內迅猛增加,咱們這臺服務器的tempdb數據庫(單獨放置在D盤),雖然設置了自動增加,可是咱們設置了tempdb單個數據文件的MaxSize爲10GB, 其總大小爲80GB,可是這個仍然不能知足問題SQL的需求,不能分配新的頁面,因此出現了上面告警。 orm
USE [tempdb]
GO
SELECT @@SERVERNAME AS [ServerName]
,[name] AS [LogicalName]
,[type_desc] AS [TypeDesc]
,[physical_name] AS [PhysicalName]
,CONVERT(NUMERIC(10,2),ROUND([size]/128.,2)) AS [Size(MB)]
,CONVERT(NUMERIC(10,2),ROUND(FILEPROPERTY([name],'SpaceUsed')/128.,2)) AS [Used(MB)]
,CONVERT(NUMERIC(10,2),ROUND(([size]-FILEPROPERTY([name],'SpaceUsed'))/128.,2)) AS [Unused(MB)]
,CASE WHEN is_percent_growth = 1
THEN RTRIM(CAST(Growth AS CHAR(10))) + '%'
ELSE RTRIM(CAST(Growth*8.0/1024 AS CHAR(18))) + 'M'
END AS [Growth(MB)]
,CASE WHEN max_size = -1 THEN 'Unlimit'
ELSE CAST(CAST(max_size * CONVERT(FLOAT, 8)/1024/1024 AS NUMERIC(10,2)) AS VARCHAR(32))
END AS [MaxSize(GB)]
,is_media_read_only AS [IsReadOnlyMedia]
,is_read_only AS [IsReadOnly]
,CAST(CASE state
WHEN 6 THEN 1
ELSE 0
END AS BIT) AS [IsOffline]
,is_sparse AS [IsSparse]
FROM [sys].[database_files]
ORDER BY name;
另外,咱們經過zabbix監控的磁盤D的空間消耗狀況以下。能夠看到其在短期內被消耗殆盡。server
雖然Zabbix比較擅長監控,可是它沒法定位問題SQL,這個須要經過做業或擴展事件監控來捕獲問題SQL語句。這篇不打算展開介紹,後面單獨一篇講述如何捕獲這些問題SQL語句!blog