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

cow977發表於2019-08-22

LISTENER 'dns_name'(<listener_option>)

定義此可用性組的新可用性組偵聽器。Defines a new availability group listener for this availability group. LISTENER是一個可選引數。LISTENER is an optional argument.

重點 Important

在建立第一個偵聽器之前,強烈建議您閱讀“建立或配置可用性組偵聽器(SQL Server)”。Before you create your first listener, we strongly recommend that you read .

為給定的可用性組建立偵聽器之後,強烈建議您執行以下操作:After you create a listener for a given availability group, we strongly recommend that you do the following:

l   請您的網路管理員保留偵聽器的IP地址,供其專用。Ask your network administrator to reserve the listener's IP address for its exclusive use.

l   嚮應用程式開發人員提供偵聽器的DNS主機名,以便在請求客戶端連線到此可用性組時在連線字串中使用。Give the listener's DNS host name to application developers to use in connection strings when requesting client connections to this availability group.

dns_name

指定可用性組偵聽器的DNS主機名。Specifies the DNS host name of the availability group listener. 偵聽器的DNS名稱在域和Netbios中必須是唯一的。The DNS name of the listener must be unique in the domain and in NetBIOS.

DNS_name 是一個字串值。 dns_name is a string value. 此名稱只能按任何順序包含字母數字字元、破折號(-)和連字元(_)。This name can contain only alphanumeric characters, dashes (-), and hyphens (_), in any order. DNS主機名不區分大小寫。DNS host names are case insensitive. 最大長度為63個字元。The maximum length is 63 characters.

我們建議您指定一個有意義的字串。We recommend that you specify a meaningful string. 例如,對於名為ag1的可用性組,有意義的DNS主機名將是 ag1-listener 。For example, for an availability group named AG1 , a meaningful DNS host name would be ag1-listener .

重點 Important

NetBIOS 只識別DNS名稱中的前15個字元。NetBIOS recognizes only the first 15 chars in the dns_name. 如果有兩個由同一個Active Directory控制的WSFC群集,並且試圖在兩個群集中使用名稱超過15個字元和相同的15個字元字首建立可用性組偵聽器,則會產生“虛擬網路名稱資源不能線上”的錯誤報告。If you have two WSFC clusters that are controlled by the same Active Directory and you try to create availability group listeners in both clusters using names with more than 15 characters and an identical 15 character prefix, an error reports that the Virtual Network Name resource could not be brought online. 有關DNS名稱的字首命名規則的資訊,請參閱分配域名。For information about prefix naming rules for DNS names, see .

<listener_option> 偵聽器接受以下選項之一:<listener_option> LISTENER takes one of the following <listener_option> options:

WITH DHCP [ ON { ('four_part_ipv4_address','four_part_ipv4_mask') } ]

指定可用性組偵聽器使用動態主機配置協議(DHCP)。Specifies that the availability group listener uses the Dynamic Host Configuration Protocol (DHCP).或者,使用ON子句標識在其上建立此偵聽器的網路。Optionally, use the ON clause to identify the network on which this listener is created. DHCP僅限於一個子網,該子網用於承載可用性組中副本的每個伺服器例項。DHCP is limited to a single subnet that is used for every server instances that hosts a replica in the availability group.

重點 Important

我們不建議在生產環境中使用DHCP。We do not recommend DHCP in production environment. 如果有停機時間並且DHCP IP租約過期,則需要額外的時間註冊與偵聽器DNS名稱關聯的新的DHCP網路IP地址並影響客戶端連線。If there is a down time and the DHCP IP lease expires, extra time is required to register the new DHCP network IP address that is associated with the listener DNS name and impact the client connectivity. 但是,DHCP對於設定開發和測試環境以驗證可用性組的基本功能以及與應用程式整合都是很好的。However, DHCP is good for setting up your development and testing environment to verify basic functions of availability groups and for integration with your applications.

例如:For example:

WITH DHCP ON ('10.120.19.0','255.255.254.0')

WITH IP ( { ('four_part_ipv4_address','four_part_ipv4_mask') | ('ipv6_address') } [ , ...n ] ) [ , PORT =listener_port ]

指定可用性組偵聽器使用一個或多個靜態IP地址,而不是使用DHCP。Specifies that, instead of using DHCP, the availability group listener uses one or more static IP addresses. 要跨多個子網建立可用性組,每個子網在偵聽器配置中需要一個靜態IP地址。To create an availability group across multiple subnets, each subnet requires one static IP address in the listener configuration. 對於給定的子網,靜態IP地址可以是IPv4地址或IPv6地址。For a given subnet, the static IP address can be either an IPv4 address or an IPv6 address. 請與網路管理員聯絡,以獲取承載新可用性組副本的每個子網的靜態IP地址。Contact your network administrator to get a static IP address for each subnet that hosts a replica for the new availability group.

例如:For example:

WITH IP ( ('10.120.19.155','255.255.254.0') )

ipv4_address

指定可用性組偵聽器的IPv4四部分地址。Specifies an IPv4 four-part address for an availability group listener. 例如,10.120.19.155。For example, 10.120.19.155 .

ipv4_mask

指定可用性組偵聽器的IPv4四部分掩碼。Specifies an IPv4 four-part mask for an availability group listener. 例如,255.255.254.0。For example, 255.255.254.0 .

ipv6_address

指定可用性組偵聽器的IPv6地址。Specifies an IPv6 address for an availability group listener. 例如,2001:4898:23:1002:20F:1FF:FEFF:B3A3。For example, 2001::4898:23:1002:20f:1fff:feff:b3a3 .

PORT = listener_port

指定由WITH IP子句指定的可用性組偵聽器使用的埠號。Specifies the port number-listener _port-to be used by an availability group listener that is specified by a WITH IP clause. PORT選項是可選的。PORT is optional.

支援預設埠號1433。The default port number, 1433, is supported. 但是,如果您有安全問題,我們建議使用其他埠號。However, if you have security concerns, we recommend using a different port number.

例如:For example: WITH IP ( ('2001::4898:23:1002:20f:1fff:feff:b3a3') ) , PORT = 7777


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

相關文章