Saturday, December 28, 2024
Google search engine
HomeData Modelling & AIConfigure Windows Server 2022 Failover Clustering (WSFC)

Configure Windows Server 2022 Failover Clustering (WSFC)

This article shows you how to configure Windows Server 2022 Failover Clustering (WSFC). Failover Clustering, also known as Windows Server Failover Clustering (WSFC), is a feature in the Windows Server Operating System. It is used to provide high availability and fault tolerance for critical applications and services. It allows multiple servers/cluster nodes, to work together to realize a highly reliable and continuously available environment.

The main reason for setting up a Failover Clustering is to ensure that if a server in the cluster fails or experiences an issue, another server automatically steps up and takes its workload without interrupting the service. This seamless transition is called failover. The active workload is transferred from the failed node to a healthy node within the cluster.

Failover Clustering is so important as it helps ensure business continuity and reduce downtime for applications and services that cannot afford to go offline. By deploying a cluster, organizations achieve high availability and fault tolerance, minimizing the impact of hardware failures, scheduled maintenance, or any software issues. The main areas where Failover Clustering is commonly used are:

  • Database Systems: when databases are clustered continuous availability is guaranteed, minimising data loss in case of a server failure. It is often employed for critical database platforms like Microsoft SQL Server
  • File and Print Services: It also allows uninterrupted access to shared files and printers, ensuring that users can always access their resources even if a server fails.
  • Web Applications: web servers can also be clustered to ensure that websites and web applications remain available even if one or more servers encounter problems. This is particularly important for e-commerce sites, online services, and other web-based applications that require continuous availability.
  • Virtualization: this ensures hosts are high available for virtual machines (VMs). If a physical host fails, the VMs can be automatically migrated to another healthy host, minimizing downtime and preserving service continuity.
  • Messaging and Collaboration: It is also often used for email servers, collaboration platforms, and messaging systems such as Microsoft Exchange Server, ensuring uninterrupted communication and collaboration.

Let us learn how we can configure Windows Server 2022 Failover Clustering (WSFC).

Prepare Your Environment

To demonstrate how o configure a Failover Clustering (WSFC), I will use the three Windows server 2022 nodes below:

TASK IP ADDRESS HOSTNAME
iSCSI Target/AD DS/DNS 192.168.200.55 win-server.geeksforgeeks.org
Cluster Node1 192.168.200.70 node1.geeksforgeeks.org
Cluster Node2 192.168.200.71 node2.geeksforgeeks.org

You also need to have a DNS server set up to provide DNS resolution. You can either use:

Step 1: Install and Configure iSCSI Target Server

For Failover Clustering (WSFC), we need to configure shared storage for the cluster nodes. For this guide, we will use iSCSI as the shared storage.

Install and configure iSCSI Target on Windows Server 2022 using the below guide:

Once the Target has been installed, you need to make some configurations before it can be used in WSFC. Create a New Target disk that will be used as the Quorum disk in the Cluster.

This can be done using the PowerShell as shown:

New-IscsiServerTarget -TargetName "iSCSITarget01" -InitiatorId @("IPAddress:192.168.200.70","IPAddress:192.168.200.71") 

In the above command, 192.168.200.70 and 192.168.200.71 are the IP addresses of the cluster nodes.

Next, set the disk size for the shared storage:

New-IscsiVirtualDisk -Path "C:\iSCSIstorage\Quorum01.vhdx" -SizeBytes 512MB

Now assign the created disk to the Target:

Add-IscsiVirtualDiskTargetMapping -TargetName "iSCSITarget01" -Path "C:\iSCSIstorage\Quorum01.vhdx" 

Enable CHAP authentication for Target. Set a username and password to be used to access the storage:

Set-IscsiServerTarget `
-TargetName "iSCSITarget01" `
-EnableChap $True `
-Chap (New-Object PSCredential("user1", (ConvertTo-SecureString -AsPlainText "StrongPassw0rd!" -Force)))`
-PassThru 

View the made configurations:

Get-IscsiServerTarget -TargetName "iSCSITarget01" 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 1 1

Restart the service:

Restart-Service -Name WinTarget 

a. Configure iSCSI Initiator on the Cluster Nodes

Now all the cluster nodes need to be configured to access the shared storage. We need to configure the iSCSI initiator on them.

On all the nodes you intend to be in the cluster, run the commands below.

Start-Service -Name MSiSCSI 
Set-Service -Name MSiSCSI -StartupType Automatic 
New-IscsiTargetPortal -TargetPortalAddress "192.168.200.55" 

Get the information:

Get-IscsiTarget 

Now connect to the iSCSI Target:

Connect-IscsiTarget `
-NodeAddress iqn.1991-05.com.microsoft:win-server-iscsitarget01-target `
-AuthenticationType ONEWAYCHAP `
-ChapUsername "user1" `
-ChapSecret "StrongPassw0rd!" `
-IsPersistent $True 

Verify if the nodes have connected to the cluster:

Get-IscsiConnection 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 2

b. Format the Shared Disk to NTFS

Now on one of the cluster nodes, we need to format the iSCSI disk to NTFS. First, identify the disk number

Get-Disk | Format-Table -AutoSize -Wrap 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 3

Once the disk number has been identified, use the number in the below step. Initialize the disk and set the GPT partition:

Set-Disk -Number 1 -IsOffline $False
Initialize-Disk -Number 1 -PartitionStyle GPT 

Create a partition and assign the disk a letter:

New-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter 

Format the disk to NTFS:

 Format-Volume -DriveLetter E -FileSystem NTFS -Force 

Replace the drive letter as assigned on your system.

Step 2: Install Windows Server Failover Clustering (WSFC)

To be able to configure the Windows Server Failover Clustering, we need to have the package installed on all the cluster nodes. This can be done using both the PowerShell and GUI.

a. Install Windows Server Failover Clustering (WSFC) on PowerShell

For the PowerShell, execute the below commands with admin privileges:

Install-WindowsFeature Failover-Clustering -IncludeManagementTools 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 4

b. Install Windows Server Failover Clustering (WSFC) on GUI

You can also install the WSFC package for the Windows Server 2022 GUI. First, access the Server Manager and click on Add roles and features

Configure Windows Server 2022 Failover Clustering WSFC 5

Select the Role-based or feature-based installation option and proceed.

Configure Windows Server 2022 Failover Clustering WSFC 6

Select the destination host:

Configure Windows Server 2022 Failover Clustering WSFC 7

On this tab, just click next.

Configure Windows Server 2022 Failover Clustering WSFC 8

On the features tab, select Failover Clustering

Configure Windows Server 2022 Failover Clustering WSFC 9

Proceed and install the feature, once complete, click close and restart your computer.

Configure Windows Server 2022 Failover Clustering WSFC 10

Step 3: Configure Windows Server Failover Clustering (WSFC)

Once the package has been installed on all the desired cluster nodes, we can then proceed and configure Failover Clustering. This can also be done through both the GUI and PowerShell.

Choose one of the options below that best works for you.

Option a: Configure Windows Server Failover Clustering using PowerShell

On one of the nodes, run PowerShell with elevated privileges and execute the below commands.

First, specify your nodes and test if they are accessible:

##Without AD
Test-Cluster -Node "192.168.200.70", "192.168.200.71" 

#With AD
Test-Cluster -Node "node1", "node2" 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 11

The above report shows that you are safe to proceed with the configuration.

Now configure the cluster. Here, you set the nodes, the Administrative Access Point and the IP address of the cluster

For DNS server

New-Cluster -Name Cluster01 -Node "192.168.200.70", "192.168.200.71" `
-AdministrativeAccessPoint DNS `
-StaticAddress 192.168.200.73 

Alternatively, if you have AD and the nodes joined, you can use

New-Cluster -Name Cluster01 -Node "node1", "node2" `
-AdministrativeAccessPoint ActiveDirectoryAndDns `
-StaticAddress 192.168.200.73 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 12

View the made settings:

Get-Cluster | Format-List -Property * 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 13

Verify if you can access the cluster:

Configure Windows Server 2022 Failover Clustering WSFC 14

Option b: Configure Windows Server Failover Clustering using GUI

It is also possible to run all the above activities from the GUI. On one of the nodes, navigate to the Server Manager->Tools->Failover Cluster Manager.

Configure Windows Server 2022 Failover Clustering WSFC 15

Right-click on the Failover Cluster Manager and select Create Cluster.

Configure Windows Server 2022 Failover Clustering WSFC 16

Click Next.

Configure Windows Server 2022 Failover Clustering WSFC 17

Provide the hostname or IP address of all the nodes you need to add to the cluster.

Configure Windows Server 2022 Failover Clustering WSFC 21

You can then run tests if you wish, to know if everything is okay:

Configure Windows Server 2022 Failover Clustering WSFC 22

Proceed as directed:

Configure Windows Server 2022 Failover Clustering WSFC 23

After skipping or doing the tests, set the name and static IP address of the cluster.

Configure Windows Server 2022 Failover Clustering WSFC 24

Now confirm the made settings and proceed if they are okay.

Configure Windows Server 2022 Failover Clustering WSFC 25

Once created, you will see this:

Configure Windows Server 2022 Failover Clustering WSFC 26

Now you can manage the cluster here.

Configure Windows Server 2022 Failover Clustering WSFC 27

Step 4: Add Shared Storage to Windows Server Failover Clustering (WSFC)

Now we need to create and add a new disk to store the data for the cluster. This disk can be created using both the GUI and Shell.

Our iSCSI Target has the previous quorum disk created. We can see the information using the below command on the iSCSI Target shell:

Get-IscsiServerTarget 

Now we will also add another disk:

New-IscsiVirtualDisk -Path "C:\iSCSIstorage\DataDisk01.vhdx" -SizeBytes 30GB 

Assign the created disk to the iSCSI Target:

Add-IscsiVirtualDiskTargetMapping -TargetName "iSCSITarget01" -Path "C:\iSCSIstorage\DataDisk01.vhdx" 

Validate the settings with the command:

Get-IscsiServerTarget -TargetName "iSCSITarget01" 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 28

a. Format the Disk on the Primary Node

Once the disk has been created on the iSCSI Target, we need to format it to NTFS on the primary node of the cluster. Get the disk number:

Get-Disk | Format-Table -AutoSize -Wrap 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 29

Initialize the disk and set the GPT partition on it:

Set-Disk -Number 2 -IsOffline $False
Initialize-Disk -Number 2 -PartitionStyle GPT 

Create a partition and assign it a letter.

New-Partition -DiskNumber 2 -UseMaximumSize -AssignDriveLetter 

Using the obtained letter, format the drive to NTFS:

Format-Volume -DriveLetter F -FileSystem NTFS -Force 

Sample output:

Configure Windows Server 2022 Failover Clustering WSFC 30

b. Add the Disk to the Cluster

Once the disk has been created and formatted, we can add it to the cluster. This can be done in two ways as shown below:

Method 1: Using PowerShell

On the Primary node, you can add the disk to the cluster using the command below:

Get-Disk -Number 2 | Add-ClusterDisk 

View the made changes:

Get-ClusterResource 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 31

Method 2: Using GUI

The disk can also be added using the GUI. On the primary node, after formatting the disk to NTFS, access the Failover Cluster Manager->Storage-> Add Disk

Configure Windows Server 2022 Failover Clustering WSFC 40

Select the disk you want to attach:

Configure Windows Server 2022 Failover Clustering WSFC 44

The disk will be added as shown:

Configure Windows Server 2022 Failover Clustering WSFC 32

Step 5: Add Nodes to Windows Server Failover Clustering (WSFC)

To add a node to the Windows Server Failover Clustering (WSFC), first, ensure that it is joined to the AD or added to the DNS server for proper name resolution.

Also, allow it to access and log in to ISCSI Target. Use the command below on the iSCSI Target:

Set-IscsiServerTarget -TargetName "iSCSITarget01" -InitiatorId @("IPAddress:192.168.200.70","IPAddress:192.168.200.71","IPAddress:192.168.200.72") 

Restart the service for the changes to take effect:

Restart-Service -Name WinTarget 

Install Failover Clustering on the node as we did in step 2.

Once installed, join the cluster by executing the command:

Add-ClusterNode -Cluster "Cluster01" -Name "node3" 

Verify the changes:

Get-ClusterNode 

Sample output:

Configure Windows Server 2022 Failover Clustering WSFC 34

On the GUI, to add a node, right-click on the cluster:

Configure Windows Server 2022 Failover Clustering WSFC 41

Provide the domain name of the node.

Configure Windows Server 2022 Failover Clustering WSFC 42

Now follow the similar steps we did earlier when creating the cluster.

Configure Windows Server 2022 Failover Clustering WSFC 43

Once added, the node will appear as shown:

Configure Windows Server 2022 Failover Clustering WSFC 33

Step 6: Remove Nodes in Windows Server Failover Clustering (WSFC)

To remove a node from the cluster, access the node with Cluster Administrative tools and issue the command with the below syntax:

Remove-ClusterNode -Cluster "<cluster-name>" -Name "<node-name>" 

For example:

Remove-ClusterNode -Cluster  "Cluster01" -Name "node3" 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 37

You can also do this from the GUI. Just right-click on the node to delete select remove ->Evict

Configure Windows Server 2022 Failover Clustering WSFC 35

Proceed as shown below:

Configure Windows Server 2022 Failover Clustering WSFC 36

Step 7: Test Windows Server Failover Clustering (WSFC)

Now we can test and see if the Windows Server Failover Clustering (WSFC) is working as desired. For this demo, we will use SSH. Ensure that SSH is enabled on the cluster nodes using the guide below:

Now test if you can SSH to any of the cluster nodes with the cluster IP.

For example:

ssh [email protected]

Once connected, run the below commands:

powershell
Get-ClusterNode 

Get the hostname and volume

hostname
Get-Volume 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 38

Once here, reboot this node:

Restart-Computer -Force 

While still rebooting, try SSH again.

ssh [email protected]

Get the hostname and volume:

powershell 
Get-ClusterNode
hostname 
Get-Volume 

Sample Output:

Configure Windows Server 2022 Failover Clustering WSFC 39

From the above output, we have logged in to another system. This is a simple demonstration of how high availability can be achieved with this setup. You can now make the desired HA for your databases, web apps etc.

Verdict

Today we have learned how to configure Windows Server 2022 Failover Clustering (WSFC). This can play a critical role in ensuring the availability, resilience, and continuous operation of important applications and services in various domains. I hope this was significant to you.

See more:

Deploy Highly Available Kubernetes Cluster on CentOS 7 using Kubespray

Configure Windows Server 2022 as Secondary DNS Server

Configure OpenSSH Server on Windows Server 2022

RELATED ARTICLES

Most Popular

Recent Comments