Automate SQL server restart in a clustered environment

  • All,

    I need to automate SQL server restart(daily due to performance issue- outside sql) in a clustered environment. What is the best way to accomplish this. If anyone can provide code/commands that would be great!

    Environment:

    Windows server 2008

    Sql 2005 - 2 node (active/passive)

    Many thanks in advance!

  • I recommend you investigate the reasons behind your performance issue before implementing this workaround. If you must do it, you can control the cluster from a command line - see this. I'm sure there are equivalent PowerShell commands as well, if you prefer that.

    John

  • John: Thanks for your input!

  • If you really need to restart your SQL Server clustered instance, you need to use the cluster commands to put the SQL cluster group offline, then put it back online.

    If you just stop SQL Server using a NET STOP command you may cause a failover to happen.

    But John has good advice - you should find out why you think you need to restart SQL Server. The problem can almost certainly be solved without the need to restart SQL Server.

    Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.

    When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara

  • John Mitchell-245523 (8/18/2014)


    I recommend you investigate the reasons behind your performance issue before implementing this workaround. If you must do it, you can control the cluster from a command line - see this. I'm sure there are equivalent PowerShell commands as well, if you prefer that.

    John

    Since this is Windows 2008, the cluster.exe documentation is useless. The Powershell commands are

    To import the Failovercluster Powershell module

    import-module failoverclusters

    List cluster groups

    get-clustergroup

    Stop a cluster group

    stop-clustergroup "groupname"

    Start a cluster group

    start-clustergroup "groupname"

    Rather than stopping the whole group just stop the SQL Server resource (takes the agent down too)

    Get the resources using

    get-clusterresource | ?{$_.resourcetype -match "SQL Server"}

    Stop the sql server resource using

    stop-clusterresource "sql server resource name"

    Start SQL server resource by starting the agent first

    start-clusterresource "sql agent resource name"

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Thanks Perry!

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply