SQL Server Always On Read Only Routing Lists

Justin Figg, 2019-02-12 (first published: 2019-01-23)

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

Related content

Database Mirroring FAQ: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup?

Question: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? This question was sent to me via email. My reply follows. Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? Databases to be mirrored are currently running on 2005 SQL instances but will be upgraded to 2008 SQL in the near future.

Robert Davis

2009-02-23

1,567 reads

Networking – Part 4

You may want to read Part 1 , Part 2 , and Part 3 before continuing. This time around I’d like to talk about social networking. We’ll start with social networking. Facebook, MySpace, and Twitter are all good examples of using technology to let…

Andy Warren

2009-02-17

1,530 reads

Speaking at Community Events – More Thoughts

Last week I posted Speaking at Community Events – Time to Raise the Bar?, a first cut at talking about to what degree we should require experience for speakers at events like SQLSaturday as well as when it might be appropriate to add additional focus/limitations on the presentations that are accepted. I’ve got a few more thoughts on the topic this week, and I look forward to your comments.

Andy Warren

2009-02-13

360 reads