SQL Server Always On Read Only Routing Lists

,

With the release of SQL Server Always on came the ability to query replica’s and offload read only requests. This enhancement is especially great for reporting type apps by allowing the reports to be generated off the secondary replica’s in the availability group and leave the primary for write and update operations.

Configuring this routing is not difficult to do. With the latest versions of SSMS there is a GUI interface to help. This interface can be found in the AG properties.

In order to configure the read only routing you must provide a routing URL (tcp://servername:portnumber) for each replica in your availability group. Once you specify the routing URL you must provide a list of replicas under the routing list section that the Read Only requests are routed to.

SQL Server uses the application connection string parameters (ApplicationIntent=ReadOnly) to route the connection to the read only replica.

Below you will find sample t-sql to create the routing URLs and the routing lists.

USE [master]
GO
ALTER AVAILABILITY GROUP [AG_Name]
MODIFY REPLICA ON N’servername1\instance’ WITH (SECONDARY_ROLE(READ_ONLY_ROUTING_URL = N’tcp://servername1:instanceportnumber))
GO
ALTER AVAILABILITY GROUP [AG_Name]
MODIFY REPLICA ON N’servername1\instance’ WITH (PRIMARY_ROLE(READ_ONLY_ROUTING_LIST = (N’servername2\instancename’)))
GO
USE [master]
GO
ALTER AVAILABILITY GROUP [AG_Name]
MODIFY REPLICA ON N’servername2\instancename’ WITH (SECONDARY_ROLE(READ_ONLY_ROUTING_URL = N’tcp://servername2:instanceportnumber’))
GO
ALTER AVAILABILITY GROUP [AG_Name]
MODIFY REPLICA ON N’servername2\instancename’ WITH (PRIMARY_ROLE(READ_ONLY_ROUTING_LIST = (N’servername1\instancename’)))
GO

Written by:  Justin Figg a Sr. SQL Server DBA with over 10 years of IT experience with Windows OS, Windows Server and Microsoft SQL Server. Subscribe to my blog to receive notifications of newly posted blog entries.

Support VitaminDBA.comSupport VitaminDBA.com

The post SQL Server Always On Read Only Routing Lists appeared first on VitaminDBA.

Rate

Share

Share

Rate