One of the common questions I receive via email is, “How to apply patches in an AlwaysOn Availability Group configuration?” or “What are the steps we should take and things to consider while patching an availability replica?” While there are many articles available on this topic, I want to provide a concise and straightforward guide. In this article, I will outline the step-by-step process for patching an Availability Group with one secondary replica.
Before starting the patching process, it is essential to ensure that you have taken a recent OS backup with system state (or a VMware snapshot with SQL services stopped), a recent backup of all databases, and successfully completed a checkdb on the primary node. These steps are not mandatory but can help avoid any unexpected issues during the patching process.
- From the node acting as the primary replica (SQL1), change the failover mode to manual.
- Refresh the affected databases on the secondary replica (SQL2) and ensure that everything is green on the dashboard.
- Apply the patch (service pack or cumulative update) on SQL2.
- Repeat the Windows Update and/or software updates until all available patches are applied. Do not proceed with the patching steps until all patches and post-patch reboot and configuration tasks are completed.
- Double-check that patches have been applied, the cluster is healthy, and AlwaysOn Availability Groups are functional. Make sure that the synchronization state is SYNCHRONIZED.
- Fail over the availability group to the secondary replica (SQL2).
- Refresh the affected databases on the secondary replica (former primary = SQL1) until the synchronization state is synchronized.
- Apply the patch (service pack or cumulative update) on SQL1.
- Repeat the Windows Update and/or software updates until all available patches are applied. Do not proceed with the patching steps until all patches and post-patch reboot and configuration tasks are completed.
- Double-check that patches have been applied, the cluster is healthy, and AlwaysOn Availability Groups are functional. Make sure that the synchronization state is SYNCHRONIZED.
- Fail over the availability group to the primary node (back to SQL1).
- Change the failover mode to Automatic (which was changed in Step 1).
Following these steps will help ensure a smooth patching process for your SQL Server AlwaysOn Availability Group. In case things do not go as planned, you have followed Step 1, so you know what needs to be done.
Remember to always have proper backups and test the patching process in a non-production environment before applying it to your production systems.