SQL Server AlwaysOn Availability -


i have 2 server sql server 2016 , want implement alwayson availabiliy.

the first server read_write

the second server read_only

i configured alwayson availability folowing :

create availability group ag (automated_backup_preference = secondary, db_failover = off, dtc_support = none, failure_condition_level = 3, health_check_timeout = 30000) database database_name replica on n'server1' (endpoint_url = n'tcp://server1_adress:port', failover_mode = automatic, availability_mode = synchronous_commit, session_timeout = 10, backup_priority = 50, secondary_role (read_only_routing_url = n'tcp://server1_adress:port')), n'server2' (endpoint_url = n'tcp://server2_adress:5022', failover_mode = automatic, availability_mode = synchronous_commit, session_timeout = 10, backup_priority = 50, primary_role(read_only_routing_list=('server1'))) listener n'listener_server' ( ip ((n'ip', n'mask') ) , port=port); 

my problem queries routed first server.

how must configure alwayson balance read queries between 2 servers?

thanks.

first of have define special connection string tell sql server connect read-only replica (called "application intent"):

server=tcp:myaglistener,1433;database=db1;integratedsecurity=sspi;applicationintent=readonly;multisubnetfailover=true   

in second step have allow read-only access nodes in case of being secondary:

alter availability group [ag] modify replica on n'server1' (secondary_role(allow_connections =  read_only)) go alter availability group [ag] modify replica on n'server2' (secondary_role(allow_connections =  read_only)) go 

furthermore add read-only routing url server2:

alter availability group [ag] modify replica on n'server2' (secondary_role (read_only_routing_url =  n'tcp://server2_adress:port')); go 

in next step have define routing list server should connected when specific server primary one. defined read_only_routing_list. 1 server. happens when server1 breaks? should define routing list every possible primary node.

alter availability group [ag]  modify replica on n'server1'  (primary_role (read_only_routing_list=('server2','server1')));  alter availability group [ag]  modify replica on n'server2'  (primary_role (read_only_routing_list=('server1','server2'))); go 

for new load balancing feature of alwayson in sql server 2016, need @ least third read-only node allows read-only connections , configure "nested" routing list:

alter availability group ag  modify replica on n'server1' (primary_role (read_only_routing_list= (('server2', 'server3'), 'server1'))); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -