Configuring AlwaysOn Read-Only Replicas

How to configure read-only secondary replicas

Michael Otey

July 11, 2014

1 Min Read
Configuring AlwaysOn Read-Only Replicas

Q: I want to offload some of my reporting workload to an AlwaysOn replica. How can I configure my AlwaysOn replica to allow read-only access?

A: While the primary replica allows read-write access by default, no connections are allowed to secondary replicas. If you want to a read-only SQL Server AlwaysOn replica, you need to specify the ALLOW_CONNECTIONS=READ_ONLY keyword or the secondary replica.

The following T-SQL example shows how you can add a read-enabled secondary replica to an existing AlwaysOn Availability group named MYSQLServerAG on the host named ORPORTSQL01.

ALTER AVAILABILITY GROUP MySQLServerAG   ADD REPLICA ON      'ORPORTSQL01' WITH         (         ENDPOINT_URL = 'TCP://ORPORTSQL01:7022',         PRIMARY_ROLE ( ALLOW_CONNECTIONS = READ_WRITE ),         SECONDARY_ROLE (ALLOW_CONNECTIONS = READ_ONLY )         );GO

Related: Microsoft SQL Server 2012: AlwaysOn Availability Groups Feature

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like