SQL Server 2016 Step by Step: Creating AlwaysOn Availability Group
Always On Availability Groups is an enterprise-level high-availability and disaster recovery solution introduced in SQL Server 2012 to enable you to maximize availability for one or more user databases. Always On Availability Groups requires that the SQL Server instances reside on Windows Server Failover Clustering (WSFC) nodes.
Prerequisites:
- Ensure that the system is not a domain controller.
- Ensure that each computer is running Windows Server 2012 or later versions.
- Ensure that each computer is a node in a Windows Server Failover Clustering (WSFC) cluster.
This environment:
OS - Windows 2012 R2
SQL Server - SQL Server 2016 Enterprise Edition (Eval)
SQL Server Installation
AlWays on availability group requires the standard installation, "New SQL Server stand-alone installation..." follow the instructions and Click Next, Next, Next, Install
Failover Cluster Installation
First, we need to add the Windows Failover Cluster Feature to all the nodes running the SQL Server instances that we will configure as replicas.
Open the Server Manager => select Add roles and features.
https://2.bp.blogspot.com/-HdDIplYnIGM/V-OwZGqfNUI/AAAAAAAABdw/4bQb91BmS6cA-zZc8yu0GBcIKbyfGdAlgCLcB/s640/ServerManagerFailoverclusterrole1.png
Click Next till Select Features dialog box.
https://2.bp.blogspot.com/-wrWve9yNc98/V-OzuAFT2HI/AAAAAAAABeA/OqDnUcqUoQI3X3m-o0em2Y3VQp33htCVQCLcB/s640/ServerManagerFailoverclusterrole2.png
https://4.bp.blogspot.com/-YU4GoYx4aaY/V-OzuOIYugI/AAAAAAAABeI/riaSlvHpD3gXdNXYWEtL2-yyhQwF-ZCAACLcB/s640/ServerManagerFailoverclusterrole3.png
https://4.bp.blogspot.com/-UCuFzkkyU7I/V-OzuI8j8rI/AAAAAAAABeE/6LPoGVhg9AQnjJEXV2WJbfz_G7TyDncyQCLcB/s640/ServerManagerFailoverclusterrole4.png
Select the Failover Clustering checkbox
https://4.bp.blogspot.com/-TL8pn5G5DHg/V-OzuV8n1HI/AAAAAAAABeM/8GCOgQMAfTQNTbI_rT1VSiYr08GeoulvACLcB/s640/ServerManagerFailoverclusterrole5.png
Click Install to install the Failover Clustering feature.
https://3.bp.blogspot.com/-dvNd9FSi0LM/V-OzurCVy8I/AAAAAAAABeQ/9iJwP2wMusouC8d42EKbYVc3ens5mop_QCLcB/s640/ServerManagerFailoverclusterrole6.png
Windows Failover Clustering Configuration for Always On Availability Groups
Open Server Manager and select "Fail over Cluster Manager".
https://1.bp.blogspot.com/-4tGav4EMy8w/V-O01h-71_I/AAAAAAAABek/bIZrOUXPEBoIyJrnA8LwnsRYyDpj1yLxgCLcB/s640/ServerManagerFailoverclusterManager.png
Select Failover Cluster Manager and select the Option Create Cluster OR You can right-click on the Failover Cluster Manager and select Create Cluster menu.
https://1.bp.blogspot.com/-cF8jRT_0QnE/V-O_UCKSwSI/AAAAAAAABfM/7K9cfL3TseYcf3BF8E9V2njyCqYD72B9wCLcB/s640/Failoverclustermanger%2Bcreate%2Bcluster2.png
You will Create Cluster Wizard
https://4.bp.blogspot.com/-dd_wnbXNuNA/V-O_USuxsmI/AAAAAAAABfY/v-pA715ZTao1vgpJcNfAUQUrU1oEzipJwCLcB/s640/create%2Bcluster%2Bwizard2.png
Add the Nodes you want be in the Cluster and then click Next
https://4.bp.blogspot.com/-IpvSXEuIvuI/V-O_USjPsiI/AAAAAAAABfc/lJxx-PkQ8oQT5M-tSJFK_n9onQujb8VSwCLcB/s640/create%2Bcluster%2Bwizard3.png
You will be getting a validation warning. Select Yes to Validate the Cluster nodes
https://2.bp.blogspot.com/-kt_C0atJysU/V-O_UmMCAbI/AAAAAAAABfg/4NPjxDqpAegcb7vcVs0iw4lnSV6NZc0NQCLcB/s640/create%2Bcluster%2Bwizard4.png
https://3.bp.blogspot.com/-lWPG5_7HthA/V-O_UvLgr1I/AAAAAAAABfk/SMP0PiJ58Fc6c-tqmcegyksGwBadM5DCQCLcB/s640/create%2Bcluster%2Bwizard5.png
Select the option Run all tests
https://4.bp.blogspot.com/-aSvdSN0wFSs/V-O_UsSa-RI/AAAAAAAABfo/hFAtqcVt5ZYKJzQHl-65JUTKcQEyv8vLQCLcB/s640/create%2Bcluster%2Bwizard6.png
https://3.bp.blogspot.com/-u3rAp8s2YNw/V-O_UyCHODI/AAAAAAAABfs/LXL35T5TaMMuiL4odo7oWR_CzXqLREpQACLcB/s640/create%2Bcluster%2Bwizard7.png
https://2.bp.blogspot.com/-EFqpPVHxOoo/V-PUH3YpTbI/AAAAAAAABgI/kfg7g_sdCbgLMjhe2--yDNQcyDLrFQX8ACLcB/s640/create%2Bcluster%2Bwizard8.png
**NOTE: **The Cluster Validation Wizard is expected to return several Warning messages, especially if you will not be using shared storage. Other than that if you find any error messages you need to fix them prior to creating the Windows Server Failover Cluster.
In the Access Point for Administering the Cluster dialog box, enter the Cluster name and virtual IP address for Windows Server Failover Cluster , then click Next.
https://4.bp.blogspot.com/-MxF7j8Ag61g/V-PXaS7_N1I/AAAAAAAABgc/0glaWPXBWGUUNblnnKAKERf_4AlVn7hiQCLcB/s640/create%2Bcluster%2Bwizard9.png
https://1.bp.blogspot.com/-mn5BB8KBp4Q/V-PXaZE1NNI/AAAAAAAABgY/QcMKRttctP8MPfsgUnpiBLun99WI7JaWwCLcB/s640/create%2Bcluster%2Bwizard10.png
Verify that the configuration is successful in Summary.
https://3.bp.blogspot.com/-LfI7PHjMkhM/V-PXaZJ_DYI/AAAAAAAABgU/uvViW4DUhsQ20bA7jOI65EAtptlXKwH7QCLcB/s640/create%2Bcluster%2Bwizard11.png
Configure Cluster Quorum Settings
Quorum is that it is a configuration database for the cluster and is stored on a shared location, accessible to all of the nodes in a cluster.
In Case of Even number of nodes (but not a multi-site cluster) Node and Disk Majority Quorum configuration is recommended. If you don't have a shared storage Node and File Share Majority is recommended. Here it will be configuring a FileShare Witness quorum.
It is recommended that you configure the quorum size to be 500 MB. This size is the minimum required for an efficient NTFS partition. Larger sizes are allowable but are not currently needed.
Click on Your Cluster Select Configure Cluster Quorum Setting from the More action menu.
https://3.bp.blogspot.com/-Dpw23kKzJ4k/V-PZifP_KFI/AAAAAAAABg4/3INPB5W2usYFXl4xIf3Pezr3iVh49SpuACLcB/s640/configure%2Bquorum%2Bsettings1.png
https://1.bp.blogspot.com/-7BcObXcJF_k/V-PZiemrC6I/AAAAAAAABg0/y4JRMIv6SfQDS21j_Q74b7nfM616ncZ4gCLcB/s640/configure%2Bquorum%2Bsettings2.png
https://4.bp.blogspot.com/-25GUTaGYqEI/V-PZiWqEZgI/AAAAAAAABg8/xVMbKs2eW8wUGsLAAFED5hRwNOjUu-JVQCLcB/s640/configure%2Bquorum%2Bsettings3.png
In the Select Quorum Witness page, select the Configure a file share witness option. Click Next.
https://3.bp.blogspot.com/-GvYsJ84LYmc/V-PZit3fAtI/AAAAAAAABhA/ma551AGNwS82-d5MdLcg726oQWG4-3O3ACLcB/s1600/configure%2Bquorum%2Bsettings4.png
Type the path of the file share that you want to use in the File Share Path: text box. Click Next.
It is recommended to have the share folder on a different node than the node participating on Cluster
https://4.bp.blogspot.com/-pVn8Gv7vOlk/V-PZiqur81I/AAAAAAAABhE/IpMyBGzqONk0BJtTipykCoD_2GhuuTeaQCLcB/s640/configure%2Bquorum%2Bsettings5.png
https://4.bp.blogspot.com/-thpYKZqvu5M/V-PZi0EzXeI/AAAAAAAABhI/9rlWZdftOkI6cQ9mYOc2eqTp-7Q86fAJgCLcB/s640/configure%2Bquorum%2Bsettings6.png
In the Confirmation page, click Next.
https://2.bp.blogspot.com/-2MZMo8J8VcI/V-PZiykYl2I/AAAAAAAABhM/820xCMwEdacYvUhp4zSRPS-DDNgo01fwgCLcB/s640/configure%2Bquorum%2Bsettings7.png
In the Summary page, click Finish.
https://1.bp.blogspot.com/-7HgnOgErfKU/V-PZjJWYkgI/AAAAAAAABhQ/S17do7BBofoI5btmgqicNb0kgDMpnKNSwCLcB/s640/configure%2Bquorum%2Bsettings8.png
Enable AlwaysOn Availability Groups Feature on SQL Server 2016
We can now proceed with enabling the AlwaysOn Availability Groups feature in SQL Server 2016. This is possible after install and configuring the Windows Failover Cluster on all the nodes.
Open SQL Server Configuration Manager - > SQL Server Properties - [SQL Server (SQLAG01)]
In the Properties dialog box, select the AlwaysOn High Availability tab. Check the Enable AlwaysOn Availability Groups check box. This will prompt you to restart the SQL Server service. Click OK.
Restart the SQL Server service.
https://1.bp.blogspot.com/-f8FatAEM_dM/V-PdlCeDW5I/AAAAAAAABho/0lu1iC4NvaIO2uZaPq6DuDznmP5W78K0ACLcB/s640/Configuration%2BManager.png
Configure SQL Server 2016 AlwaysOn Availability Groups
Go to Management Studio, right click Availability Groups and click New Availability Group Wizard.
https://1.bp.blogspot.com/-6Sn_zkFHj-o/V-dXu04mLfI/AAAAAAAABiM/_AviRaKBW8k_tAkPXs73QQkjgqy_0gKswCLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup1.png
https://2.bp.blogspot.com/-uzf_ZZ-Ks6Q/V-dXvTsnc9I/AAAAAAAABic/SzjujSjpcp8ExXV5-dbi6Ez8Nk3fNKY8QCLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup2.png
Specify Availability Group Name . This group name is SQLAVG2016. Then click Next.
https://2.bp.blogspot.com/-2kafMOMGSYM/V-dXvUDX3RI/AAAAAAAABig/VTwrVAHbKsU166_dmoZne0WSEdYhmUukACLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup3.png
Choose Database
Here you can see whether the DB meets the prerequisites
- Database should be in full recovery mode.
- You should make a full backup to add the DB into the Availability Group
https://2.bp.blogspot.com/-9hwbyyG1kSo/V-dXvj2qPlI/AAAAAAAABik/j9xORB4nJqwA1rtG8eOVHfK-87Mig_XJgCLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup4.png
Specify Replicas
This page applies to the New Availability Group Wizard and the Add Replica to Availability Group Wizard of SQL Server 2016.
If a server instance that you to use to host a secondary replica is not listed by the Availability Replicas grid, click the Add Replica button.
Add Azure Replica button to create virtual machines with secondary replicas in Windows Azure.
https://3.bp.blogspot.com/-Il6MhNkPLSQ/V-dXvqnCkAI/AAAAAAAABio/cleuXFyxSC4K7fulxrm4w7tGKCl0qN6cgCLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup5.png
Adding Secondary Replica
https://2.bp.blogspot.com/-hDWjAR8ox14/V-dXvnOdszI/AAAAAAAABis/BqpHXI7fuXc9GUqPjAMkReXfw8cmhQ78wCLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup6.png
https://4.bp.blogspot.com/-IeSkiZxtrxo/V-dXv7343MI/AAAAAAAABiw/jtYVeizvF_AlHEoZstLfbMNa8CIuDFRHQCLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup7.png
https://3.bp.blogspot.com/-B66pbpGCeE4/V-dXvyk80JI/AAAAAAAABi0/jRa5Baj9oxQFuLQ-Jbv2yNthpPzSiEYTQCLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup8.png
Endpoints
Use this tab to verify any existing database mirroring endpoints and also, if this endpoint is lacking on a server instance whose service accounts use Windows Authentication, create the endpoint automatically.
https://4.bp.blogspot.com/-4hzNtjx4EdU/V-dXu1PbjaI/AAAAAAAABiI/qcjYvNvcr0IH5mnD2b1PeuQHwVGjxFT8ACLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup11.png
Backup Preference
Use this tab to specify your backup preference for the availability group as a whole and your backup priorities for the individual availability replicas.
https://1.bp.blogspot.com/-Xm9PU_DbjWU/V-dXv5M2SPI/AAAAAAAABi4/S5bCMh0-l4U6Ff7Y9AL-sLR5aqgrIGtzACLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup9.png
Listener
An availability group listener is a virtual network name (VNN) to which clients can connect in order to access a database in a primary or secondary replica of an AlwaysOn availability group. You point applications to the listener (which is registered with DNS) and directs traffic in the AG.
https://1.bp.blogspot.com/-B2jY153Wqtg/V-dXuxANqXI/AAAAAAAABiQ/ZSI_e3-UNqoMK_vwNs2QFDqM4qX1WWKFgCLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup10.png
Select Data Synchronization
Use the Always On Select Initial Data Synchronization page to indicate your preference for initial data synchronization of new secondary databases. This page is shared by three wizards—the New Availability Group Wizard, the Add Replica to Availability Group Wizard, and the Add Database to Availability Group Wizard.
The possible choices include Full, Join only, or Skip initial data synchronization. Before you select Full or Join only ensure that your environment meets the prerequisites.
For each primary database, the Full option performs several operations in one workflow: create a full and log backup of the primary database, create the corresponding secondary databases by restoring these backups on every server instance that is hosting a secondary replica, and join each secondary database to availability group.
Select this option only if your environment meets the following prerequisites for using full initial data synchronization, and you want the wizard to automatically start data synchronization.
https://2.bp.blogspot.com/-5Egj1YDBSyc/V-dXvE-BAaI/AAAAAAAABiY/C1bzQ43jfBQohjSMlza2bgNptkcoOQuRwCLcB/s640/create%2Balways%2Bon%2Bavailability%2Bgroup13.png