-> A multi-subnet environment is defined when the OS cluster used for AlwaysOn has server nodes that are located in multiple, different subnets. By default, the behavior of the SQL client libraries is to try all IP addresses returned by the DNS lookup – one after another (serially) until the all of the IP addresses have been exhausted and either a connection is made, or a connection timeout threshold has been reached.
-> Microsoft added a new connection string parameter that can be added to change the connection behavior. This new parameter, MultiSubnetFailover, should be used and set to “TRUE.” When set to TRUE, the connection attempt behavior changes. It will no longer attempt all of the IP addresses serially, but in parallel.
-> The parameter MultiSubnetFailover cannot be used in the Linked Server as part of the provider string. We will have to create a Data Source and then use the Data Source in the Linked Server.
-> I am using Windows Aunthentication to connect the Listener. If you want to use SQL Server Authentication, select as appropriate.
-> Change “Change the default database to:” as indicated in the below screenshot from database Master to a database that is part of Alwayson Availability group that is part of the listener. Make sure the Application Intent is READONLY and Multi-subnet failover is checked.
-> Once the Data Source is created and tested. Move onto creating the Linked server.
-> Select “Be made using this security context” and provide the SQL Server Authentication Credential if required. I am using Windows authentication, so using “Be made using the login’s current securoty context”.
-> Once the Linked server is created. Execute the below query and check if the output returned is your readable secondary and not pointing to the primary.
select * from openquery([JBSERVER1],’select @@servername’)
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.