Availability Groups: Things to remember

Here are a few things to remember when working with Availability Groups:

Backup and Restore

NOTE: Using the Recovery Advisor GUI in SSMS is advised as it can quickly devise the restore sequence with multiple LOG and BAK locations for a given database.  

NOTE: To restore a database that is a part of an availability group, you will first need to remove it from the availability group.  

Seeding New Databases on Asynchronous Replicas

When adding a new database to the AG, Remember it will auto-seed the database to the synchronous replicas, but the asynchronous replicas will need a FULL and TAIL LOG backup to add them to the AG on that replica. Here is the script below to perform that task:

Distributing Workloads

READ_ONLY Routing

Configuring read replica’s allows you to utilize the secondary servers for processing SELECT queries off of the primary replica, thus increasing the performance on the primary for data updates and inserts.

Below is the connection string attribute that the client applications should add if they are able to use the secondary read capabilities of the availability group and do not need to read from the primary:

Server=AGCorp,1433;Database=AdventureWorks2016;IntegratedSecurity=SSPI;ApplicationIntent=ReadOnly

Configuring the read-only routing URL’s:

Configuring the read-only routing list:

NOTE: some aspects of configuring READ_ONLY routing can only be configured with T-SQL. There are no SSMS GUI screens to configure them. See page 156 of Apress’s ‘Pro SQL Server AlwaysOn Availability Groups’ book.
  

NOTE: READ_ONLY routing stops working when the primary replica is offline. “Read-only routing does not work if the primary is down, because the availability group listener is offline as well. Clients would have to connect directly to the read-only secondary replicas for read-only workloads. Prior to SQL 2014, you could not read from a secondary replica database if it was in a disconnected or not synchronized state. Hence the direct connection to read from the secondary is only available from SQL Server 2014 onwards.” 

Replica Synchronization

IMPORTANT: Suspending the HADR activity on the database will cause a backlog of log blocks and cause the transaction log file(s) to grow on the primary and other remaining replicas that do not have data synchronization suspended.”. In short, always try to keep database synchronization flowing as much as possible to minimize this. %nbsp; 

Data Latency

Remember that on the AlwaysOn Dashboard the data latency column is based on the log being committed. If the secondary is reporting 0ms latency, that does not necessarily mean that the database is current. The REDO thread still needs to apply them yet to the database itself.

MONITOR THE REDO QUEUE SIZE ON ALL SECONDARIES

This has a big impact on the Primary replica. Set REDO queue thresholds for alerting. Read more about this on page 162.

Upgrades, Updates and Hotfixes

When planning for any version upgrade, service packs, or hotfixes, read the “Pro SQL Server Availability Groups” book chapter 13 completely before starting. It walks you through every step, including temporary configuration changes required BEFORE and AFTER the upgrade process.

Rolling Upgrade Best Practices

Similar to the best practices list for upgrading a regular SQL Server instance, we have a list of best practices for performing rolling upgrade for availability group replicas. Following the best practices will avoid data loss, maximize the uptime, and minimize the downtime for client applications using the availability groups.
– Take a full database backup of all databases (if you already don’t have one).
– Run DBCC CHECKDB on all databases and ensure that there are no errors.
– Manually failover on at least one of your synchronous-commit secondary replicas and ensure that it fails over as expected.
Remove automatic failover from all synchronous-commit replicas. This is to avoid any unintended fail-overs during the upgrade process.
Change the automated backup preference as discussed in chapter 11 to ensure that the backups will not run on the replica being upgraded.
Always upgrade the remote secondary replicas first followed by the local secondary replicas, and the primary replica the last.
Before upgrading the primary replica, fail over the availability group to an upgraded synchronous-commit secondary replica with a SYNCHRONIZED state. If you fail over to an asynchronous-commit secondary replica, then you can have data loss and all availability databases will be suspended requiring us to manually resume them.
– If the replicas are SQL Server failover clustering instances (FCIs), then upgrade the inactive node of the FCI before you upgrade the active node.
NOTE: Failure to fail over to an upgraded secondary replica before upgrading the primary replica will affect the applications and users and will extend the downtime during the primary replica upgrade.
 

Views – 168