SQL Server 2017 Availability group not routing to secondary server
-
11-10-2020 - |
Pregunta
I've set up a dev AlwaysOn environment on SSMS 2017. I have my AG set up:
I also ran the following scripts:
ALTER AVAILABILITY GROUP [DEV-SQLAG] MODIFY REPLICA ON N'DEV-DB1' WITH (SECONDARY_ROLE (READ_ONLY_ROUTING_URL = N'TCP://Dev-DB1.test.com:5022'));
ALTER AVAILABILITY GROUP [DEV-SQLAG] MODIFY REPLICA ON N'DEV-DB2' WITH (SECONDARY_ROLE (READ_ONLY_ROUTING_URL = N'TCP://Dev-DB2.test.com:5022'));
ALTER AVAILABILITY GROUP [DEV-SQLAG] MODIFY REPLICA ON N'DEV-DB1' WITH (PRIMARY_ROLE (READ_ONLY_ROUTING_LIST = ('DEV-DB2','DEV-DB1')));
ALTER AVAILABILITY GROUP [DEV-SQLAG] MODIFY REPLICA ON N'DEV-DB2' WITH (PRIMARY_ROLE (READ_ONLY_ROUTING_LIST = ('DEV-DB1','DEV-DB2')));
now when I connect to the listener (using SSMS2017) with ApplicationIntent=ReadOnly and I run select @@SERVERNAME
it still shows me DEV-DB1. I thought it would show me that I'm getting data from the secondary DEV-DB2
What am I missing?
Solución
Found my issue: I was under the impression that my End Point URL should be the same as my routing URL, which was going to port 5022. after reading the following article read_only_routing_url I was able to identify my actual routing URL port which was 1433.
Otros consejos
2 more things to be noted here while you are trying to connect to the Listener via the Management Studio for ReadOnly routing:
Make sure that you are also providing the database Name along with "ApplicationIntent=ReadOnly" in the Additional Connection parameters section of SSMS
SSMS sometimes has sticky connections so it could be possible that it is still connecting to an existing connection that was made via SSMS before providing the parameters "ApplicationIntent=ReadOnly". Try restarting the SSMS.