[AlwaysOn] 创建SQL Server高可用性组T-SQL语法:LISTENER子句

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 Create or Configure an Availability Group Listener (SQL Server).

为给定的可用性组创建侦听器之后,强烈建议您执行以下操作: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 Assigning Domain Names.

<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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/81227/viewspace-2654518/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值