{"id":195,"date":"2024-05-10T15:27:38","date_gmt":"2024-05-10T15:27:38","guid":{"rendered":"https:\/\/arturicast.co.za\/blogs\/?p=195"},"modified":"2024-05-13T13:44:28","modified_gmt":"2024-05-13T11:44:28","slug":"set-up-basic-always-on-availability-disaster-recovery-in-sql-server-standard","status":"publish","type":"post","link":"https:\/\/arturicast.co.za\/blogs\/2024\/05\/10\/set-up-basic-always-on-availability-disaster-recovery-in-sql-server-standard\/","title":{"rendered":"Set up Basic Always-on availability &amp; disaster recovery in SQL Server Standard"},"content":{"rendered":"<h2><a id=\"post-195-_Toc159846561\"><\/a>Index<\/h2>\n<p>Contents<\/p>\n<p><a href=\"#post-195-_Toc159846562\">Introduction 2<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846563\">List of acronyms used in this document: 2<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846564\">Explanation 2<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846565\">A brief explanation of what BADR is and why we use it: 2<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846566\">Limitations 3<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846567\">Prerequisites for setting up BADR 4<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846568\">Now we need to do the actual Basic Availability Setup 4<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846569\">Step 1: Enable Always On in all participating instances of SQL Server 4<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846570\">Step 2: Restart SQL Server instance Service 6<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846571\">Step 3: Configure AG per database per node 6<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846572\">Step 4: Adding more databases to AG 14<\/a><\/p>\n<p><a href=\"#post-195-_Toc159846573\">The beauty of BADR: 16<\/a><\/p>\n<h2><a id=\"post-195-_Toc159846562\"><\/a>Introduction<\/h2>\n<h3><a id=\"post-195-_Toc159846563\"><\/a>List of acronyms used in this document:<\/h3>\n<table>\n<tbody>\n<tr>\n<td>Acronym<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td>WSFC<\/td>\n<td>Windows Server Failover Cluster (A group of connected and interdependent servers used for reliability and availability of an environment)<\/td>\n<\/tr>\n<tr>\n<td>HA<\/td>\n<td>High Availability<\/td>\n<\/tr>\n<tr>\n<td>AG<\/td>\n<td>Availability Groups<\/td>\n<\/tr>\n<tr>\n<td>BAG<\/td>\n<td>Basic Availability Groups<\/td>\n<\/tr>\n<tr>\n<td>HADR<\/td>\n<td>High Always-On Availability and Disaster Recovery<\/td>\n<\/tr>\n<tr>\n<td>FCI<\/td>\n<td>Failover Cluster Instances<\/td>\n<\/tr>\n<tr>\n<td>BADR<\/td>\n<td>Basic Always-on Availability and Disaster Recovery<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><a id=\"post-195-_Toc159846564\"><\/a>Explanation<\/h2>\n<p>In this walkthrough, we will be setting up BADR in SQL Server Standard, as a base for HA.<\/p>\n<h3><a id=\"post-195-_Toc159846565\"><\/a>A brief explanation of what BADR is and why we use it:<\/h3>\n<p>This is a group of SQL servers that work together to ensure high availability of applications and services.<\/p>\n<p>Any HA platform in SQL Server runs in WSFC (albeit for FCI or AG).<\/p>\n<p>To begin, let us provide a succent breakdown of the various components, and compare between SQL Server Standard and Enterprise editions:<\/p>\n<table>\n<tbody>\n<tr>\n<td>Component<\/td>\n<td>Standard<\/td>\n<td>Enterprise<\/td>\n<\/tr>\n<tr>\n<td>Always On failover cluster instances<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>High Always On availability groups<\/td>\n<td>No<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Basic Always-On availability groups<\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Contained availability groups<\/td>\n<td>No<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Distributed availability groups<\/td>\n<td>No<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Number of Availability Groups per Database Server<\/td>\n<td>Limited to number of databases in Primary<\/td>\n<td>Limited to system resources<\/td>\n<\/tr>\n<tr>\n<td>Number of Databases per availability group<\/td>\n<td>1<\/td>\n<td>Number of databases in Primary<\/td>\n<\/tr>\n<tr>\n<td>Maximums:<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Nodes<\/td>\n<td>2<\/td>\n<td>9<\/td>\n<\/tr>\n<tr>\n<td>Of which:<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\n<ul>\n<li>Primary<\/li>\n<\/ul>\n<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>\n<ul>\n<li>Read-only Secondary Replicas<\/li>\n<\/ul>\n<\/td>\n<td>0<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>\n<ul>\n<li>Synchronised Secondary Replicas with Automatic Failover<\/li>\n<\/ul>\n<\/td>\n<td>1<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td>\n<ul>\n<li>Synchronised Secondary Replicas with Manual Failover<\/li>\n<\/ul>\n<\/td>\n<td>1<\/td>\n<td>5<\/td>\n<\/tr>\n<tr>\n<td>\n<ul>\n<li>Asynchronous Secondary Replicas with Manual \/ Forced Failover<\/li>\n<\/ul>\n<\/td>\n<td>1<\/td>\n<td>5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This functionality therefore ensures that a copy of the current primary is always available, with the following caveats:<\/p>\n<ul>\n<li>For Synchronised Sencondary replicas, the more replicas in the group, the longer it will take to finalise each entry (incrementally higher latency), i.e. all secondaries in the chain need to have hardened their logs before the primary records the transaction as successful. Therefore:\n<ul>\n<li>Location is important, the closer to the primary the better.<\/li>\n<li>Connectivity speeds between members of the WSFC makes a difference (only use in a high-speed intranet environment).<\/li>\n<\/ul>\n<\/li>\n<li>For Asynchronous Secondary replicas, commit occurs on the Primary and responds as such, before sending the logs to the secondary replicas. Therefore:\n<ul>\n<li>Location and network speed do not matter. However, stability does.<\/li>\n<li>However, the probability of data loss in case of forced failover is greater than with Synchronised Secondary Replicas.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><a id=\"post-195-_Toc159846566\"><\/a>Limitations<\/h3>\n<p>Basic availability groups use a subset of features compared to advanced availability groups on SQL Server Enterprise Edition. Basic availability groups include the following limitations:<\/p>\n<ul>\n<li>Limit of two replicas (primary and secondary). Basic Availability Groups for SQL Server on Linux support an additional configuration only replica.<\/li>\n<li>No read access on secondary replica.<\/li>\n<li>No backups on secondary replica.<\/li>\n<li>No integrity checks on secondary replicas.<\/li>\n<li>No support for replicas hosted on servers running a version of SQL Server prior to SQL Server 2016 Community Technology Preview 3 (CTP3).<\/li>\n<li>Support for one availability database.<\/li>\n<li>Basic availability groups cannot be upgraded to advanced availability groups. The group must be dropped and re-added to a group that contains servers running only SQL Server Enterprise Edition.<\/li>\n<li>Basic availability groups are only supported for Standard Edition servers.<\/li>\n<li>Basic availability groups cannot be part of a distributed availability group.<\/li>\n<li>You may have multiple Basic availability groups connected to a single instance of SQL Server.<\/li>\n<\/ul>\n<h2><a id=\"post-195-_Toc159846567\"><\/a>Prerequisites for setting up BADR<\/h2>\n<ul>\n<li>Ensure both nodes are on the same domain.<\/li>\n<li>Both nodes have the same version and edition of SQL server installed, with the same level of patching.<\/li>\n<li>The hard drive locations are the same on both replicas.<\/li>\n<li>WSFC has been set up and is correctly configured, and both nodes are members thereof.<\/li>\n<\/ul>\n<h2><a id=\"post-195-_Toc159846568\"><\/a>Now we need to do the actual Basic Availability Setup<\/h2>\n<p>To showcase this, I have the following setup in my environment:<\/p>\n<ul>\n<li>Host: Windows Server 2022 Standard with Hyper-V\n<ul>\n<li>Virtual Servers:\n<ul>\n<li>Active Directory Services. Domain Controller and DNS Services (In the real world, these would be separate servers.)<\/li>\n<li>DB Server 1, SQL Server 2022 with 3 databases<\/li>\n<li>DB Server 2, SQL Server 2022.<\/li>\n<li>File Server (this will be the tiebreaker instance)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"532\" height=\"129\" class=\"wp-image-198\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-7.png\" alt=\"A screenshot of a computer\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-7.png 532w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-7-300x73.png 300w\" sizes=\"auto, (max-width: 532px) 100vw, 532px\" \/><\/p>\n<h3><a id=\"post-195-_Toc159846569\"><\/a>Step 1: Enable Always On in all participating instances of SQL Server<\/h3>\n<ul>\n<li>Open SQL Server Configuration Manager (as Administrator).<\/li>\n<li>Select SQL Server Services.<\/li>\n<li>Right Click on the instance of SQL server and select Properties.<\/li>\n<li>In the properties form, select Always On Availability Groups tab.<\/li>\n<li>Tick Enable Always On Availability Groups.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1209\" height=\"715\" class=\"wp-image-199\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-4.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-4.png 1209w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-4-300x177.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-4-1024x606.png 1024w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-4-768x454.png 768w\" sizes=\"auto, (max-width: 1209px) 100vw, 1209px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1359\" height=\"714\" class=\"wp-image-200\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-8.png\" alt=\"A screenshot of a computer\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-8.png 1359w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-8-300x158.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-8-1024x538.png 1024w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-8-768x403.png 768w\" sizes=\"auto, (max-width: 1359px) 100vw, 1359px\" \/><\/p>\n<ul>\n<li>A popup notification will appear to state that the changes will be applied but will only take effect after the service is restarted. Click on OK.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"409\" height=\"479\" class=\"wp-image-201\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-6.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-6.png 409w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-6-256x300.png 256w\" sizes=\"auto, (max-width: 409px) 100vw, 409px\" \/><\/p>\n<h3><a id=\"post-195-_Toc159846570\"><\/a>Step 2: Restart SQL Server instance Service<\/h3>\n<p>Right Click on the SQL Server instance and select Restart. The Stopping and starting pane will briefly appear<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"514\" height=\"161\" class=\"wp-image-202\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-error-description-auto-1.png\" alt=\"A screenshot of a computer error\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-error-description-auto-1.png 514w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-error-description-auto-1-300x94.png 300w\" sizes=\"auto, (max-width: 514px) 100vw, 514px\" \/> <img loading=\"lazy\" decoding=\"async\" width=\"494\" height=\"157\" class=\"wp-image-203\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-error-description-auto-2.png\" alt=\"A screenshot of a computer error\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-error-description-auto-2.png 494w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-error-description-auto-2-300x95.png 300w\" sizes=\"auto, (max-width: 494px) 100vw, 494px\" \/><\/p>\n<h3><a id=\"post-195-_Toc159846571\"><\/a>Step 3: Configure AG per database per node<\/h3>\n<p>To create a basic availability group, use the\u00a0<strong>CREATE AVAILABILITY GROUP<\/strong>\u00a0Transact-SQL command and specify the\u00a0<strong>WITH BASIC<\/strong>\u00a0option (the default is\u00a0<strong>ADVANCED<\/strong>). You can also create the basic availability group using the UI in SQL Server Management Studio.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"819\" height=\"721\" class=\"wp-image-204\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-9.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-9.png 819w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-9-300x264.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-9-768x676.png 768w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"714\" class=\"wp-image-205\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-10.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-10.png 808w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-10-300x265.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-10-768x679.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/p>\n<p>For the HR database, we opt for Asynchronous Secondary:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"819\" height=\"706\" class=\"wp-image-206\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-11.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-11.png 819w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-11-300x259.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-11-768x662.png 768w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/p>\n<p>Endpoints:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"812\" height=\"707\" class=\"wp-image-207\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-9.png\" alt=\"A screenshot of a computer\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-9.png 812w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-9-300x261.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-9-768x669.png 768w\" sizes=\"auto, (max-width: 812px) 100vw, 812px\" \/><\/p>\n<p>Backup Preference:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"812\" height=\"710\" class=\"wp-image-208\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-13.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-13.png 812w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-13-300x262.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-13-768x672.png 768w\" sizes=\"auto, (max-width: 812px) 100vw, 812px\" \/><\/p>\n<p>Listener:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"822\" height=\"717\" class=\"wp-image-209\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-14.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-14.png 822w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-14-300x262.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-14-768x670.png 768w\" sizes=\"auto, (max-width: 822px) 100vw, 822px\" \/><\/p>\n<p>Once that is done, we proceed to Data Synchronisation:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"819\" height=\"701\" class=\"wp-image-210\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-15.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-15.png 819w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-15-300x257.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-15-768x657.png 768w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/p>\n<p>We are going with Join only, as a backup and restore was done on the secondary. This will take us to the validation page:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"815\" height=\"707\" class=\"wp-image-211\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-16.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-16.png 815w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-16-300x260.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-16-768x666.png 768w\" sizes=\"auto, (max-width: 815px) 100vw, 815px\" \/><\/p>\n<p>Summary:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"812\" height=\"700\" class=\"wp-image-212\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-17.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-17.png 812w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-17-300x259.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-17-768x662.png 768w\" sizes=\"auto, (max-width: 812px) 100vw, 812px\" \/><\/p>\n<p>Pressing Finish will execute setup at the various locations.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"816\" height=\"714\" class=\"wp-image-213\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-18.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-18.png 816w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-18-300x263.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-18-768x672.png 768w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><\/p>\n<p>The full detail of what was done is reflected.<\/p>\n<p>Now, looking at the primary DB server in SSMS, we can see:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"357\" height=\"361\" class=\"wp-image-214\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-10.png\" alt=\"A screenshot of a computer\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-10.png 357w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-10-297x300.png 297w\" sizes=\"auto, (max-width: 357px) 100vw, 357px\" \/><\/p>\n<p>The Secondary Replica reflects:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"279\" height=\"325\" class=\"wp-image-215\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-20.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-20.png 279w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-20-258x300.png 258w\" sizes=\"auto, (max-width: 279px) 100vw, 279px\" \/><\/p>\n<p>We can check that the Virtual Network Node for the listener has been created in the domain:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"756\" height=\"529\" class=\"wp-image-216\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-21.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-21.png 756w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-21-300x210.png 300w\" sizes=\"auto, (max-width: 756px) 100vw, 756px\" \/><\/p>\n<h3><a id=\"post-195-_Toc159846572\"><\/a>Step 4: Adding more databases to AG<\/h3>\n<p>Adding the other databases to availability groups reflects as follows:<\/p>\n<ul>\n<li>On the primary replica:\n<ul>\n<li>In SSMS Connected database list:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"266\" height=\"269\" class=\"wp-image-217\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-11.png\" alt=\"A screenshot of a computer\n\nDescription automatically generated\" \/><\/p>\n<ul>\n<li>\n<ul>\n<li>AG Dashboard:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"627\" height=\"234\" class=\"wp-image-218\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-23.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-23.png 627w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-23-300x112.png 300w\" sizes=\"auto, (max-width: 627px) 100vw, 627px\" \/><\/p>\n<ul>\n<li>On the secondary replica:\n<ul>\n<li>In SSMS Connected database list:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"262\" height=\"269\" class=\"wp-image-219\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-12.png\" alt=\"A screenshot of a computer\n\nDescription automatically generated\" \/><\/p>\n<ul>\n<li>\n<ul>\n<li>AD Dashboard:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"196\" class=\"wp-image-220\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-13.png\" alt=\"A screenshot of a computer\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-13.png 473w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-13-300x124.png 300w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/p>\n<ul>\n<li>On Active Directory:\n<ul>\n<li>Computers:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"511\" height=\"77\" class=\"wp-image-221\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-group-of-black-text-description-automatically-g.png\" alt=\"A group of black text\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-group-of-black-text-description-automatically-g.png 511w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-group-of-black-text-description-automatically-g-300x45.png 300w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><\/p>\n<h2><a id=\"post-195-_Toc159846573\"><\/a>The beauty of BADR:<\/h2>\n<ul>\n<li>Connections to the database can now be made using the listener, and not directly to the primary and\/or secondary replica\u2019s (even though an instance of SQL server had not been installed on the listener (which is, in and of itself, a virtual network node, with no OS or applications installed)). Thus, in the case of a failover, it is not necessary to change the connection string in the application.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1347\" height=\"599\" class=\"wp-image-222\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-14.png\" alt=\"A screenshot of a computer\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-14.png 1347w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-14-300x133.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-14-1024x455.png 1024w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-14-768x342.png 768w\" sizes=\"auto, (max-width: 1347px) 100vw, 1347px\" \/><\/p>\n<ul>\n<li>The Always-On Dashboard gives a birds-eye view of the synchronisation status of participating databases<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"963\" height=\"234\" class=\"wp-image-223\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-28.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-28.png 963w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-28-300x73.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-28-768x187.png 768w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"958\" height=\"494\" class=\"wp-image-224\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-15.png\" alt=\"A screenshot of a computer\n\nDescription automatically generated\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-15.png 958w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-15-300x155.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/a-screenshot-of-a-computer-description-automatica-15-768x396.png 768w\" sizes=\"auto, (max-width: 958px) 100vw, 958px\" \/><\/p>\n<ul>\n<li>Manual Failover can take place with the click of a button.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"805\" height=\"714\" class=\"wp-image-225\" src=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-30.png\" srcset=\"https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-30.png 805w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-30-300x266.png 300w, https:\/\/arturicast.co.za\/blogs\/wp-content\/uploads\/2024\/05\/word-image-195-30-768x681.png 768w\" sizes=\"auto, (max-width: 805px) 100vw, 805px\" \/><\/p>\n<p>Here is the entire script applied, at each server as highlighted, to activate BADR:<\/p>\n<p>&#8212; YOU MUST EXECUTE THE FOLLOWING SCRIPT IN SQLCMD MODE.<\/p>\n<p>:Connect DBSERV01<\/p>\n<p>IF (SELECT state FROM sys.endpoints WHERE name = N&#8217;Hadr_endpoint&#8217;) &lt;&gt; 0<\/p>\n<p>BEGIN<\/p>\n<p>ALTER ENDPOINT [Hadr_endpoint] STATE = STARTED<\/p>\n<p>END<\/p>\n<p>GO<\/p>\n<p>use [master]<\/p>\n<p>GO<\/p>\n<p>GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [ACSCS\\SQLService]<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV01<\/p>\n<p>IF EXISTS(SELECT * FROM sys.server_event_sessions WHERE name=&#8217;AlwaysOn_health&#8217;)<\/p>\n<p>BEGIN<\/p>\n<p>ALTER EVENT SESSION [AlwaysOn_health] ON SERVER WITH (STARTUP_STATE=ON);<\/p>\n<p>END<\/p>\n<p>IF NOT EXISTS(SELECT * FROM sys.dm_xe_sessions WHERE name=&#8217;AlwaysOn_health&#8217;)<\/p>\n<p>BEGIN<\/p>\n<p>ALTER EVENT SESSION [AlwaysOn_health] ON SERVER STATE=START;<\/p>\n<p>END<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV02<\/p>\n<p>IF (SELECT state FROM sys.endpoints WHERE name = N&#8217;Hadr_endpoint&#8217;) &lt;&gt; 0<\/p>\n<p>BEGIN<\/p>\n<p>ALTER ENDPOINT [Hadr_endpoint] STATE = STARTED<\/p>\n<p>END<\/p>\n<p>GO<\/p>\n<p>use [master]<\/p>\n<p>GO<\/p>\n<p>GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [ACSCS\\SQLService]<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV02<\/p>\n<p>IF EXISTS(SELECT * FROM sys.server_event_sessions WHERE name=&#8217;AlwaysOn_health&#8217;)<\/p>\n<p>BEGIN<\/p>\n<p>ALTER EVENT SESSION [AlwaysOn_health] ON SERVER WITH (STARTUP_STATE=ON);<\/p>\n<p>END<\/p>\n<p>IF NOT EXISTS(SELECT * FROM sys.dm_xe_sessions WHERE name=&#8217;AlwaysOn_health&#8217;)<\/p>\n<p>BEGIN<\/p>\n<p>ALTER EVENT SESSION [AlwaysOn_health] ON SERVER STATE=START;<\/p>\n<p>END<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV01<\/p>\n<p>USE [master]<\/p>\n<p>GO<\/p>\n<p>CREATE AVAILABILITY GROUP [HR_AG]<\/p>\n<p>WITH (AUTOMATED_BACKUP_PREFERENCE = PRIMARY,<\/p>\n<p><strong>BASIC,<\/strong><\/p>\n<p>DB_FAILOVER = ON,<\/p>\n<p>DTC_SUPPORT = NONE,<\/p>\n<p>REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT = 0)<\/p>\n<p>FOR DATABASE [HR]<\/p>\n<p>REPLICA ON N&#8217;DBServ01&#8242; WITH (ENDPOINT_URL = N&#8217;TCP:\/\/DBServ01.ACSCS.arturicast.co.za:5022&#8242;, FAILOVER_MODE = MANUAL, AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT, BACKUP_PRIORITY = 50, SEEDING_MODE = MANUAL, SECONDARY_ROLE(ALLOW_CONNECTIONS = NO)),<\/p>\n<p>N&#8217;DBServ02&#8242; WITH (ENDPOINT_URL = N&#8217;TCP:\/\/DBServ02.ACSCS.arturicast.co.za:5022&#8242;, FAILOVER_MODE = MANUAL, AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT, BACKUP_PRIORITY = 50, SEEDING_MODE = MANUAL, SECONDARY_ROLE(ALLOW_CONNECTIONS = NO));<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV01<\/p>\n<p>USE [master]<\/p>\n<p>GO<\/p>\n<p>ALTER AVAILABILITY GROUP [HR_AG]<\/p>\n<p>ADD LISTENER N&#8217;Listener_HR_AG&#8217; (<\/p>\n<p>WITH IP<\/p>\n<p>((N&#8217;172.26.92.14&#8242;, N&#8217;255.255.0.0&#8242;)<\/p>\n<p>)<\/p>\n<p>, PORT=1433);<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV02<\/p>\n<p>ALTER AVAILABILITY GROUP [HR_AG] JOIN;<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV01<\/p>\n<p>BACKUP DATABASE [HR] TO DISK = N&#8217;\\\\DBSERV01\\UserDB\\HR\\HR.bak&#8217; WITH COPY_ONLY, FORMAT, INIT, SKIP, REWIND, NOUNLOAD, COMPRESSION, STATS = 5<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV02<\/p>\n<p>RESTORE DATABASE [HR] FROM DISK = N&#8217;\\\\DBSERV01\\UserDB\\HR\\HR.bak&#8217; WITH NORECOVERY, NOUNLOAD, STATS = 5<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV01<\/p>\n<p>BACKUP LOG [HR] TO DISK = N&#8217;\\\\DBSERV01\\UserDB\\HR\\HR.trn&#8217; WITH NOFORMAT, INIT, NOSKIP, REWIND, NOUNLOAD, COMPRESSION, STATS = 5<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV02<\/p>\n<p>RESTORE LOG [HR] FROM DISK = N&#8217;\\\\DBSERV01\\UserDB\\HR\\HR.trn&#8217; WITH NORECOVERY, NOUNLOAD, STATS = 5<\/p>\n<p>GO<\/p>\n<p>:Connect DBSERV02<\/p>\n<p>&#8212; Wait for the replica to start communicating<\/p>\n<p>begin try<\/p>\n<p>declare @conn bit<\/p>\n<p>declare @count int<\/p>\n<p>declare @replica_id uniqueidentifier<\/p>\n<p>declare @group_id uniqueidentifier<\/p>\n<p>set @conn = 0<\/p>\n<p>set @count = 30 &#8212; wait for 5 minutes<\/p>\n<p>if (serverproperty(&#8216;IsHadrEnabled&#8217;) = 1)<\/p>\n<p>and (isnull((select member_state from master.sys.dm_hadr_cluster_members where upper(member_name COLLATE Latin1_General_CI_AS) = upper(cast(serverproperty(&#8216;ComputerNamePhysicalNetBIOS&#8217;) as nvarchar(256)) COLLATE Latin1_General_CI_AS)), 0) &lt;&gt; 0)<\/p>\n<p>and (isnull((select state from master.sys.database_mirroring_endpoints), 1) = 0)<\/p>\n<p>begin<\/p>\n<p>select @group_id = ags.group_id from master.sys.availability_groups as ags where name = N&#8217;HR_AG&#8217;<\/p>\n<p>select @replica_id = replicas.replica_id from master.sys.availability_replicas as replicas where upper(replicas.replica_server_name COLLATE Latin1_General_CI_AS) = upper(@@SERVERNAME COLLATE Latin1_General_CI_AS) and group_id = @group_id<\/p>\n<p>while @conn &lt;&gt; 1 and @count &gt; 0<\/p>\n<p>begin<\/p>\n<p>set @conn = isnull((select connected_state from master.sys.dm_hadr_availability_replica_states as states where states.replica_id = @replica_id), 1)<\/p>\n<p>if @conn = 1<\/p>\n<p>begin<\/p>\n<p>&#8212; exit loop when the replica is connected, or if the query cannot find the replica status<\/p>\n<p>break<\/p>\n<p>end<\/p>\n<p>waitfor delay &#8217;00:00:10&#8242;<\/p>\n<p>set @count = @count &#8211; 1<\/p>\n<p>end<\/p>\n<p>end<\/p>\n<p>end try<\/p>\n<p>begin catch<\/p>\n<p>&#8212; If the wait loop fails, do not stop execution of the alter database statement<\/p>\n<p>end catch<\/p>\n<p>ALTER DATABASE [HR] SET HADR AVAILABILITY GROUP = [HR_AG];<\/p>\n<p>GO<\/p>\n<p>GO<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Index Contents Introduction 2 List of acronyms used in this document: 2 Explanation 2 A brief explanation of what BADR is and why we use it: 2 Limitations 3 Prerequisites for setting up BADR 4 Now we need to do the actual Basic Availability Setup 4 Step 1: Enable Always On in all participating instances [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,12,5,6],"tags":[],"class_list":["post-195","post","type-post","status-publish","format-standard","hentry","category-database","category-operating-system","category-programming","category-services"],"_links":{"self":[{"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/comments?post=195"}],"version-history":[{"count":1,"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/posts\/195\/revisions"}],"predecessor-version":[{"id":226,"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/posts\/195\/revisions\/226"}],"wp:attachment":[{"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/media?parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/categories?post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arturicast.co.za\/blogs\/wp-json\/wp\/v2\/tags?post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}