Distributed Availability Groups

Slides:



Advertisements
Similar presentations
Implementing SQLServer AlwaysON Sarabpreet Singh Anand SQL Server – MVP SQLServerGeeks.com (VP)
Advertisements

SharePoint 2013 & SQL Server 2012 Availability Groups The Rough Guide.
0 SQL Server AlwaysOn – SharePoint 2013 High Availability and Disaster Recovery Sal Bawany, Solutions Architect
Virtual techdays INDIA │ September 2011 High Availability - A Story from Past to Future Balmukund Lakhani │ Technical Lead – SQL Support, Microsoft.
Denny Cherry twitter.com/mrdenny.
SQL Server 2012 Always On Premier Field Engineer Microsoft Corporation Lisa Gardner
SQL Server AlwaysOn: Active Secondaries Luis Vargas Program Manager Microsoft Corporation DBI312.
Chapter 10 : Designing a SQL Server 2005 Solution for High Availability MCITP Administrator: Microsoft SQL Server 2005 Database Server Infrastructure Design.
High-Availability Methods Lesson 25. Skills Matrix.
SQL-Server 2012 Always On.
IT Pro Day SQL Server 2012 AllwaysOn Stephan Hurni Microsoft V-TSP Principal Consultant, Trivadis AG
It is one of the techniques to create a stand by server. Introduced in SQL 2000,enhanced in It is a High Availability as well as Disaster recovery.
Maintaining a Mirrored Database Tips and Tricks by Paul G. Hiles.
SQLintersection SQL37 SQL Server 2012 Availability Groups: High Availability for Your Most Important Data Aaron Bertrand,
DATABASE MIRRORING  Mirroring is mainly implemented for increasing the database availability.  Is configured on a Database level.  Mainly involves two.
SQLCAT: SQL Server 2012 AlwaysOn Lessons Learned from Early Customer Deployments Sanjay Mishra Program Manager Microsoft Corporation DBI360.
Unified solution Easy to configure, manage, and monitor Reuse existing investments SAN/DAS environments Allow using HA hardware resources Fast seamless.
SQLCAT: SQL Server HA and DR Design Patterns, Architectures, and Best Practices Using Microsoft SQL Server 2012 AlwaysOn Sanjay Mishra Program Manager.
Speaker Name 00/00/2013. Solution Requirements.
1© Copyright 2012 EMC Corporation. All rights reserved. EMC VNX5700, EMC FAST Cache, SQL Server AlwaysOn Availability Groups Strategic Solutions Engineering.
Alwayson Availability Groups
Course Topics Administering SQL Server 2012 Jump Start 01 | Install and Configure SQL Server04 | Manage Data 02 | Maintain Instances and Databases05 |
Warwick Rudd – Henry Rooney – How Available is SQL Server 2016? DAT33 6.
SQL Server 2012: AlwaysOn HA and DR Design Patterns, and Lessons Learned from Early Customer Deployments Sanjay Mishra SQLCAT.
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
Narasimha Reddy Gopu Jisha J. Agenda Introduction to AlwaysOn * AlwaysOn Availability Groups (AG) & Listener * AlwaysOn Failover * AlwaysOn Active Secondaries.
Windows Server Failover Clustering with SQL Server.
SQL Server 2014 AlwaysOn Step-by-Step SQL Server 2014 AlwaysOn Step-by-Step A hands on look at implementing AlwaysOn in SQL Server 2014.
What HADR Option(s) Are Right For You?. Where’s The AlwaysOn?
SQL Server High Availability Introduction to SQL Server high availability solutions.
All the things you need to know before setting up AlwaysOn Michael Steineke SQL & BI Solution Lead Enterprise Architect Concurrency, Inc.
Windows Server Failover Clustering (WSFC) with SQL Server.
AlwaysOn In SQL Server 2012 Fadi Abdulwahab – SharePoint Administrator - 4/2013
FUN WITH AVAILABILITY GROUPS Christopher Wolff SQL Server Database Engineer, Xero.
Redmond Protocols Plugfest 2016 Kevin Farlee Senior Program Manager SQL Server AlwaysOn in SQL Server 2016.
SQL 2012 – Always On Deep Dive Bob Duffy Database Architect Prodata SQL Centre of Excellence 11 th April 2013.
ALWAYSON AVAILABILITY GROUPS Replicas, Listeners & Quorums, Oh My! Kevin Howell SQL Saturday #517 Philadelphia, June 2016.
Sponsors.
SQL Server AlwaysOn Availability Groups DrillDown
Welcome to SharePoint Saturday Houston
SQL Server 2012 AlwaysOn and SQLSentry
ALWAYSON AVAILABILITY GROUPS
Navigating the options for Data Redundancy
Disaster Recovery Where to Begin
Always On Availability Groups
Always on HA SQL Server Always ON feature is the new comprehensive high availability and disaster recovery solution which increases application availability.
TOP 10 Availability Groups Improvement in SQL 2016
Contained DB? Did it do something wrong?
SQL AlwaysOn Availability Groups
AlwaysOn, an Early bird Overview
AlwaysOn Availability Groups 101
Disaster Recovery Where to Begin
How to keep your database servers out of the news Matt Gordon
Safety of information systems Fault-tolerant systems
What’s new in SQL Server 2016 Availability Groups
Example of a page header
SYED SAJID WASIM SQL SERVER ALWAYS ON Step by Step.
SQL Server on Linux: High Availability And Disaster Recovery
Distributed Availability Groups
AlwaysOn Availability Groups
High Availability/Disaster Recovery Solution
Distributed Availability Groups
04 | Always On High Availability
Using Distributed AGs for Your Migrations
Distributed Availability Groups
Using Distributed AGs for Your Migrations
Distributed Availability Groups Praveen Kumar. What we will cover Availability group refresher The HA/DR solution Distributed availability groups – what.
SQL AlwaysOn Availability Groups
Designing Database Solutions for SQL Server
Presentation transcript:

Distributed Availability Groups Jennifer Brocato jbrocatosql@gmail.com SQLSaturday#845 Atlanta Distributed Availability Groups

About Me Lead DBA for a fortune 50 transportation company 30 years experience with Enterprise Development Worked with SQL Server since 2000 My article on SQLServerCentral.com on SQLDAG

What we will cover Availability group refresher The HA/DR solution VM AlwaysOn Architecture Distributed availability groups – what is it? Configuring a SQLDAG solution Failover a SQLDAG Monitoring and health

Availability Groups Refresher Requires a Windows Server Failover Clustering (WSFC) cluster. An instance of SQL Server must reside on a WSFC node Each availability replica of a given availability group must reside on a different node of the same WSFC cluster. Relies on WSFC to monitor and manage the current roles of the availability replicas Overall health is based on all nodes in the cluster Quorum configuration – node and disk majority/file share sys.dm_hadr_cluster sys.dm_hadr_cluster_members

Example Configuration (GEO Cluster)

Configuring Quorum

Availability Group Basics Contains one or more databases Database must be in Full Recovery Model One Unit of Failover SQL Server Agent Jobs, Logins, Linked Servers do not fail over Create Availability Groups then add database

Feature Comparison Standard Edition (basic AG) Enterprise Edition (advanced AG) 2 Replicas – Primary and Secondary 9 replicas – Primary and 8 Secondaries No readable secondary 8 readable secondaries Synchronous/Asynchronous 3 Synchronous (SQL 2016, 2017) 5 Synchronous (SQL 2019) 1 Availability Database Unlimited No secondary backup Secondary backup No distributed availability group Distributed availability group Basic AG simulates mirroring CREATE AVAILABILITY GROUP WITH BASIC

Thread Usage By Availability Groups Single threaded based on database ID. Multiple replicas on an instance share a thread pool (3-10 threads) Uses up to 100 threads for parallel redo, if exceeds then goes to single redo thread Each database uses ½ total number of cores, max 16 per database

Thread Usage By Availability Groups Each primary database uses 1 unshared Log Capture thread Each secondary database uses 1 Log Send thread

Primary Replica with 4 Secondaries 2012 support max 4 secondary replicas, 2016 supports up to 8 (one primary and 2 sych secondarys)

Configuring the HA/DR Solution Purpose: Recovery time in same location Separate location in the event of failure WSFC Setup Cluster Validation; Quorum; Install stand-alone or failover cluster instance Enable AlwaysOn Availability Group for each SQL Server Service

Enable AlwaysOn

Creating the HA/DR Solution Add service account login and grant connect to SQL Create endpoint Create availability group Join availability group Create database or restore to primary instance Create full/log backup Restore full/log backup to each secondary Join database to availability group USE [master] GO CREATE LOGIN [US\DataCtrSQLSvc] FROM WINDOWS WITH DEFAULT_DATABASE=[master] use [master] GRANT CONNECT SQL TO [US\DataCtrSQLSvc] --Use AES encryption, RC4 is deprecated CREATE ENDPOINT [hadr_endpoint] STATE=STARTED AS TCP (LISTENER_PORT = 5022, LISTENER_IP = ALL) FOR DATA_MIRRORING (ROLE = ALL, AUTHENTICATION = WINDOWS NEGOTIATE , ENCRYPTION = REQUIRED ALGORITHM AES) GRANT CONNECT ON ENDPOINT::[hadr_endpoint] TO [US\DataCtrSQLSvc]

VM AlwaysOn Architecture Location A ESX Host Cluster 1 SQL VM1 SQL VM2 ESX Host Cluster 2 SQL AlwaysOn Distributed Availability Group Location B ESX Host Cluster 1 SQL VM3 SQL VM4 ESX Host Cluster 2 SQL AlwaysOn

SQL Distributed Availability Group (SQLDAG) One of the new features in SQL2016 is the ability to distribute availability groups across clusters. This solution makes high availability and disaster recovery geographically dispersed. Distributed Availability Groups allows you to associate availability groups on two different Windows Server Failover Clusters.

SQL Distributed Availability Group Two or more clusters Mix of standalone and FCIs Secondary cluster only knows that it is a secondary and does not know which is primary (DMV is coming for visibility with this) No GUI No Alerts USE [master] GO CREATE LOGIN [US\DataCtrSQLSvc] FROM WINDOWS WITH DEFAULT_DATABASE=[master] use [master] GRANT CONNECT SQL TO [US\DataCtrSQLSvc] --Use AES encryption, RC4 is deprecated CREATE ENDPOINT [hadr_endpoint] STATE=STARTED AS TCP (LISTENER_PORT = 5022, LISTENER_IP = ALL) FOR DATA_MIRRORING (ROLE = ALL, AUTHENTICATION = WINDOWS NEGOTIATE , ENCRYPTION = REQUIRED ALGORITHM AES) GRANT CONNECT ON ENDPOINT::[hadr_endpoint] TO [US\DataCtrSQLSvc]

Terminology Primary Cluster Primary Instance Secondary Cluster Secondary Cluster Primary Instance Secondary Instance

Creating the HA/DR Solution using SQLDAG (…continued) Add service account login and grant connect to SQL Create endpoints on all instances Create availability group on primary cluster Join availability group on primary cluster (may contain just one replica) Create availability group on secondary (primary instance) cluster Create database or restore to primary instance Create full/log backup Restore full/log backup to each secondary including secondary cluster(s) USE [master] GO CREATE LOGIN [US\DataCtrSQLSvc] FROM WINDOWS WITH DEFAULT_DATABASE=[master] use [master] GRANT CONNECT SQL TO [US\DataCtrSQLSvc] --Use AES encryption, RC4 is deprecated CREATE ENDPOINT [hadr_endpoint] STATE=STARTED AS TCP (LISTENER_PORT = 5022, LISTENER_IP = ALL) FOR DATA_MIRRORING (ROLE = ALL, AUTHENTICATION = WINDOWS NEGOTIATE , ENCRYPTION = REQUIRED ALGORITHM AES) GRANT CONNECT ON ENDPOINT::[hadr_endpoint] TO [US\DataCtrSQLSvc] ALTER AVAILABILITY GROUP AG_1 GRANT CREATE ANY DATABASE (for automatic seeding)

Now for the FUN PART! WITH (DISTRIBUTED) Go to the Primary Cluster Primary Instance and create SQLDAG CREATE AVAILABILITY GROUP [distributedag] WITH (DISTRIBUTED) AVAILABILITY GROUP ON 'AG_1' WITH ( LISTENER_URL = 'tcp://<virtualname>:5022', --Use listener name when there is a standalone AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT, FAILOVER_MODE = MANUAL ), 'AG_2' WITH LISTENER_URL = 'tcp://<virtualname>:5022', --Use SQLVNN not listener name when there is an FCI --check port to make sure it is 5022/5023/5024 etc ); GO USE [master] GO CREATE LOGIN [US\DataCtrSQLSvc] FROM WINDOWS WITH DEFAULT_DATABASE=[master] use [master] GRANT CONNECT SQL TO [US\DataCtrSQLSvc] --Use AES encryption, RC4 is deprecated CREATE ENDPOINT [hadr_endpoint] STATE=STARTED AS TCP (LISTENER_PORT = 5022, LISTENER_IP = ALL) FOR DATA_MIRRORING (ROLE = ALL, AUTHENTICATION = WINDOWS NEGOTIATE , ENCRYPTION = REQUIRED ALGORITHM AES) GRANT CONNECT ON ENDPOINT::[hadr_endpoint] TO [US\DataCtrSQLSvc]

Now for the FUN PART…again! Go to the Secondary Cluster Primary Instance and join SQLDAG CREATE AVAILABILITY GROUP [distributedag] JOIN AVAILABILITY GROUP ON 'AG_1' WITH ( LISTENER_URL = 'tcp://<virtualname>:5022', --Use listener name when there is a standalone AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT, FAILOVER_MODE = MANUAL ), 'AG_2' WITH LISTENER_URL = 'tcp://<virtualname>:5022', --Use SQLVNN not listener name when there is an FCI --check port to make sure it is 5022/5023/5024 etc ); GO USE [master] GO CREATE LOGIN [US\DataCtrSQLSvc] FROM WINDOWS WITH DEFAULT_DATABASE=[master] use [master] GRANT CONNECT SQL TO [US\DataCtrSQLSvc] --Use AES encryption, RC4 is deprecated CREATE ENDPOINT [hadr_endpoint] STATE=STARTED AS TCP (LISTENER_PORT = 5022, LISTENER_IP = ALL) FOR DATA_MIRRORING (ROLE = ALL, AUTHENTICATION = WINDOWS NEGOTIATE , ENCRYPTION = REQUIRED ALGORITHM AES) GRANT CONNECT ON ENDPOINT::[hadr_endpoint] TO [US\DataCtrSQLSvc]

Now Let’s Get Synchronized ALTER DATABASE D000DB1 SET HADR AVAILABILITY GROUP = xxxx Then WAIT…. Check the health of the distributed availability group to see if all replicas are synchronizing select r.replica_server_name, r.endpoint_url, rs.connected_state_desc, rs.last_connect_error_description, rs.last_connect_error_number, rs.last_connect_error_timestamp from sys.dm_hadr_availability_replica_states rs join sys.availability_replicas r on rs.replica_id=r.replica_id where rs.is_local=1 There is no GUI for SQLDAG so you will need to rely on DMVs USE [master] GO CREATE LOGIN [US\DataCtrSQLSvc] FROM WINDOWS WITH DEFAULT_DATABASE=[master] use [master] GRANT CONNECT SQL TO [US\DataCtrSQLSvc] --Use AES encryption, RC4 is deprecated CREATE ENDPOINT [hadr_endpoint] STATE=STARTED AS TCP (LISTENER_PORT = 5022, LISTENER_IP = ALL) FOR DATA_MIRRORING (ROLE = ALL, AUTHENTICATION = WINDOWS NEGOTIATE , ENCRYPTION = REQUIRED ALGORITHM AES) GRANT CONNECT ON ENDPOINT::[hadr_endpoint] TO [US\DataCtrSQLSvc] ALTER AVAILABILITY GROUP AG_1 GRANT CREATE ANY DATABASE (for automatic seeding)

Demo 3 - AG to DAG to Create DB.mp4 4 - Establish Replication.mp4 5 - Replication the Right Way.mp4 6 - Test.mp4 USE [master] GO CREATE LOGIN [US\DataCtrSQLSvc] FROM WINDOWS WITH DEFAULT_DATABASE=[master] use [master] GRANT CONNECT SQL TO [US\DataCtrSQLSvc] --Use AES encryption, RC4 is deprecated CREATE ENDPOINT [hadr_endpoint] STATE=STARTED AS TCP (LISTENER_PORT = 5022, LISTENER_IP = ALL) FOR DATA_MIRRORING (ROLE = ALL, AUTHENTICATION = WINDOWS NEGOTIATE , ENCRYPTION = REQUIRED ALGORITHM AES) GRANT CONNECT ON ENDPOINT::[hadr_endpoint] TO [US\DataCtrSQLSvc] ALTER AVAILABILITY GROUP AG_1 GRANT CREATE ANY DATABASE (for automatic seeding)

Gathering Information About Availability Groups dm_hadr_automatic_seeding dm_hadr_physical_seeding_stats dm_hadr_availability_replica_cluster_nodes dm_hadr_availability_group_states dm_hadr_availability_replica_states USE [master] GO CREATE LOGIN [US\DataCtrSQLSvc] FROM WINDOWS WITH DEFAULT_DATABASE=[master] use [master] GRANT CONNECT SQL TO [US\DataCtrSQLSvc] --Use AES encryption, RC4 is deprecated CREATE ENDPOINT [hadr_endpoint] STATE=STARTED AS TCP (LISTENER_PORT = 5022, LISTENER_IP = ALL) FOR DATA_MIRRORING (ROLE = ALL, AUTHENTICATION = WINDOWS NEGOTIATE , ENCRYPTION = REQUIRED ALGORITHM AES) GRANT CONNECT ON ENDPOINT::[hadr_endpoint] TO [US\DataCtrSQLSvc] ALTER AVAILABILITY GROUP AG_1 GRANT CREATE ANY DATABASE (for automatic seeding)

Manual Failover of SQLDAG ALTER AVAILABILITY GROUP of SQLDAG (secondary cluster) to SYNCHRONOUS_COMMIT Verify from dm_hadr_database_replica_states that status is SYNCHRONIZED and end_of_log_lsn matches from primarys in both clusters On instance that hosts primary SQLDAG, set SQLDAG role to Secondary ALTER AVAILABILITY GROUP xxx SET (ROLE = SECONDARY) At this point the SQLDAG is unavailable Verify again readiness to failover Issue failover – ALTER AVAILABILITY GROUP xxx FORCE_FAILOVER_ALLOW_DATA_LOSS After this step the SQLDAG is available again Set SQLDAG back to ASYNCHRONOUS_COMMIT USE [master] GO CREATE LOGIN [US\DataCtrSQLSvc] FROM WINDOWS WITH DEFAULT_DATABASE=[master] use [master] GRANT CONNECT SQL TO [US\DataCtrSQLSvc] --Use AES encryption, RC4 is deprecated CREATE ENDPOINT [hadr_endpoint] STATE=STARTED AS TCP (LISTENER_PORT = 5022, LISTENER_IP = ALL) FOR DATA_MIRRORING (ROLE = ALL, AUTHENTICATION = WINDOWS NEGOTIATE , ENCRYPTION = REQUIRED ALGORITHM AES) GRANT CONNECT ON ENDPOINT::[hadr_endpoint] TO [US\DataCtrSQLSvc] ALTER AVAILABILITY GROUP AG_1 GRANT CREATE ANY DATABASE (for automatic seeding)

Configuration Example 2 sets of clustered VMs Availability group in each VM cluster Automatic Failover Synchronous Distributed availability group between each cluster set ESX host cluster A in data center 1 ESX host cluster B in data center 1 ESX host cluster C in data center 2 ESX host cluster D in data center 2 VM1 on ESX host cluster A VM2 on ESX host cluster B VM3 on ESX host cluster C VM4 on ESX host cluster D Cluster VM1 and VM2 – Cluster X Cluster VM3 and VM4 – Cluster Y VM1 and VM2 set up with AG with automatic failover and synchronous VM3 and VM4 set up with AG with automatic failover and synchronous SQLDAG between cluster X and cluster Y

Monitor SQLDAG Replication Health State SELECT * FROM (SELECT… FROM sys.availability_replicas r LEFT JOIN sys.availability_groups ds ON r.group_id = ds.group_id WHERE ds.name = '<AGName>' ) a inner join ( SELECT … FROM sys.availability_groups ag JOIN sys.dm_hadr_availability_group_states as ags ON ag.group_id=ags.group_id LEFT JOIN sys.dm_hadr_database_replica_states ds ON ds.group_id = ag.group_id ) b ON b.availability_group = a.replica_server_name select CAST(r.replica_id as VARCHAR(36)) as replica_id, CAST(r.group_id as VARCHAR(36)) as group_id, replica_server_name, endpoint_url, ISNULL(ds.is_distributed,0) as is_distributed, ds.name from sys.availability_replicas r left join sys.availability_groups ds on r.group_id = ds.group_id where ds.name = '<AGName>' ) a inner join ( select availability_group=cast(ag.name as varchar(30)), primary_replica=cast(ags.primary_replica as varchar(30)), primary_recovery_health_desc=cast(ags.primary_recovery_health_desc as varchar(30)), synchronization_health_desc=cast(ags.synchronization_health_desc as varchar(30)), CAST(ag.group_id as VARCHAR(36)) as group_id , CAST(ag.resource_id as VARCHAR(36)) as resource_id, CAST(ag.resource_group_id as VARCHAR(36)) as resource_group_id, ag.failure_condition_level, ag.health_check_timeout, ag.is_distributed, ds.recovery_lsn, ds.truncation_lsn, CAST(ISNULL(ds.last_sent_lsn,0) AS VARCHAR) last_sent_lsn, ISNULL(ds.last_sent_time,0) as last_sent_time, CAST(ISNULL(ds.last_received_lsn,0) AS VARCHAR) as last_received_lsn, ISNULL(ds.last_received_time,0) as last_received_time, CAST(ISNULL(ds.last_hardened_lsn,0) AS VARCHAR) as last_hardened_lsn, ISNULL(ds.last_hardened_time,0) as last_hardened_time, ds.last_redone_lsn, ds.last_redone_time, ds.log_send_queue_size, CAST(ISNULL(ds.log_send_rate,0) AS VARCHAR) as log_send_rate, ds.redo_queue_size, CAST(ISNULL(ds.redo_rate,0) AS VARCHAR) as redo_rate, CAST(ds.end_of_log_lsn AS VARCHAR) as end_of_log_lsn, CAST(ds.last_commit_lsn AS VARCHAR) as last_commit_lsn, ds.last_commit_time, automated_backup_preference_desc=cast(ag.automated_backup_preference_desc as varchar(10)) from sys.availability_groups ag join sys.dm_hadr_availability_group_states ags on ag.group_id=ags.group_id left join sys.dm_hadr_database_replica_states ds on ds.group_id = ag.group_id ) b on b.availability_group = a.replica_server_name

Health State Metric Collection timestamp, LSN information and Health State

Health State LSN Hardened, RedoRate, LSN Commit.

Alert on Unhealthy SQLDAG State Record health state with query in a set interval using a job (5 minutes is a suggestion). Use a job to check latest health state in comparison to prior health state Repeated unhealthy SQLDAG replication to trigger alerting mechanism (such as email).

Read-Scale Availability Groups Does not depend on any clustering technology Not for HA or DR, just for synchronization, no WSFC Single SQLDAG can have up to 17 readable secondaries. Availability group syntax: CLUSTER_TYPE = NONE

Worth Mentioning SQL2017 Read-scale availability groups Not for HA or DR, just for synchronization, no WSFC The official abbreviation for distributed availability groups is not DAG. DAG is used for Exchange Database Availability Groups. Automatic Seeding – folder structure matters

Questions

Thank You