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

cow977發表於2019-08-20

SECONDARY_ROLE ( ... )

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

輔助角色選項如下:The secondary role options are as follows:

ALLOW_CONNECTIONS = { NO | READ_ONLY | ALL }

指定執行輔助角色(即充當輔助副本)的給定可用性副本的資料庫是否可以接受來自客戶端的連線,其中之一:Specifies whether the databases of a given availability replica that is performing the secondary role (that is, is acting as a secondary replica) can accept connections from clients, one of:

NO

不允許使用者連線到此副本的輔助資料庫。No user connections are allowed to secondary databases of this replica. 它們不可用於讀取訪問。They are not available for read access. 這是預設行為。This is the default behavior.

READ_ONLY

僅允許連線到輔助副本中的資料庫,其中application intent屬性設定為readonly。Only connections are allowed to the databases in the secondary replica where the Application Intent property is set to ReadOnly. 有關此屬性的詳細資訊,請參閱將連線字串關鍵字用於SQL Server本機客戶端。For more information about this property, see .

ALL

允許所有到輔助副本中資料庫的連線進行只讀訪問。All connections are allowed to the databases in the secondary replica for read-only access.

有關詳細資訊,請參閱活動的輔助副本:可讀的輔助副本(始終在可用性組上)。For more information, see .

READ_ONLY_ROUTING_URL ='TCP://system-address:port'

指定用於將只讀連線請求路由到此可用性副本的URL。Specifies the URL to be used for routing read-intent connection requests to this availability replica. 這是SQL Server資料庫引擎偵聽的URL。This is the URL on which the SQL Server Database Engine listens. 通常,SQL Server資料庫引擎的預設例項偵聽TCP 1433埠。Typically, the default instance of the SQL Server Database Engine listens on TCP port 1433.

對於命名例項,可以透過查詢sys.dm_tcp_listener_states動態管理檢視的port和type_desc列來獲取埠號。For a named instance, you can obtain the port number by querying the port and type_desc columns of the dynamic management view. 伺服器例項使用Transact-SQL偵聽器(type_desc='tsql')。The server instance uses the Transact-SQL listener ( type_desc='TSQL').

有關計算副本的只讀路由URL的詳細資訊,請參閱計算AlwaysOn的只讀路由URL。For more information about calculating the read-only routing URL for a replica, see Calculating read_only_routing_url for Always On.

註釋 Note

對於SQL Server的命名例項,應將Transact-SQL偵聽器配置為使用特定埠。For a named instance of SQL Server, the Transact-SQL listener should be configured to use a specific port. 有關詳細資訊,請參閱配置伺服器以偵聽特定的TCP埠(SQL Server配置管理器)。For more information, see .


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

相關文章