ALTER AVAILABILITY GROUP [sqlmaxiangqianbd] MODIFY REPLICA ON N‘maxiangqian1‘ WITH (SECONDARY_ROLE (ALLOW_CONNECTIONS = READ_ONLY));
ALTER AVAILABILITY GROUP [sqlmaxiangqianbd] MODIFY REPLICA ON
N‘maxiangqian1‘ WITH (SECONDARY_ROLE (READ_ONLY_ROUTING_URL = N‘TCP://maxiangqian1.maxiangqian.local:1433‘));
ALTER AVAILABILITY GROUP [sqlmaxiangqianbd] MODIFY REPLICA ON
N‘maxiangqian2‘ WITH (SECONDARY_ROLE (ALLOW_CONNECTIONS = READ_ONLY));
ALTER AVAILABILITY GROUP [sqlmaxiangqianbd] MODIFY REPLICA ON
N‘maxiangqian2‘ WITH (SECONDARY_ROLE (READ_ONLY_ROUTING_URL = N‘TCP://maxiangqian2.maxiangqian.local:1433‘));
ALTER AVAILABILITY GROUP [sqlmaxiangqianbd] MODIFY REPLICA ON
N‘maxiangqian1‘ WITH (PRIMARY_ROLE (READ_ONLY_ROUTING_LIST=(‘maxiangqian2‘,‘maxiangqian1‘)));
ALTER AVAILABILITY GROUP [sqlmaxiangqianbd] MODIFY REPLICA ON
N‘maxiangqian2‘ WITH (PRIMARY_ROLE (READ_ONLY_ROUTING_LIST=(‘maxiangqian1‘,‘maxiangqian2‘)));
maxiangqian1?,maxiangqian2是两台主机的主机名,sqlmaxiangqianbd是高可用性组的名字