MS SQL Server Fail-over Cluster Implementation
Table of Contents
Prerequisites:
- Two Windows Server VMs (2016/2019/2022)
- Each VM needs:
- Minimum 8GB RAM (16GB recommended)
- 4 vCPUs
- 100GB+ storage for OS and SQL Server
- Active Directory domain-joined
- SQL Server Enterprise Edition installed
- Network connectivity between VMs
Step 1: Prepare Both VMs
- Ensure both VMs are patched with the same updates
- Join both VMs to the same Active Directory domain
- Install SQL Server Enterprise Edition on both nodes:
- Use the same instance name, file paths, and configuration
- Install with the same service accounts
- Include SQL Server Replication feature
Step 2: Configure Windows Failover Clustering
- Add the Failover Clustering feature on both nodes
- Run the Cluster Validation wizard to check for any issues
- Create the Windows Failover Cluster with a unique name and IP address
- Verify the cluster is healthy in Failover Cluster Manager
Step 3: Configure SQL Server Always On
- Enable SQL Server Always On feature in SQL Server Configuration Manager on both nodes
- Create a database mirroring endpoint on both servers (port 5022)
- Create the Availability Group on the primary node
- Add the database(s) to the Availability Group
- Join the secondary replica to the Availability Group
- Create a listener for client connectivity
PowerShell Script
Step 4: Test Failover Functionality
Manually fail over the Availability Group:
Switch-SqlAvailabilityGroup -Path "SQLSERVER:\SQL\VM1\DEFAULT\AvailabilityGroups\SQLAG"
Perform a forced failover (for disaster recovery testing):
Switch-SqlAvailabilityGroup -Path "SQLSERVER:\SQL\VM1\DEFAULT\AvailabilityGroups\SQLAG" -AllowDataLoss
Verify client connectivity through the listener after failover
Performance Tuning:
# Adjust synchronization mode for better performance
Set-SqlAvailabilityReplica -AvailabilityMode "AsynchronousCommit" -Path "SQLSERVER:\SQL\VM1\DEFAULT\AvailabilityGroups\SQLAG\AvailabilityReplicas\VM2"