#SQLSAT777
AlwaysOn in SQL Server 2017
Gianluca Hotz
#SQLSAT777
Organizers
GetLatestVersion.it
#SQLSAT777
Sponsors
#SQLSAT777
Who am I?
• Gianluca Hotz | @glhotz | ghotz@ugiss.org
• Independent Consultant, Founder and Mentor SolidQ
• 20+ years on SQL Server (from 4.21 in 1996)
• Database modeling and development, sizing and administration,
upgrade and migration, performance tuning
• Interests
• Relational model, DBMS architecture, Security, High Availability
and Disaster Recovery
• Community
• 20 years Microsoft MVP SQL Server (from 1998)
• Founder and President UGISS
• User Group Italiano SQL Server (PASS Chapter)
#SQLSAT777
Whats is AlwaysOn?
• New name for HA and DR technologies
• Failover Cluster Instance (FCI)
• Availability Groups (AG)
• Previously named HADRON
• Keep in mind when searching articles
• Still present in some DMVs (_hadr_)
#SQLSAT777
AlwaysOn FCI
#SQLSAT777
FCI Review
• Protects an entire SQL Server instance
• All databases including system databases (logins, jobs, etc.)
• Automatic failover (client connects to a VNN/IP Address)
• Requires Shared Storage
• Geographic DR with SQL Server < 2012
• Proprietary solutions for Stretch V-LAN
• Proprietary solutions for storage replication
• Multi-subnet support >=2012
#SQLSAT777
Normal operations with AlwaysOn FCI
Primary Site
Shared Storage
SQLCLUSTER
SQL FCI Primary
SQL02
SAN01
SQLFCI01
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.100
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
#SQLSAT777
Node unavailability with AlwaysOn FCI
Primary Site
Shared Storage
SQLCLUSTER
SQL FCI Primary
SQL02
SAN01
SQLFCI01
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.100
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
CRASH
#SQLSAT777
Multi-Subnet Support
• Nodes on different subnets
• IP Address resources in OR
• Still need storage replication
• (Enterprise Edition required)
http://msdn.microsoft.com/en-us/library/ff878716.aspx
#SQLSAT777
Multi-Subnet: how do clients reconnect?
• New clients
• Try IP addresses in order
• Avoid DNS update latencies
• New connection string parameter
• MultiSubnetFailover=True
• Try IP addresses in parallel
• Old clients can be problematic…
• Check driver support!
• … OleDB Provider fixed 30 March 2018!!
• https://blogs.msdn.microsoft.com/sqlnativeclient/2017/10/06/ann
ouncing-the-new-release-of-ole-db-driver-for-sql-server
• https://blogs.msdn.microsoft.com/sqlreleaseservices/released-
microsoft-ole-db-driver-for-sql-server
http://msdn.microsoft.com/en-us/library/ff878716.aspx
#SQLSAT777
Multi-Subnet problem with old clients
• Applies to
• Libraries without support for MultiSubnetFailover
• Connection strings that can’t be modified
• Origin
• Multiple IP registration in DNS
• Library timeout < TCP timeout (15 vs 21 sec.)
• Mitigation
• Raise library timeout > 30-40 sec. (if possible)
• Avoid registering all IPs (affects everyone)
• Reduce DNS updates latency (HostRecordTTL)
• Reduce DNS cache expiration on the client
• For AG: implement both on separate Availability Groups
http://msdn.microsoft.com/en-us/library/ff878716.aspx
#SQLSAT777
Normal operation with multi-subnet
Secondary Site
Core Services
Primary Site
Shared Storage
SQLCLUSTER
Multi-subnet SQL FCI
SQL02
SAN01
SQLFCI01
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.100
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
Shared Storage
SQL04
SAN02
10.2.0.20
SQL03
10.2.0.10
10.2.1.100
10.2.1.50
DC03 DC04
10.2.0.1 10.2.0.2
Proprietary Storage
Replication
#SQLSAT777
AlwaysOn FCI multi-subnet resilience
Secondary Site
Core Services
Primary Site
Shared Storage
SQLCLUSTER
Multi-subnet SQL FCI
SQL02
SAN01
SQLFCI01
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.100
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
Shared Storage
SQL04
SAN02
10.2.0.20
SQL03
10.2.0.10
10.2.1.100
10.2.1.50
DC03 DC04
10.2.0.1 10.2.0.2
Proprietary Storage
Replication
CRASH
CRASH
CRASH
#SQLSAT777
AlwaysOn FCI multi-subnet DR with HA
Secondary Site
Core Services
Primary Site
Shared Storage
SQLCLUSTER
Multi-subnet SQL FCI
SQL02
SAN01
SQLFCI01
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.100
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
Shared Storage
SQL04
SAN02
10.2.0.20
SQL03
10.2.0.10
10.2.1.100
10.2.1.50
DC03 DC04
10.2.0.1 10.2.0.2
Proprietary Storage
Replication
CRASH
CRASH
CRASH
CRASH
#SQLSAT777
AlwaysOn FCI in SQL Server 2014
• Support for Windows Server 2012 CSV
• Support for FCI in Sysprep
• Same support as for Availability Groups in
• sys.dm_hadr_cluster
• sys.dm_hadr_cluster_members
• sys.dm_hadr_cluster_networks
• New DMV
• sys.dm_io_cluster_valid_path_names
#SQLSAT777
AlwaysOn FCI in SQL Server 2016
• Group Managed Service Accounts (gMSA)
• Managed directly by AD
• Automatic password rotation
• SQL Server 2014 Supported on Windows Server 2012
R2 + hotfix
#SQLSAT777
AlwaysOn FCI in SQL Server 2017
• Support for Linux
#SQLSAT777
AlwaysOn AG
#SQLSAT777
Data replicas review
• Log Shipping
• Database Mirroring
• Replication
• SQL Server 2012+: Availability Groups
#SQLSAT777
Log Shipping
• Advantages
• Entire database replicas
• Multiple replicas per database
• Simple and robust
• Disadvantages
• Only asynchronous replicas
• Readable replicas with trade-offs
• Updated to last log restore
• Need to disconnect clients before restoring
#SQLSAT777
Database Mirroring
• Advantages
• Entire database replicas
• Synchronous and asynchronous (EE) replicas
• Simple and robust
• Disadvantages
• Only one replica per database
• Readable replicas need Database Snapshot
• Enterprise Edition
• Updated to last snapshot creation time
• Need to disconnect or handle multiple snapshot names
#SQLSAT777
Replication
• Advantages
• More granular (depends on scenario)
• Multiple replicas
• Readable & updateable replicas
• Disadvantages
• More granular (depends on scenario)
• Only asynchronous replicas
• Typically higher latency
• Complexity and maintenance overhead
#SQLSAT777
Common Problems
• Manual Failover*
• No coordination to failover multiple DBs
• No backups on replicas*
• Specific limitations
• E.g. FILESTREAM, cross-database consistency of
transactions, only one replica
#SQLSAT777
AG as evolution of Database Mirroring
• Coordinated failover of multiple DBs
• Multiple replicas (up to 4 initially)*
• Synchronous/asynchronous replicas
• Up-to-date readable replicas
• Ability to off-load maintenance on replicas
• e.g. backups
#SQLSAT777
AG Overview
https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server
#SQLSAT777
Normal operations with AlwaysOn AG
Primary Site
SQLCLUSTER
Availability Group AG01
SQL02
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
SQLAG01
10.1.1.200
DAS DAS
Primary
Replica
AGDB01
AGDB02
Secondary
Replica
AGDB01
AGDB02
#SQLSAT777
Node unavailability with AlwaysOn AG
Primary Site
SQLCLUSTER
Availability Group AG01
SQL02
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
SQLAG01
10.1.1.200
DAS DAS
Primary
Replica
AGDB01
AGDB02
Secondary
Replica
AGDB01
AGDB02
CRASH
#SQLSAT777
AlwaysOn AG multi-subnet resilience
Secondary SitePrimary Site
SQLCLUSTER
Availability Group AG01
Core Services
SQL02
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
SQL04
10.2.0.20
SQL03
10.2.0.10
Quorum Witness
Disk Share Node
10.2.1.50
DC03 DC04
10.2.0.1 10.2.0.2
SQLAG01
10.1.1.200 10.2.1.200
DAS DAS DAS DAS
Primary
Replica
AGDB01
AGDB02
Secondary
Replica
AGDB01
AGDB02
Secondary
Replica
AGDB01
AGDB02
Secondary
Replica
AGDB01
AGDB02
CRASH
#SQLSAT777
AlwaysOn AG multi-subnet DR with HA
Secondary SitePrimary Site
SQLCLUSTER
Availability Group AG01
Core Services
SQL02
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
SQL04
10.2.0.20
SQL03
10.2.0.10
Quorum Witness
Disk Share Node
10.2.1.50
DC03 DC04
10.2.0.1 10.2.0.2
SQLAG01
10.1.1.200 10.2.1.200
DAS DAS DAS DAS
Primary
Replica
AGDB01
AGDB02
Secondary
Replica
AGDB01
AGDB02
Secondary
Replica
AGDB01
AGDB02
Secondary
Replica
AGDB01
AGDB02
CRASH
CRASH
#SQLSAT777
Read-Only Access
• Replicas roles
• Primary: READ_WRITE|ALL
• Secondary: NO|READ_ONLY|ALL
• New connection property
• ApplicationIntent
• Name slightly different across client APIs
• Read-Only Routing
#SQLSAT777
AlwaysOn AG Topology Example
A
A
Direct attached storage local, regional and geo secondaries
A
A
Synchronous
data movement
Asynchronous data
movement
#SQLSAT777
Read-Only Access Capacity Planning
• Synchronization latency of replica can raise
• because of the read I/O activity
• Impact on tempdb
• Temporary statistics
• Automatically created
• Gone after failover
• Read Committed Snapshot Isolation
• 14 bytes added to rows at primary (on updates)
#SQLSAT777
Problem with Replicas at Database level
• Need Manual synchronization for objects outside
database scope
• New logins/users, Jobs, …
• Solution for logins/users
• Contained databases
• Problem with ApplicationIntent=ReadOnly
#SQLSAT777
Availability Groups in SQL Server 2014
• Up to 8 secondary replicas (was 4)
• still only 2 can be in synchronous mode
• Secondary readable replicas remain online
• when disconnected from primary
• When there’s a quorum loss
• New DMV
• sys.fn_hadr_is_primary_replica
• Add Azure Replica Wizard
#SQLSAT777
Availability Groups in SQL Server 2016
• Up to 3 synchronous replicas with automatic failover (was 2)
• Enhanched database failover (fail on write transaction failure)
• Secondary replica seeding (instead of backup/restore)
• Read-only secondary replicas load balancing
• MSDTC supported with Windows Server 2016 (cross-instance only)
• Database encryption support (eg. SSIDB)
• Cross-domain and domain-independent AG
• Distributed AG
• Log record transport re-written to be much faster
#SQLSAT777
Scalability with Read-Only AG in SQL 2016
Async Log Synchronization
OLTP workload
#SQLSAT777
Scalability with Distributed AG in SQL 2016
AG2
Async Log
Synchronization
Distributed availability group
AG1
#SQLSAT777
Basic Availability Groups in SQL Server 2016
• Availabile with Standard Edition
• Solution for deprecated Database Mirorring (almost…)
• Limited to 2 replicas
• Synchronous or asynchronous (DBM required EE for async!)
• Replica can be in Azure
• Limited to 1 database per Availability Group
• Secondary replica not accessible
• eg. read-only, backups…
#SQLSAT777
AG Turbocharged in SQL Server 2016
• Problem
• Performance not adequate in some synchronous replica scenarios
• Higher scalability required with more/faster resources
• Target: 95% performance with 1 synchronous replica
• Many optimizations in SQL Server 2016
• Eg. reduced number of needed worker thread, use more parallelism,
reduced contention
• Results
• 95% with 1 synchronous replica, 90% with 2 replicas
#SQLSAT777
Availability Groups in SQL Server 2017
• Cross-database transaction support (MSDTC)
• Minimum number of (sync) replica to commit
• Clusterless sceanarios support
• CLUSTER_TYPE = NONE
• e.g. read-only scale out replicas not used for HA
• Linux support
• CLUSTER_TYPE = EXTERNAL (Pacemaker)
• CLUSTER_TYPE = NONE
• Cross-OS migration Windows-Linux supported
#SQLSAT777
Advanced Scenarios
AlwaysOn FCI+AG
Secondary SitePrimary Site
SQLCLUSTER
Availability Group AG01
Core Services
Shared Storage
SQL FCI Primary
SQL02
SAN01
SQLFCI01
ADMINWKS
Router
10.1.0.20
SQL01
10.1.0.10
Quorum Witness
Disk Share Node
10.1.1.100
10.1.1.50
Core Services
DC01 DC02
10.1.0.1 10.1.0.2
Shared Storage
SQL FCI Secondary
SQL04
SAN02
SQLFCI02
10.2.0.20
SQL03
10.2.0.10
Quorum Witness
Disk Share Node
10.2.1.100
10.2.1.50
DC03 DC04
10.2.0.1 10.2.0.2
SQLAG01
10.1.1.200 10.2.1.200
SQL Server Database
Replication
Primary
Replica
AGDB01
AGDB02
Secondary
Replica
AGDB01
AGDB02
CRASH
CRASH
CRASH
#SQLSAT777
Hybrid Cloud
Run backups
Run BI reports
#SQLSAT777
Considerations
#SQLSAT777
Other Hybrid Cloud Scenarios
• Database Mirroring
• VPN not needed for domain authentication
• Can use certificate based authentication
• Log Shipping
#SQLSAT777
Choice based on business requirements
Recovery Point
Objective
Recovery Time
Objective
SLA
Requirements
Resiliency
Requirements
Deployment
Span
Read/Write
Scale-out
Cost Of
Deployment
Environmental
Constraints
#SQLSAT777
«Zero downtime»?
• Excellence in designing and planning
• Excellence in execution
• Application resiliency
• Retry logic (exponential back-off)
• Useful in other context (deadlocks, update conflicts)
#SQLSAT777
Change in licensing
• Software Assurance needed for passive servers
• “Beginning with SQL Server 2014, each active server licensed with SA coverage allows the
installation of a single passive server used for fail-over support.”
• Right to run only one free passive secondary
• “The active server license (s) must be covered with SA, and allow for one passive secondary SQL
Server, with up to the same amount of compute as the licensed active server, only.”
• Impacts everything: log shipping, mirroring, AG, FCI
• SQL Server 2014-2017 Licensing Datasheets
• http://download.microsoft.com/download/6/6/F/66FF3259-1466-4BBA-A505-
2E3DA5B2B1FA/SQL_Server_2014_Licensing_Datasheet.pdf
• http://download.microsoft.com/download/F/D/5/FD5E5C28-6973-4273-8737-
D69AA3BEA243/SQL_Server_2016_Licensing_Datasheet_EN_US.pdf
• http://download.microsoft.com/download/7/8/c/78cdf005-97c1-4129-926b-
ce4a6fe92cf5/sql_server_2017_licensing_guide.pdf
• SQL Server 2017 Licensing Guide
• http://download.microsoft.com/download/7/8/c/78cdf005-97c1-4129-926b-
ce4a6fe92cf5/sql_server_2017_licensing_guide.pdf
#SQLSAT777
AG Main Resources
• Official documentation
• https://docs.microsoft.com/en-us/sql/sql-server/failover-
clusters/windows/always-on-failover-cluster-instances-sql-server
• https://docs.microsoft.com/en-us/sql/database-
engine/availability-groups/windows/always-on-availability-
groups-sql-server
• Blogs
• CSS SQL Server Engineers
• http://blogs.msdn.com/b/psssql/archive/tags/alwayson
• SQL AlwaysOn Blog
• http://blogs.msdn.com/b/sqlalwayson (stale)
#SQLSAT777
AG Whitepapers series
• AlwaysOn Architecture Guide: Building a High Availability and Disaster Recovery Solution by Using AlwaysOn Availability Groups
• http://msdn.microsoft.com/en-us/library/jj191711.aspx
• AlwaysOn Architecture Guide: Building a High Availability and Disaster Recovery Solution by Using Failover Cluster Instances and
Availability Groups
• http://msdn.microsoft.com/en-us/library/jj215886.aspx
• AlwaysOn Solution Guide: Offloading Read-Only Workloads to Secondary Replicas
• http://msdn.microsoft.com/en-us/library/jj542414.aspx
• Cross-cluster Migration of AlwaysOn Availability Groups for Operating System Upgrades
• http://msdn.microsoft.com/en-us/library/jj873730.aspx
• Microsoft SQL Server AlwaysOn Solutions Guide for High Availability and Disaster Recovery
• http://msdn.microsoft.com/en-us/library/hh781257.aspx
• Migration Guide: Migrating to AlwaysOn Availability Groups from Prior Deployments Combining Database Mirroring and Log Shipping
• http://msdn.microsoft.com/en-us/library/jj635217.aspx
• Multisite Failover Cluster Instance
• http://sqlcat.com/sqlcat/b/whitepapers/archive/2011/12/22/sql-server-2012-alwayson_3a00_-multisite-failover-cluster-instance.aspx
• SQL Server 2012 AlwaysOn High Availability and Disaster Recovery Design Patterns
• http://sqlcat.com/sqlcat/b/msdnmirror/archive/2011/12/22/sql-server-2012-alwayson-high-availability-and-disaster-recovery-design-
patterns.aspx
#SQLSAT777
Resources SQL Server 2019
• Ignite 2018 Video
• Architecting a highly available database platform with
SQL Server
• https://www.youtube.com/watch?v=5h1Xkh9CU-c
#SQLSAT777
Thanks!

Alwayson in sqlserver2017

  • 1.
    #SQLSAT777 AlwaysOn in SQLServer 2017 Gianluca Hotz
  • 2.
  • 3.
  • 4.
    #SQLSAT777 Who am I? •Gianluca Hotz | @glhotz | ghotz@ugiss.org • Independent Consultant, Founder and Mentor SolidQ • 20+ years on SQL Server (from 4.21 in 1996) • Database modeling and development, sizing and administration, upgrade and migration, performance tuning • Interests • Relational model, DBMS architecture, Security, High Availability and Disaster Recovery • Community • 20 years Microsoft MVP SQL Server (from 1998) • Founder and President UGISS • User Group Italiano SQL Server (PASS Chapter)
  • 5.
    #SQLSAT777 Whats is AlwaysOn? •New name for HA and DR technologies • Failover Cluster Instance (FCI) • Availability Groups (AG) • Previously named HADRON • Keep in mind when searching articles • Still present in some DMVs (_hadr_)
  • 6.
  • 7.
    #SQLSAT777 FCI Review • Protectsan entire SQL Server instance • All databases including system databases (logins, jobs, etc.) • Automatic failover (client connects to a VNN/IP Address) • Requires Shared Storage • Geographic DR with SQL Server < 2012 • Proprietary solutions for Stretch V-LAN • Proprietary solutions for storage replication • Multi-subnet support >=2012
  • 8.
    #SQLSAT777 Normal operations withAlwaysOn FCI Primary Site Shared Storage SQLCLUSTER SQL FCI Primary SQL02 SAN01 SQLFCI01 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.100 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2
  • 9.
    #SQLSAT777 Node unavailability withAlwaysOn FCI Primary Site Shared Storage SQLCLUSTER SQL FCI Primary SQL02 SAN01 SQLFCI01 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.100 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2 CRASH
  • 10.
    #SQLSAT777 Multi-Subnet Support • Nodeson different subnets • IP Address resources in OR • Still need storage replication • (Enterprise Edition required) http://msdn.microsoft.com/en-us/library/ff878716.aspx
  • 11.
    #SQLSAT777 Multi-Subnet: how doclients reconnect? • New clients • Try IP addresses in order • Avoid DNS update latencies • New connection string parameter • MultiSubnetFailover=True • Try IP addresses in parallel • Old clients can be problematic… • Check driver support! • … OleDB Provider fixed 30 March 2018!! • https://blogs.msdn.microsoft.com/sqlnativeclient/2017/10/06/ann ouncing-the-new-release-of-ole-db-driver-for-sql-server • https://blogs.msdn.microsoft.com/sqlreleaseservices/released- microsoft-ole-db-driver-for-sql-server http://msdn.microsoft.com/en-us/library/ff878716.aspx
  • 12.
    #SQLSAT777 Multi-Subnet problem withold clients • Applies to • Libraries without support for MultiSubnetFailover • Connection strings that can’t be modified • Origin • Multiple IP registration in DNS • Library timeout < TCP timeout (15 vs 21 sec.) • Mitigation • Raise library timeout > 30-40 sec. (if possible) • Avoid registering all IPs (affects everyone) • Reduce DNS updates latency (HostRecordTTL) • Reduce DNS cache expiration on the client • For AG: implement both on separate Availability Groups http://msdn.microsoft.com/en-us/library/ff878716.aspx
  • 13.
    #SQLSAT777 Normal operation withmulti-subnet Secondary Site Core Services Primary Site Shared Storage SQLCLUSTER Multi-subnet SQL FCI SQL02 SAN01 SQLFCI01 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.100 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2 Shared Storage SQL04 SAN02 10.2.0.20 SQL03 10.2.0.10 10.2.1.100 10.2.1.50 DC03 DC04 10.2.0.1 10.2.0.2 Proprietary Storage Replication
  • 14.
    #SQLSAT777 AlwaysOn FCI multi-subnetresilience Secondary Site Core Services Primary Site Shared Storage SQLCLUSTER Multi-subnet SQL FCI SQL02 SAN01 SQLFCI01 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.100 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2 Shared Storage SQL04 SAN02 10.2.0.20 SQL03 10.2.0.10 10.2.1.100 10.2.1.50 DC03 DC04 10.2.0.1 10.2.0.2 Proprietary Storage Replication CRASH CRASH CRASH
  • 15.
    #SQLSAT777 AlwaysOn FCI multi-subnetDR with HA Secondary Site Core Services Primary Site Shared Storage SQLCLUSTER Multi-subnet SQL FCI SQL02 SAN01 SQLFCI01 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.100 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2 Shared Storage SQL04 SAN02 10.2.0.20 SQL03 10.2.0.10 10.2.1.100 10.2.1.50 DC03 DC04 10.2.0.1 10.2.0.2 Proprietary Storage Replication CRASH CRASH CRASH CRASH
  • 16.
    #SQLSAT777 AlwaysOn FCI inSQL Server 2014 • Support for Windows Server 2012 CSV • Support for FCI in Sysprep • Same support as for Availability Groups in • sys.dm_hadr_cluster • sys.dm_hadr_cluster_members • sys.dm_hadr_cluster_networks • New DMV • sys.dm_io_cluster_valid_path_names
  • 17.
    #SQLSAT777 AlwaysOn FCI inSQL Server 2016 • Group Managed Service Accounts (gMSA) • Managed directly by AD • Automatic password rotation • SQL Server 2014 Supported on Windows Server 2012 R2 + hotfix
  • 18.
    #SQLSAT777 AlwaysOn FCI inSQL Server 2017 • Support for Linux
  • 19.
  • 20.
    #SQLSAT777 Data replicas review •Log Shipping • Database Mirroring • Replication • SQL Server 2012+: Availability Groups
  • 21.
    #SQLSAT777 Log Shipping • Advantages •Entire database replicas • Multiple replicas per database • Simple and robust • Disadvantages • Only asynchronous replicas • Readable replicas with trade-offs • Updated to last log restore • Need to disconnect clients before restoring
  • 22.
    #SQLSAT777 Database Mirroring • Advantages •Entire database replicas • Synchronous and asynchronous (EE) replicas • Simple and robust • Disadvantages • Only one replica per database • Readable replicas need Database Snapshot • Enterprise Edition • Updated to last snapshot creation time • Need to disconnect or handle multiple snapshot names
  • 23.
    #SQLSAT777 Replication • Advantages • Moregranular (depends on scenario) • Multiple replicas • Readable & updateable replicas • Disadvantages • More granular (depends on scenario) • Only asynchronous replicas • Typically higher latency • Complexity and maintenance overhead
  • 24.
    #SQLSAT777 Common Problems • ManualFailover* • No coordination to failover multiple DBs • No backups on replicas* • Specific limitations • E.g. FILESTREAM, cross-database consistency of transactions, only one replica
  • 25.
    #SQLSAT777 AG as evolutionof Database Mirroring • Coordinated failover of multiple DBs • Multiple replicas (up to 4 initially)* • Synchronous/asynchronous replicas • Up-to-date readable replicas • Ability to off-load maintenance on replicas • e.g. backups
  • 26.
  • 27.
    #SQLSAT777 Normal operations withAlwaysOn AG Primary Site SQLCLUSTER Availability Group AG01 SQL02 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2 SQLAG01 10.1.1.200 DAS DAS Primary Replica AGDB01 AGDB02 Secondary Replica AGDB01 AGDB02
  • 28.
    #SQLSAT777 Node unavailability withAlwaysOn AG Primary Site SQLCLUSTER Availability Group AG01 SQL02 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2 SQLAG01 10.1.1.200 DAS DAS Primary Replica AGDB01 AGDB02 Secondary Replica AGDB01 AGDB02 CRASH
  • 29.
    #SQLSAT777 AlwaysOn AG multi-subnetresilience Secondary SitePrimary Site SQLCLUSTER Availability Group AG01 Core Services SQL02 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2 SQL04 10.2.0.20 SQL03 10.2.0.10 Quorum Witness Disk Share Node 10.2.1.50 DC03 DC04 10.2.0.1 10.2.0.2 SQLAG01 10.1.1.200 10.2.1.200 DAS DAS DAS DAS Primary Replica AGDB01 AGDB02 Secondary Replica AGDB01 AGDB02 Secondary Replica AGDB01 AGDB02 Secondary Replica AGDB01 AGDB02 CRASH
  • 30.
    #SQLSAT777 AlwaysOn AG multi-subnetDR with HA Secondary SitePrimary Site SQLCLUSTER Availability Group AG01 Core Services SQL02 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2 SQL04 10.2.0.20 SQL03 10.2.0.10 Quorum Witness Disk Share Node 10.2.1.50 DC03 DC04 10.2.0.1 10.2.0.2 SQLAG01 10.1.1.200 10.2.1.200 DAS DAS DAS DAS Primary Replica AGDB01 AGDB02 Secondary Replica AGDB01 AGDB02 Secondary Replica AGDB01 AGDB02 Secondary Replica AGDB01 AGDB02 CRASH CRASH
  • 31.
    #SQLSAT777 Read-Only Access • Replicasroles • Primary: READ_WRITE|ALL • Secondary: NO|READ_ONLY|ALL • New connection property • ApplicationIntent • Name slightly different across client APIs • Read-Only Routing
  • 32.
    #SQLSAT777 AlwaysOn AG TopologyExample A A Direct attached storage local, regional and geo secondaries A A Synchronous data movement Asynchronous data movement
  • 33.
    #SQLSAT777 Read-Only Access CapacityPlanning • Synchronization latency of replica can raise • because of the read I/O activity • Impact on tempdb • Temporary statistics • Automatically created • Gone after failover • Read Committed Snapshot Isolation • 14 bytes added to rows at primary (on updates)
  • 34.
    #SQLSAT777 Problem with Replicasat Database level • Need Manual synchronization for objects outside database scope • New logins/users, Jobs, … • Solution for logins/users • Contained databases • Problem with ApplicationIntent=ReadOnly
  • 35.
    #SQLSAT777 Availability Groups inSQL Server 2014 • Up to 8 secondary replicas (was 4) • still only 2 can be in synchronous mode • Secondary readable replicas remain online • when disconnected from primary • When there’s a quorum loss • New DMV • sys.fn_hadr_is_primary_replica • Add Azure Replica Wizard
  • 36.
    #SQLSAT777 Availability Groups inSQL Server 2016 • Up to 3 synchronous replicas with automatic failover (was 2) • Enhanched database failover (fail on write transaction failure) • Secondary replica seeding (instead of backup/restore) • Read-only secondary replicas load balancing • MSDTC supported with Windows Server 2016 (cross-instance only) • Database encryption support (eg. SSIDB) • Cross-domain and domain-independent AG • Distributed AG • Log record transport re-written to be much faster
  • 37.
    #SQLSAT777 Scalability with Read-OnlyAG in SQL 2016 Async Log Synchronization OLTP workload
  • 38.
    #SQLSAT777 Scalability with DistributedAG in SQL 2016 AG2 Async Log Synchronization Distributed availability group AG1
  • 39.
    #SQLSAT777 Basic Availability Groupsin SQL Server 2016 • Availabile with Standard Edition • Solution for deprecated Database Mirorring (almost…) • Limited to 2 replicas • Synchronous or asynchronous (DBM required EE for async!) • Replica can be in Azure • Limited to 1 database per Availability Group • Secondary replica not accessible • eg. read-only, backups…
  • 40.
    #SQLSAT777 AG Turbocharged inSQL Server 2016 • Problem • Performance not adequate in some synchronous replica scenarios • Higher scalability required with more/faster resources • Target: 95% performance with 1 synchronous replica • Many optimizations in SQL Server 2016 • Eg. reduced number of needed worker thread, use more parallelism, reduced contention • Results • 95% with 1 synchronous replica, 90% with 2 replicas
  • 41.
    #SQLSAT777 Availability Groups inSQL Server 2017 • Cross-database transaction support (MSDTC) • Minimum number of (sync) replica to commit • Clusterless sceanarios support • CLUSTER_TYPE = NONE • e.g. read-only scale out replicas not used for HA • Linux support • CLUSTER_TYPE = EXTERNAL (Pacemaker) • CLUSTER_TYPE = NONE • Cross-OS migration Windows-Linux supported
  • 42.
  • 43.
    AlwaysOn FCI+AG Secondary SitePrimarySite SQLCLUSTER Availability Group AG01 Core Services Shared Storage SQL FCI Primary SQL02 SAN01 SQLFCI01 ADMINWKS Router 10.1.0.20 SQL01 10.1.0.10 Quorum Witness Disk Share Node 10.1.1.100 10.1.1.50 Core Services DC01 DC02 10.1.0.1 10.1.0.2 Shared Storage SQL FCI Secondary SQL04 SAN02 SQLFCI02 10.2.0.20 SQL03 10.2.0.10 Quorum Witness Disk Share Node 10.2.1.100 10.2.1.50 DC03 DC04 10.2.0.1 10.2.0.2 SQLAG01 10.1.1.200 10.2.1.200 SQL Server Database Replication Primary Replica AGDB01 AGDB02 Secondary Replica AGDB01 AGDB02 CRASH CRASH CRASH
  • 44.
  • 45.
  • 46.
    #SQLSAT777 Other Hybrid CloudScenarios • Database Mirroring • VPN not needed for domain authentication • Can use certificate based authentication • Log Shipping
  • 47.
    #SQLSAT777 Choice based onbusiness requirements Recovery Point Objective Recovery Time Objective SLA Requirements Resiliency Requirements Deployment Span Read/Write Scale-out Cost Of Deployment Environmental Constraints
  • 48.
    #SQLSAT777 «Zero downtime»? • Excellencein designing and planning • Excellence in execution • Application resiliency • Retry logic (exponential back-off) • Useful in other context (deadlocks, update conflicts)
  • 49.
    #SQLSAT777 Change in licensing •Software Assurance needed for passive servers • “Beginning with SQL Server 2014, each active server licensed with SA coverage allows the installation of a single passive server used for fail-over support.” • Right to run only one free passive secondary • “The active server license (s) must be covered with SA, and allow for one passive secondary SQL Server, with up to the same amount of compute as the licensed active server, only.” • Impacts everything: log shipping, mirroring, AG, FCI • SQL Server 2014-2017 Licensing Datasheets • http://download.microsoft.com/download/6/6/F/66FF3259-1466-4BBA-A505- 2E3DA5B2B1FA/SQL_Server_2014_Licensing_Datasheet.pdf • http://download.microsoft.com/download/F/D/5/FD5E5C28-6973-4273-8737- D69AA3BEA243/SQL_Server_2016_Licensing_Datasheet_EN_US.pdf • http://download.microsoft.com/download/7/8/c/78cdf005-97c1-4129-926b- ce4a6fe92cf5/sql_server_2017_licensing_guide.pdf • SQL Server 2017 Licensing Guide • http://download.microsoft.com/download/7/8/c/78cdf005-97c1-4129-926b- ce4a6fe92cf5/sql_server_2017_licensing_guide.pdf
  • 50.
    #SQLSAT777 AG Main Resources •Official documentation • https://docs.microsoft.com/en-us/sql/sql-server/failover- clusters/windows/always-on-failover-cluster-instances-sql-server • https://docs.microsoft.com/en-us/sql/database- engine/availability-groups/windows/always-on-availability- groups-sql-server • Blogs • CSS SQL Server Engineers • http://blogs.msdn.com/b/psssql/archive/tags/alwayson • SQL AlwaysOn Blog • http://blogs.msdn.com/b/sqlalwayson (stale)
  • 51.
    #SQLSAT777 AG Whitepapers series •AlwaysOn Architecture Guide: Building a High Availability and Disaster Recovery Solution by Using AlwaysOn Availability Groups • http://msdn.microsoft.com/en-us/library/jj191711.aspx • AlwaysOn Architecture Guide: Building a High Availability and Disaster Recovery Solution by Using Failover Cluster Instances and Availability Groups • http://msdn.microsoft.com/en-us/library/jj215886.aspx • AlwaysOn Solution Guide: Offloading Read-Only Workloads to Secondary Replicas • http://msdn.microsoft.com/en-us/library/jj542414.aspx • Cross-cluster Migration of AlwaysOn Availability Groups for Operating System Upgrades • http://msdn.microsoft.com/en-us/library/jj873730.aspx • Microsoft SQL Server AlwaysOn Solutions Guide for High Availability and Disaster Recovery • http://msdn.microsoft.com/en-us/library/hh781257.aspx • Migration Guide: Migrating to AlwaysOn Availability Groups from Prior Deployments Combining Database Mirroring and Log Shipping • http://msdn.microsoft.com/en-us/library/jj635217.aspx • Multisite Failover Cluster Instance • http://sqlcat.com/sqlcat/b/whitepapers/archive/2011/12/22/sql-server-2012-alwayson_3a00_-multisite-failover-cluster-instance.aspx • SQL Server 2012 AlwaysOn High Availability and Disaster Recovery Design Patterns • http://sqlcat.com/sqlcat/b/msdnmirror/archive/2011/12/22/sql-server-2012-alwayson-high-availability-and-disaster-recovery-design- patterns.aspx
  • 52.
    #SQLSAT777 Resources SQL Server2019 • Ignite 2018 Video • Architecting a highly available database platform with SQL Server • https://www.youtube.com/watch?v=5h1Xkh9CU-c
  • 53.