데이터베이스 미러링 파트너 상태

Microsoft.SQLServer.2012.Mirroring.PartnersStateMonitor (UnitMonitor)

이 모니터는 데이터베이스 미러링이 동기화되었는지 확인합니다.

Knowledge Base article:

요약

이 모니터는 Microsoft® SQL Server™가 보고한 데이터베이스 미러링 세션의 상태를 확인합니다. 이 작업은 SQL Server 인스턴스의 master 데이터베이스에 대해 쿼리를 실행하고 데이터베이스 미러링 세션의 상태를 반환하여 수행됩니다. 이 모니터에서 경고가 수신되면 데이터베이스 미러링 세션을 작동 상태로 되돌리기 위한 동작이 필요합니다.

원인

비정상 상태는 SQL Server™ 데이터베이스 미러링 세션이 작동 상태가 아님을 나타냅니다. 가능한 상태에 대한 자세한 설명은 다음과 같습니다.:

미러링 파트너 상태

설명

MOM 상태

IN_SYNC

정상적인 작동 상태입니다. 미러링 파트너가 동기화되고 미러링이 정상적으로 수행되고 있습니다.

녹색

OUT_OF_SYNC

미러링 파트너가 동기화되지 않았습니다.

빨강

해결 방법

문제를 해결하려면 다음 방법을 시도하십시오.:

Element properties:

TargetMicrosoft.SQLServer.2012.Mirroring.Witness
Parent MonitorSystem.Health.AvailabilityState
CategoryAvailabilityHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityError
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2012.Mirroring.ScriptedTwoStateType
RemotableTrue
AccessibilityPublic
Alert Message
데이터베이스 미러링 파트너가 동기화되지 않음
데이터베이스 미러링 '{0}'이(가) 동기화되지 않았습니다. 미러링 파트너는 '{1}' 및 '{2}'입니다.
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2012.Mirroring.PartnersStateMonitor" Accessibility="Public" Enabled="true" Target="SQL2012Mirroring!Microsoft.SQLServer.2012.Mirroring.Witness" ParentMonitorID="Health!System.Health.AvailabilityState" TypeID="Microsoft.SQLServer.2012.Mirroring.ScriptedTwoStateType" Remotable="true" Priority="Normal" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2012.Mirroring.PartnersStateMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL2012Mirroring!Microsoft.SQLServer.2012.Mirroring.Witness"]/DatabaseName$</AlertParameter1>
<AlertParameter2>$Target/Property[Type="SQL2012Mirroring!Microsoft.SQLServer.2012.Mirroring.Witness"]/Principal$</AlertParameter2>
<AlertParameter3>$Target/Property[Type="SQL2012Mirroring!Microsoft.SQLServer.2012.Mirroring.Witness"]/Mirror$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Good" MonitorTypeStateID="Good" HealthState="Success"/>
<OperationalState ID="Bad" MonitorTypeStateID="Bad" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ScriptName>GetSQL2012MirroringPartnersState.vbs</ScriptName>
<ScriptBody><Script>'#Include File:GetSQL2008MirroringPartnersState.vbs
'Copyright (c) Microsoft Corporation. All rights reserved.
' This script takes a single parameter
' Param 0: The SQL connection string to connect to

Const SQL_MONITORING_CONNECT_FAILURE = -1
Const SQL_MONITORING_QUERY_FAILURE = -2
Const SQL_MONITORING_SUCCESS = 0

Dim GetPartnersStatusQuery
GetPartnersStatusQuery = "SELECT " &amp;_
" mirroring_guid, " &amp;_
" partner_sync_state_desc " &amp;_
" FROM sys.database_mirroring_witnesses "

Call GetPartnersStatus()

Sub GetPartnersStatus()
If WScript.Arguments.Count = 4 Then
Dim oBag
Set oBag = oAPI.CreatePropertyBag()
Dim nResult
nResult = PartnersStatus(WScript.Arguments(0), oBag, WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3))
Call oAPI.Return(oBag)
Else
Wscript.Quit()
End If
End Sub

Function PartnersStatus(ByVal sSQLConnectionString, ByRef oBag, ByVal sComputerName, ByVal sInstanceName, ByVal sTcpPort)
Dim e
Set e = New Error

Dim cnADOConnection
Set cnADOConnection = SmartConnectWithoutSQLADODB(sSQLConnectionString, sTcpPort, sComputerName, sInstanceName, "master")
if cnADOConnection Is Nothing Then
PartnersStatus = SQL_MONITORING_CONNECT_FAILURE
ThrowScriptErrorNoAbort "Cannot connect to '" &amp; sSQLConnectionString &amp; "' SQL Server", e
Exit Function
End If

Dim oResults
e.Clear
On Error Resume Next
Set oResults = cnADOConnection.Execute(GetPartnersStatusQuery)
e.Save
On Error Goto 0
If e.Number &lt;&gt; 0 Then
PartnersStatus = SQL_MONITORING_QUERY_FAILURE
ThrowScriptErrorNoAbort "Query execution failed for '" &amp; sSQLConnectionString &amp; "' SQL Server", e
If (oResults &lt;&gt; null) Then oResults.Close
cnADOConnection.Close
Exit Function
End If

Do While Not oResults.EOF
Call oBag.AddValue(oResults(0), CStr(oResults(1)))
oResults.MoveNext
Loop

cnADOConnection.Close
PartnersStatus = SQL_MONITORING_SUCCESS
End Function
</Script></ScriptBody>
<IntervalSeconds>900</IntervalSeconds>
<SyncTime/>
<TimeoutSeconds>300</TimeoutSeconds>
<ConnectionString>$Target/Host/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ConnectionString$</ConnectionString>
<GoodExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='$Target/Property[Type="SQL2012Mirroring!Microsoft.SQLServer.2012.Mirroring.Witness"]/MirroringGUID$']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">IN_SYNC</Value>
</ValueExpression>
</SimpleExpression>
</GoodExpression>
<BadExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='$Target/Property[Type="SQL2012Mirroring!Microsoft.SQLServer.2012.Mirroring.Witness"]/MirroringGUID$']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">OUT_OF_SYNC</Value>
</ValueExpression>
</SimpleExpression>
</BadExpression>
</Configuration>
</UnitMonitor>