我有两台服务器 SQL Server 2016,我想实现 AlwaysOn 可用性。
第一个服务器是 Read_Write
第二个服务器是 Read_Only
我将 AlwaysOn 可用性配置如下:
CREATE AVAILABILITY GROUP ag
WITH (AUTOMATED_BACKUP_PREFERENCE = SECONDARY,
DB_FAILOVER = OFF,
DTC_SUPPORT = NONE,
FAILURE_CONDITION_LEVEL = 3,
HEALTH_CHECK_TIMEOUT = 30000)
FOR DATABASE DATABASE_NAME
REPLICA ON N'server1' WITH (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' WITH (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' (
WITH IP
((N'ip', N'mask')
)
, PORT=port);
我的问题是所有查询都被路由到第一台服务器。
我必须如何配置 AlwaysOn 以平衡两台服务器之间的读取查询?
谢谢。