Sql-server – Always On Availability Group ApplicationIntent=ReadOnly Not routing to Secondary

availability-groupssql-server-2012

Version: SQL 2012 SP3
Two Node. 1 Primary 1 Secondary

This is how nodes are set up.

enter image description here

Using SSMS connection options when I set connection property ApplicationIntent=ReadOnly I am not getting routed to secondary node. Yes I am using listener name as Server name.

enter image description here

I did not create any read-only routing list because I only have 2 nodes.

Question 1

Am I wrong that even with only 2 nodes I need read-only routing list?

Question 2

What is the difference between these 2 settings about Readable Secondary? Secondaries can only serve read-only traffic, so why route other connections with selecting Yes?

As per books online:

Read-intent only

Only read-only connections are allowed to secondary databases of this
replica. The secondary database(s) are all available for read access.

Yes

All connections are allowed to secondary databases of this replica,
but only for read access. The secondary database(s) are all available
for read access.

Best Answer

You have to have a read-routing list, even with only two instances, if you want to offload reads to a secondary replica.

The following script is an example of setting this up (you would change the AG name to whatever your AG is, and the replicas to your servernames (using the fully qualified domain name, and adjusting the port if required).

ALTER AVAILABILITY GROUP YOURAGNAME MODIFY REPLICA ON 'REPLICA1' with (SECONDARY_ROLE (READ_ONLY_ROUTING_URL = N'TCP://REPLICA1.FQDN:1433'));
ALTER AVAILABILITY GROUP YOURAGNAME MODIFY REPLICA ON 'REPLICA2' with (SECONDARY_ROLE (READ_ONLY_ROUTING_URL = N'TCP://REPLICA2.FQDN:1433'));

ALTER AVAILABILITY GROUP YOURAGNAME MODIFY REPLICA ON 'REPLICA1' with (PRIMARY_ROLE (READ_ONLY_ROUTING_LIST = ('REPLICA2', 'REPLICA1')));
ALTER AVAILABILITY GROUP YOURAGNAME MODIFY REPLICA ON 'REPLICA2' with (PRIMARY_ROLE (READ_ONLY_ROUTING_LIST = ('REPLICA1', 'REPLICA2')));

As regards the flags:

  • ReadIntent allows for connections only passed along with the ApplicationIntent=ReadOnly flag

  • Yes allows for any connection to the database (meaning you could connect directly with SSMS and run queries)