Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Automate SQL server restart in a clustered environment


Automate SQL server restart in a clustered environment

Author
Message
SQL!$@w$0ME
SQL!$@w$0ME
Old Hand
Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)

Group: General Forum Members
Points: 378 Visits: 1188
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!
John Mitchell-245523
John Mitchell-245523
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7361 Visits: 15079
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
SQL!$@w$0ME
SQL!$@w$0ME
Old Hand
Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)

Group: General Forum Members
Points: 378 Visits: 1188
John: Thanks for your input!
EdVassie
EdVassie
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3144 Visits: 3815
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: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005. 1 Dec 2016: now over 39,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Quote: "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
Perry Whittle
Perry Whittle
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8779 Visits: 16548
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" ;-)
SQL!$@w$0ME
SQL!$@w$0ME
Old Hand
Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)Old Hand (378 reputation)

Group: General Forum Members
Points: 378 Visits: 1188
Thanks Perry!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search