Setting up a reboot cycle for Active/Passive Cluster SQL Server

Thursday Jan 13th 2005 by Muthusamy Anantha Kumar aka The MAK

MAK explains how to reboot cluster nodes and switch the active and passive modes on a weekly basis.

Most organizations have a system of weekly reboots or monthly reboots etc., for all their servers. When it comes to clustered servers, the reboot cycle would be little different. Usually the active node in the cluster will always be active, unless there is a failover initiated manually or when there is a hardware failure etc.

In this article, I am going to explain how to reboot cluster nodes.

We are going to discuss how to reboot the active nodes every Saturday at 1 AM. In addition, we will discuss how to make the current active node a passive node every week so that the same physical server will not be the active node every week.

Let's assume we have a Cluster server VCLUSTER with nodes SQLNode1 and SQLNode2. Let's also assume that the virtual server name for the SQL Server cluster is SQLClusterA. Refer Fig 1.0

Click for larger image

Fig 1.0

We are going to take advantage of the command SHUTDOWN, the MS-DOS command FOR and the Windows Scheduler to handle the reboot of the cluster nodes. This will make SQLNode2 the active node and SQLNode1 the passive node on the first week and make SQLNode1 the active node and SQLNode2 the passive node the following week and so on.

Step 1

Create Folder C:\reboot as shown in Fig 1.1.

Fig 1.1

Step 2

Create file C:\reboot\Clusternodes.txt as shown below in Fig 1.2.

Make sure your active node is listed first and the passive node is listed second, separated by a comma.


Fig 1.2

Step 3

Create C:\reboot\preparereboot.bat as shown below in Fig 1.3.

REM Objective: Prepare rebooting of cluster nodes
REM Created By: MAK
REM Created date: Jan 10, 2004

for /f "tokens=1,2,3 delims=,"
  %%i in (C:\reboot\clusternodes.txt) do c:\reboot\rebootserver.bat %%i %%j

Download preparereboot.bat_

Fig 1.3

Step 4

Create C:\reboot\rebootserver.bat as shown in Fig 1.4.

REM Objective: To reboot the active node of the cluster every week
REM Created by: MAK
REM COntact:
REM Created Date: Jan 10, 2004
shutdown /m \\%1 /r /f /c "Weekly reboot cycle for %1" /t 60
Echo %2,%1 > c:\reboot\clusternodes.txt

Download rebootserver.bat_.

Fig 1.4

Step 5

Create a Windows schedule to execute C:\reboot\preparereboot.bat as shown below.

a. Open Control panel. Refer to Fig 1.4.

Fig 1.4

b. Select prepareboot.bat as the program to schedule. Refer to Fig 1.5.

Fig 1.5

c. Select Weekly Schedule. Refer to Fig 1.6.

Fig 1.6

d. Change time to 1 AM. Refer to Fig 1.7.

Fig 1.7

e. Update using the Admin userid and password, which has access to the physical nodes SQLNode1 and SQLNode2 of the VCLuster. Fig 1.8.

Fig 1.8

f. Click Finish. Refer to Fig 1.9.

Fig 1.9

Step 6

For testing purposes, let's run this batch file manually.

(Caution: Do not execute this batch file in your production environment unless you test it in your test cluster box. This procedure will restart your physical nodes immediately).

Now, let's assume that all resources are active in SQLNode1 as shown in Fig 2.0.

Click for larger image

Fig 2.0

Execute the batch file, c:\reboot\preparereboot.bat, as shown below in Fig 2.1 and 2.2.

Click for larger image

Fig 2.1

Fig 2.2

Immediately you will get this message in SQLNode1. (Refer to Fig 2.3). The /t 60 switch in the SHUTDOWN command provides a one minute delay before shutting down. This can be changed according to your requirements.

Fig 2.3

Cluster service will automatically move the group to SQLNode2 as shown below. Refer to Fig 2.4 and 2.5.

Fig 2.4

Fig 2.5

Now if you take a look at the clusternodes.txt, you will see that the sequence is changed from SQLNode1,SQLNode2 to SQLNode2,SQLNode1. Refer to Fig 2.6.

Fig 2.6

Let's run the batch file again, to see whether it returns SQLNode1 back to the active node. Refer to Fig 2.7

Fig 2.7

In SQLNode2 you will get the following message. Refer to Fig 2.8.

Fig 2.8

Cluster service will immediately move all of the resources to SQLNode1 as shown below. Refer Fig 2.9 and 3.0.

Fig 2.9

Fig 3.0

In addition, you will notice that clusternodes.txt will contain the old sequence SQLNode1,SQLNode2.

Fig 3.1


By using the instructions described in this article, you can switch the active node to the passive node and the passive node to the active node on the first reboot and vice versa in the successive reboots. In an upcoming article, we will go through the steps involved in rebooting Active/Active SQL Cluster.

» See All Articles by Columnist MAK

Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved