MySQL Server 查询缓存命中百分比监视器

Microsoft.MySQLServer.ManagedServer.Unix.QueryCacheHitPct.Monitor (UnitMonitor)

Knowledge Base article:

摘要

通过查询缓存满足的查询的百分比。查询缓存用于存储 select 语句的内容以及相应的结果,这些结果将在插入、更新或删除语句后失效。查询缓存大小由全局变量 "query_cache_size" 控制。可插入查询缓存中的查询的大小由全局变量 "query_cache_limit" 控制。此监视器阈值是按照轮询过程中返回给代理的平均值分析的,其中“样本数”参数控制平均值计算中所包含的样本数。

原因

运行不正常状态表示通过查询缓存满足的查询百分比低。查询缓存可能没有足够的存储空间来存储最近使用的查询。插入、更新和删除语句使用过于频繁将导致清除查询缓存。

解决方案

要解决查询缓存命中百分比低的问题,可增大 query_cache_size 以允许存储更多查询。如果大多数查询超过这一限值,则增大 query_cache_limit 将允许查询缓存中存储更大查询。这两个变量均可进行修改,方法是在配置文件中的实例组下添加各自的变量名称,后跟大小。

配置

默认配置

参数

默认值

警告阈值

小于 90

错误阈值

小于 80

样本数

3

替代可用于更改以上为所有实例或为特定实例或组定义的参数值。

Element properties:

TargetMicrosoft.MySQLServer.ManagedServer.Unix
Parent MonitorMicrosoft.MySQLServer.QueryCachePerformanceRollup
CategoryPerformanceHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.Oss.WSManEnumeration.LessThanThreshold.ThreeState.MonitorType
RemotableTrue
AccessibilityPublic
Alert Message
MySQL Server 查询缓存命中百分比
MySQL Server 的当前查询缓存命中百分比 ({0}\%) 低
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.MySQLServer.ManagedServer.Unix.QueryCacheHitPct.Monitor" Accessibility="Public" Target="Microsoft.MySQLServer.ManagedServer.Unix" TypeID="Oss!Microsoft.Oss.WSManEnumeration.LessThanThreshold.ThreeState.MonitorType" Enabled="onStandardMonitoring" ParentMonitorID="Microsoft.MySQLServer.QueryCachePerformanceRollup">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.MySQLServer.ManagedServer.Unix.QueryCacheHitPct.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Value$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState HealthState="Success" MonitorTypeStateID="StatusOK" ID="OverThreshold"/>
<OperationalState HealthState="Warning" MonitorTypeStateID="StatusWarning" ID="UnderWarningThreshold"/>
<OperationalState HealthState="Error" MonitorTypeStateID="StatusError" ID="UnderErrorThreshold"/>
</OperationalStates>
<Configuration>
<Interval>300</Interval>
<TargetSystem>$Target/Host/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$</TargetSystem>
<Uri>http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/MySQL_ServerStatistics?__cimnamespace=root/mysql</Uri>
<WSManFilter/>
<ObjectName>MySQL Server</ObjectName>
<CounterName>Query Cache Hit Pct</CounterName>
<InstanceXPath>/DataItem/WsManData/*[local-name(.)='MySQL_ServerStatistics']/*[local-name(.)='InstanceID']</InstanceXPath>
<InstanceName>$Target/Property[Type="Microsoft.MySQLServer.Installation"]/InstanceID$</InstanceName>
<Value>$Data/WsManData/*[local-name(.)='MySQL_ServerStatistics']/*[local-name(.)='QCacheHitPct']$</Value>
<WarningThreshold>90</WarningThreshold>
<ErrorThreshold>80</ErrorThreshold>
<NumSamples>3</NumSamples>
</Configuration>
</UnitMonitor>