SQLintersection
Wednesday November 1, 2017
3:00pm - 4:00pm
SQL SERVER 2016/2017 ALWAYSON AVAILABILITY
GROUPS: WINDOWS AND LINUX DEPLOYMENTS
David Pless
David.Pless@Microsoft.com
Overview
▪ Introduction
Planning and Deploying AlwaysOn Availability Groups
Readable Secondary Replicas and Database Maintenance
AlwaysOn Integration with Windows and Linux
Management and Monitoring of Availability Groups
SQL Server 2016 / 2017 Improvements and Features
▪ Technologies Covered
AlwaysOn Availability Groups
Azure Portal
Linux / Pacemaker
© SQLintersection. All rights reserved.
http://www.SQLintersection.com
Causes of Downtime and Data Loss
Planned Downtime
• Maintenance
• Upgrade
• Updates
• No data loss
Unplanned Downtime
• Datacenter failure
• Server failure
• I/O subsystem failure
• Human error
• Possible data loss
Understanding Disaster Recovery
Two Principle Requirements for HA and DR
▪ Recovery Time Objective (RTO) - The maximum allowable downtime
when a failure occurs
▪ Recovery Point Objective (RPO) - The maximum allowable data-loss
when a failure occurs
© SQLintersection. All rights reserved.
http://www.SQLintersection.com
Introduction to AlwaysOn Technologies
SQL Server AlwaysOn Solutions
Failover Cluster Instances (FCI) Availability Group (AG)
▪ Enhancements ▪ Introduced in SQL 2012
▪ Cloud Witness ▪ Multi-database failover
▪ Site Awareness ▪ Non Shared Storage
▪ Fault Domains ▪ Active Secondary Replicas
▪ SQL Server Instance Failover ▪ Failover takes less than 30s (secondary
▪ Shared Storage replicas are online)
▪ Passive Secondary Nodes ▪ New Features introduced in subsequent
▪ Failover takes 30s to couple of minutes SQL Server versions
(instance restart)
SQL Server AlwaysOn Solutions
a). Failover Cluster in Azure, b). Branch Office Clusters, c). Multi-site Clusters
Fault Domains have three benefits:
Storage Affinity in a Stretch Cluster
Ensures Cluster workload and storage are in the same location
Increases Storage Spaces resiliency
Enhanced Health Service Alerts include meta data about the location of the associated
resources raising the alarm
Overview of a Windows Server Windows Server 2016
allows you to create a
Failover Cluster cluster without a
Domain and a Witness
in Azure
Clients
DC
File Share Witness
The Windows Server
Cluster service
Public Network
maintains quorum and
is used to
Private communicate with the
Network nodes / replicas
Node 1 Node 2 Node 3 Node 4
Virtual Network
Fabric Switches Name
Optional Shared Storage
AlwaysOn Availability Groups and
Replicas
AlwaysOn Availability Groups
▪ Multi-database failover ▪ Application failover using virtual name ▪ Active Secondary
▪ Multiple secondaries ▪ Configuration Wizard ▪ Readable Secondary
▪ Total of 4 secondaries (8 with 2014+) ▪ AlwaysOn Management Dashboard ▪ Backup from Secondary
▪ 3 synchronous secondaries* ▪ System Center Integration ▪ Improves primary server performance
▪ 2 automatic failover pair** ▪ Rich diagnostic infrastructure by offloading work to secondary
▪ Synchronous and asynchronous ▪ File-stream replication ▪ Monitoring & Troubleshooting
enhanced
▪ Built in compression and encryption ▪ Replication publisher failover
▪ Automation using PowerShell
▪ Auto-page repair ▪ Read-only routing **
▪ Automatic & manual failover ▪ Guarantee commits on synchronous
▪ Flexible failover policy secondary replicas ¥
▪ Create an availability group w/o a ▪ Support for SQL Server on Linux ¥
cluster for read-scale workloads ¥
* New to SQL Server 2014 ¥ New to SQL Server 2017
** New to SQL Server 2016
AlwaysOn Availability Groups and Replicas
Windows Server Failover Cluster
A
Primary Secondary A Secondary A Secondary Secondary
A A
Replica Replica 1 Replica 2 Replica 3 Replica 8
….
AG1 AG1 AG1 AG1 AG1
Synchronous Data Movement
Asynchronous Data Movement
Enabling AlwaysOn Availability Groups
Use SQL Server Configuration Manager You must first install
failover clustering and
put the replicas in the
same cluster
Requires ‘Windows
Management
Instrumentation (ASync-In)’
or Enable-SQLAlwaysOn Windows PowerShell cmdlet Firewall rule to be enabled
Availability Groups in SQL Server 2014
▪ Increased Number of Secondaries
▪ SQL 2014 increased to 8 replicas
▪ Additional Diagnostic Capabilities (fn_hadr* function, cluster DMVs)
▪ Increased Readable Secondaries Availability
Reduced the events which caused the readable secondaries
to be unavailable
▪ Add Azure Replica Wizard
Simple end-to-end solution for deploying replicas to Azure VMs
First step to improved deployment experiences
Available via T-SQL, but currently removed from SSMS
© SQLintersection. All rights reserved.
http://www.SQLintersection.com
AlwaysOn Availability Group Availability Modes
Asynchronous-Commit
• Disaster-recovery solution
• Works well when replicas are distributed over considerable
distances
• Useful when performance is more important than synchronized
data protection
Synchronous-Commit
• High availability over performance at the cost of increased
transaction latency
Different ways to Create Availability Groups
SQL Server Management Studio
▪ Availability Group Wizard AlwaysOn_health
session may not be
▪ Availability Group Dialog Box automatically
started, If AG is not
created using the AG
T-SQL Wizard
PowerShell
22
Demo
AlwaysOn Availability Groups
© SQLintersection. All rights reserved.
http://www.SQLintersection.com
Flexible Failover Policy and Health Monitoring
▪ sp_server_diagnostics stored procedure called to perform a
health check of the primary replica
▪ Results at an interval that equals 1/3 of the health-check
timeout threshold
▪ Default health-check timeout threshold is 30 seconds
sp_server_diagnostics returns results at 10 second interval
sp_server_diagnostics
• Captures diagnostic data and health information about SQL Server to detect
potential failures
• Runs in repeat mode and sends results periodically
• Sample Result:
System,resource and
query_processing Health
leveraged for failure State
detection
io_subsystem and
5 events are leveraged
for diagnostic
Components purposes only
Failure Condition Levels
5 – Failover if any qualified
Query Processing errors
failure conditions
4 – Failover if moderate SQL
Resource errors
Server errors
3 – Failover if critical SQL
System errors
Server errors (Default)
2 – Failover if server is No response from
unresponsive sp_server_diagnostics
1 – Failover if server is down
Service is down
or lease timeout
Note: Damaged databases and suspect databases are not detected by any failure-condition level.
Therefore, a database that is damaged or suspect (whether due to a hardware failure, data corruption,
or other issue) never triggers an automatic failover.
Demo
AlwaysOn Availability Groups
© SQLintersection. All rights reserved.
http://www.SQLintersection.com
Dashboards, System Views,
Wait Statistics and Performance Monitor
Dashboard
Health
Open from events
primary
Quorum
information
Group
health
Replica
health
Hidden
columns
Database
health
System Views
• System catalog views
• View system configuration
• Dynamic Management Views (DMVs) and Functions
• View current state and health information
Performance Monitor
SQL Server: SQL Server: SQL Server:
Availability Replica Database Replica Databases
▪ Bytes Received from ▪ Log Send Queue ▪ Log Bytes
Replica/sec ▪ Transaction Delay Flushed/sec
▪ Bytes Sent to ▪ Mirrored Write
Replica/sec Transactions/sec
▪ Bytes Sent to ▪ Redone Bytes/sec
Transport/sec
Watch for HADR_
▪ Redo Bytes waits, Network
▪ Resent Messages/sec Remaining
Latency, WRITELOG,
▪ Redo Blocked/sec
and PAGEIOLATCH_
waits
Automated Health Monitoring using PowerShell
▪ Cmdlets to monitor health of an Availability Group
Test-SQLAvailabilityGroup
Test-SQLAvailabilityReplica
Test-SQLDatabaseReplicaState
Demo
AlwaysOn Availability Groups
© SQLintersection. All rights reserved.
http://www.SQLintersection.com
AlwaysOn Availability Groups
and Replicas
Availability Groups in SQL Server
Secondary
Secondary Replica 2 A Primary
A
Replica 3 Replica
A A
Secondary
A
Replica 4
Secondary A
Replica 1 Windows
Azure
Reports
Secondary
Replica 5
Reports
Reports
Asynchronous Movement A Primary Replica Backups
Synchronous Movement A Secondary Replica Reports
AlwaysOn AG Enhancements in SQL 2016
Load balancing for secondary
• Define a load balanced routing list (SSMS)
replicas
Increased Replicas for automatic • Now you can have 3 replicas
failover • Requires synchronous commit
Group Managed Service Accounts
• Managed service accounts that extend to multiple machines
are allowed for AG Clusters
Distributed Transactions are • Requires Windows Server 2016
Supported • Use the new WITH DTC_SUPPORT for the CREATE AG command (SSMS)
• Availability Groups have affectedly better performance over the
Improved log performance wire
Database Level Failover • If a DB goes offline you will be able to initiate failover for the AG
Basic Availability Group • An option for Standard Edition customers in SQL Server 2016
AlwaysOn AG Automatic Seeding
▪ Automatically create the database replica on the secondary server
▪ SQL Server performs a backup over the network for initialization
▪ Process can be slow if databases are very large, or the replica(s) are remote
▪ The transaction log for these databases cannot be truncated during the backup
process
▪ Create new or enable on an Existing AG
ALTER AVAILABILITY GROUP [<availability_group_name>]
Enable
MODIFY REPLICA ON '<primary_node>' WITH (SEEDING_MODE = AUTOMATIC)Trace Flag 9567
GO for data stream
▪ compression
Query sys.dm_hadr_automatic_seeding system view to monitor the seeding progress
SELECT start_time, completion_time, is_source, current_state,
failure_state, failure_state_desc, error_code
FROM sys.dm_hadr_automatic_seeding
AlwaysOn Availability Groups
and Replicas
What is Read-Only Routing?
▪ Facilitates automatic redirect of read workloads
▪ Increases availability for read workloads
▪ Minimizes contention on Primary Replica
▪ Requires Listener and ApplicationIntent property
Windows Server Failover Cluster
AA Secondary Replica
A Secondary Replica
Primary Replica Primary Replica
CRASH
Reports Reports
AG1 (DB1, DB2) AG1 (DB1, DB2)
Load Balancing in Readable Secondaries
▪ In SQL 2014, read-only transactions routed by the Listener, went to
the first secondary that was available.
▪ Read-only Routing lists
▪ Now you can configure the ROR lists to round-robin among a
specific set of secondaries. (for each primary)
▪ READ_ONLY_ROUTING_LIST =
((‘COMPUTER2’, ’COMPUTER3’, ’COMPUTER4’), ’COMPUTER5’)
Readable Secondary Load Balancing
DR Site READ_ONLY_ROUTING_LIST= Computer 2 Primary Site
(('COMPUTER2', 'COMPUTER3',
'COMPUTER4'), 'COMPUTER5')
Computer 1
Computer 5
(Primary)
Computer 3
Computer 4
Demo
Readable Routing & Reporting
with SQL Server 2016 Availability Groups
© SQLintersection. All rights reserved.
http://www.SQLintersection.com
Distributed Availability Groups
▪ Span geographically
dispersed sites
▪ DR Site does not impact
primary
▪ Secondary AG automatically
becomes ReadOnly
▪ Replicate between AGs once
▪ The Primary of AG1 sends to
Key Scenarios: the secondary of AG1 and
• Disaster recovery and multi-site scenarios the Primary of AG2
• Migrate by using a distributed availability group (forwarder)
• Scale out readable replicas with distributed ▪ Manual failover only
availability groups
Performance and Availability
What’s New in SQL Server 2017
▪ New CLUSTER_TYPE that identifies the type of server cluster manager
that manages an availability group. (WSFC, EXTERNAL, NONE)
▪ Guarantee commits on synchronous secondary replicas
▪ Read-scale availability groups for performance
▪ Cross database transactions are now supported among all databases
that are part of an Always On Availability Group
▪ Transaction log redo of memory-optimized tables is now executed in
parallel. This bolsters faster recovery times and significantly increases
the sustained throughput of AlwaysOn availability group configuration
▪ Improved Monitoring and Diagnostics
© SQLintersection. All rights reserved.
http://www.SQLintersection.com
AlwaysOn AGs on Linux Concepts
High-level Create Linux Cluster
Steps to
create an Configure SQL Server on the Cluster Nodes
availability
Create the Availability Group
group on
Linux servers
Configure a cluster resource
for HA: manager, like Pacemaker
Enterprise Building a Mission Critical Application
Solution
Scenario • HADR with Always On Availability
Groups on Linux or Windows
▪ All Linux Infrastructure HA
▪ Application-level protection
▪ Automatic and within seconds failover DR
during unplanned outages
▪ No Downtime during planned
Maintenance
▪ Performance sensitive applications
▪ DR required for compliance
regulations
Reports
Async Log Synchronous Log
Backups
Migration / Testing
Solution
Scenario • Minimum downtime and HA for cross-
platform migrations with Distributed
▪ ISV solution built on SQL Server
Availability Groups
on Windows
Linux Certification
Migration / Testing
▪ Enterprise moving to an all-
Linux infrastructure
Rigorous Business Requirements
Seamless migration
▪ No cross platform cluster
manager –
DR Solution between
environments AG2
Distributed Availability Group
Flexibility of HADR Infrastructure
Scenario Solution
▪ ISV solution built on SQL Server ▪ Cross platform hybrid availability group
on Windows ▪ Enables DR/Testing/Migration – Fast Data
Linux Certification replication and minimum downtime
▪ Cost effective – Hybrid with Azure replicas
DR / Migration /
Testing
Availability Group
Read Scale-Out
Scenario Solution
▪ SaaS app (website) ▪ Read scale with availability groups
▪ Catalog database with high volume of ▪ No cluster required
concurrent read-only transactions ▪ Both Windows and Linux support
▪ Bottlenecks on primary due to read
workloads
P
▪ Increased response time S3
S1
Note: R/W
▪ A single distributed availability
group can have up to 17 readable
secondary replicas S2
S4
▪ Daisy Chain is supported
Local Reads
Scale with Distributed Availability Groups
Primary
Asynch Log
Synchronization
AG2
Distributed Availability Group
AlwaysOn and SQL on Linux Resources
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-
SQL Server Linux Stability
business-continuity-dr
Install SQL Server on Linux https://docs.microsoft.com/en-us/sql/linux/quickstart-install-
Quick Starts connect-suse
SQL Server Best Practices http://technet.microsoft.com/en-us/sqlserver/bb671430
https://docs.microsoft.com/en-us/sql/database-
Always On Availability engine/availability-groups/windows/always-on-availability-
Groups (SQL Server) groups-sql-server
SQL Server Hands On Labs https://technet.microsoft.com/en-us/virtuallabs
SQL Server Whitepapers https://msdn.microsoft.com/en-us/library/mt803150(v=sql.1).aspx
Perf BP and config guidelines for https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-
SQL Server 2017 on Linux performance-best-practices
Overview
▪ Avoiding Downtime and Data Loss
Two Principle Requirements for HA and DR
▪ HADR Options in SQL Server
▪ AlwaysOn Availability Groups and Availability Modes
▪ Flexible Failover Policy and Health Monitoring
▪ AlwaysOn Availability Group Monitoring
▪ AlwaysOn Availability Group Features in SQL Server 2016 / 2017
AlwaysOn Availability Group Read-Only Routing
Linux and Pacemaker Support
Read Scale-Out Architecture
© SQLintersection. All rights reserved.
http://www.SQLintersection.com
Questions?
Don’t forget to complete an online evaluation!
SQL SERVER 2016/2017 ALWAYSON AVAILABILITY GROUPS:
WINDOWS AND LINUX DEPLOYMENTS
Your evaluation helps organizers build better conferences
and helps speakers improve their sessions.
Thank you!
Save the Date! www.SQLintersection.com
2018
Mar 25-28
We’re back in Orlando!
Leave the every day behind and enter a world of wonder and enchantment at the Walt Disney World® Resort.
Located in the heart of the most magical place on earth, the Walt Disney World Swan and Dolphin Resort
provides a truly extraordinary backdrop for our event! Beautiful tropical landscaping, tranquil waterways,
and classic art and architecture work together to create a stunning landmark!