[AlwaysOn] 建立SQL Server高可用性組T-SQL語法:PRIMARY_ROLE子句

cow977發表於2019-08-20

PRIMARY_ROLE ( ... )

指定當此可用性副本當前擁有主要角色(即,無論何時為主要副本)時生效的特定於角色的設定。Specifies role-specific settings that take effect if this availability replica currently owns the primary role (that is, whenever it is the primary replica). 在括號內,指定一個或兩個主要角色選項。Within the parentheses, specify either or both primary-role options. 如果兩者都指定,請使用逗號分隔的列表。If you specify both, use a comma-separated list.

主要角色選項如下:The primary role options are as follows:

ALLOW_CONNECTIONS = { READ_WRITE | ALL }

指定執行主要角色(即充當主要副本)的給定可用性副本的資料庫可以從客戶端接受的連線型別,其中之一:Specifies the type of connection that the databases of a given availability replica that is performing the primary role (that is, is acting as a primary replica) can accept from clients, one of:

READ_WRITE

不允許將應用程式意向連線屬性設定為只讀的連線。Connections where the Application Intent connection property is set to ReadOnly are disallowed. 當Application Intent屬性設定為ReadWrite或未設定Application Intent連線屬性時,允許進行連線。When the Application Intent property is set to ReadWrite or the Application Intent connection property is not set, the connection is allowed.有關應用程式意向連線屬性的詳細資訊,請參閱將連線字串關鍵字用於SQL Server本機客戶端。For more information about Application Intent connection property, see .

ALL

允許所有連線到主副本中的資料庫。All connections are allowed to the databases in the primary replica. 這是預設行為。This is the default behavior.

READ_ONLY_ROUTING_LIST = { ('<server_instance>' [ ,...n ] ) | NONE }

指定在輔助角色下執行時承載此可用性組的可用性副本並滿足以下要求的伺服器例項的逗號分隔列表:Specifies a comma-separated list of server instances that host availability replicas for this availability group that meet the following requirements when running under the secondary role:

l   配置為允許所有連線或只讀連線(見上文輔助角色選項的“允許連線”引數)。Be configured to allow all connections or read-only connections (see the ALLOW_CONNECTIONS argument of the SECONDARY_ROLE option, above).

l   定義其只讀路由URL(見上文輔助角色選項的只讀路由URL引數)。Have their read-only routing URL defined (see the READ_ONLY_ROUTING_URL argument of the SECONDARY_ROLE option, above).

只讀路由列表值如下:The READ_ONLY_ROUTING_LIST values are as follows:

<server_instance> 指定作為副本主機的SQL Server例項的地址,該副本在輔助角色下執行時是可讀的輔助副本。<server_instance> Specifies the address of the instance of SQL Server that is the host for a replica that is a readable secondary replica when running under the secondary role.

使用逗號分隔的列表指定可能承載可讀的輔助副本的所有伺服器例項。Use a comma-separated list to specify all the server instances that might host a readable secondary replica. 只讀路由遵循在列表中指定伺服器例項的順序。Read-only routing follows the order in which server instances are specified in the list. 如果在副本的只讀路由列表中包含副本的主機伺服器例項,那麼將此伺服器例項放在列表末尾通常是一個好的做法,這樣,如果有可用的話,讀意向連線將轉到輔助副本。If you include a replica's host server instance on the replica's read-only routing list, placing this server instance at the end of the list is typically a good practice, so that read-intent connections go to a secondary replica, if one is available.

從SQL Server 2016(13.x)開始,您可以在可讀的輔助副本之間負載平衡讀意向請求。Beginning with SQL Server 2016 (13.x), you can load-balance read-intent requests across readable secondary replicas. 您可以透過將副本放置在只讀路由列表中一組巢狀的圓括號中來指定這一點。You specify this by placing the replicas in a nested set of parentheses within the read-only routing list. 有關更多資訊和示例,請參閱跨只讀副本配置負載平衡。For more information and examples, see .

註釋 NONE

指定當此可用性副本是主副本時,不支援只讀路由。Specifies that when this availability replica is the primary replica, read-only routing is not supported.這是預設行為。This is the default behavior.


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/81227/viewspace-2654211/,如需轉載,請註明出處,否則將追究法律責任。

相關文章