Quantcast
Channel: Welcome To TechBrothersIT
Viewing all articles
Browse latest Browse all 1878

DBA Posts - How to monitor SQL Server Cluster failover as well as current active node?

$
0
0

Cluster Failover Notification Process


This process explains step by step process of monitoring cluster failover of SQL Server.
Basic Idea behind this process is to find active node (where sql server resources are running currently)
High Level steps:

1- create a table to keep track of current active node

2- create a sql agent job that will read data from above table

3- send an email notification as soon as the value in tracking table changes

Detail Process Steps:

createtable ActiveNodeTracker
(
PriorActiveNode varchar(50)
)

insertinto ActiveNodeTracker
values('ActiveNodeName')

Declare @Nodevar1 varchar(50)
SELECT @Nodevar1= PriorActiveNode FROMActiveNodeTracker

CREATETABLE HOSTNAME
(
VALUE VARCHAR(50),
PresentActiveNode VARCHAR(50)

)
INSERTINTO HOSTNAME
EXEC master..xp_regread'HKEY_LOCAL_Machine',

'SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\','PhysicalName'
declare @nodevar2 varchar(50)
SELECT @Nodevar2=PresentActiveNode FROMHOSTNAME

IF @Nodevar1<>@Nodevar2
Begin
EXEC msdb..sp_send_dbmail@profile_name='DBAdmin',

@recipients='email@orgnization.com',--Please replace with your org domain emails
@subject='Failover Alert',
@body='Cluster Failover Notification, please see Prior and present Active Nodes',
@QUERY='SET NOCOUNT ON;
SELECT PriorActiveNode FROM ActiveNodeTracker;
SELECT PresentActiveNode FROM HOSTNAME;
SET NOCOUNT OFF'
UPDATEActiveNodeTracker SET PriorActiveNode=@nodevar2
END
DROPTABLE HOSTNAME


Viewing all articles
Browse latest Browse all 1878

Trending Articles