指定服务器网络地址(数据库镜像)Specify a Server Network Address (Database Mirroring)

适用对象: yesSQL ServeryesAzure SQL 数据库noAzure SQL 数据仓库no并行数据仓库APPLIES TO: yesSQL Server noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

设置数据库镜像会话要求每个服务器实例都有一个服务器网络地址。Setting up a database mirroring session requires a server network address for each of the server instances. 服务器实例的服务器网络地址必须通过提供系统地址和实例侦听的端口号来明确标识该实例。The server network address of a server instance must unambiguously identify the instance by providing a system address and the number of the port on which the instance is listening.

在服务器网络地址中指定一个端口之前,服务器实例上必须具有数据库镜像端点。Before you can specify a port in a server network address, the database mirroring endpoint must exist on the server instance. 有关详细信息,请参阅 为 Windows 身份验证创建数据库镜像终结点 (Transact-SQL)For more information, see Create a Database Mirroring Endpoint for Windows Authentication (Transact-SQL).

服务器网络地址的语法Syntax for a Server Network Address

服务器网络地址的语法格式如下:The syntax for a server network address is of the form:

TCP://<system-address>:<port>TCP://<system-address>:<port>

其中where

  • <system-address> 是明确标识目标计算机系统的字符串。<system-address> is a string that unambiguously identifies the destination computer system. 通常,服务器地址是系统名称(如果各系统都在同一个域中)、完全限定域名或 IP 地址:Typically, the server address is a system name (if the systems are in the same domain), a fully qualified domain name, or an IP address:

    • 如果各系统都在同一个域中,则可以使用计算机系统的名称;例如, SYSTEM46If the systems are the same domain, you can use the name of the computer system; for example, SYSTEM46.

    • 若要使用 IP 地址,则该地址在您环境中必须是唯一的。To use an IP address, it must be unique in your environment. 建议只使用静态的 IP 地址。We recommend that you use an IP address only if it is static. IP 地址可以是 IP 版本 4 (IPv4) 或 IP 版本 6 (IPv6)。The IP address can be IP Version 4 (IPv4) or IP Version 6 (IPv6). 必须用方括号将 IPv6 地址括起,例如:[<IPv6_address>]An IPv6 address must be enclosed within square brackets, for example: [<IPv6_address>].

      若要了解系统的 IP 地址,则在 Windows 命令提示符处,输入 ipconfig 命令。To learn the IP address of a system, at the Windows command prompt, enter the ipconfig command.

    • 保证完全限定域名的有效性。The fully qualified domain name is guaranteed to work. 它是在不同位置具有不同形式的本地定义的地址字符串。This is a locally defined address string that different forms in different places. 通常(但并不总是),完全限定域名是一个复合名称,包含计算机名称和一系列句点分隔的域段,其格式为:Often, but not always, a fully qualified domain name is a compound name that includes the computer name and a series of period-separated domain segments of the form:

      computer_name computer_name . domain_segment[....domain_segment]domain_segment[....domain_segment]

      其中, computer_name是运行服务器实例的计算机的网络名称, domain_segment[....domain_segment] 是服务器的其余域信息;例如: localinfo.corp.Adventure-Works.comwhere computer_name is the network name of the computer running the server instance, and domain_segment[....domain_segment] is the remaining domain information of the server; for example: localinfo.corp.Adventure-Works.com.

      在公司或组织内确定域段的内容和数量。The content and number of domain segments are determined within the company or organization. 如果您不知道服务器的完全限定域名,请与系统管理员联系。If you do not know the fully qualified domain name for your server, see your system administrator.

      备注

      有关如何查找完全限定域名的信息,请参阅本主题后面的“查找完全限定域名”。For information about how to find a fully qualified domain name, see "Finding the Fully Qualified Domain Name," later in this topic.

  • <port> 是合作伙伴服务器实例的镜像终结点所使用的端口号。<port> is the port number used by the mirroring endpoint of the partner server instance. 有关指定终结点的信息,请参阅 为 Windows 身份验证创建数据库镜像终结点 (Transact-SQL)For information about specifying an endpoint, see Create a Database Mirroring Endpoint for Windows Authentication (Transact-SQL).

    数据库镜像端点可以使用计算机系统上的任意可用端口。A database mirroring endpoint can use any available port on the computer system. 计算机系统上的每个端口号只能与一个端点相关联,而每个端点与一个服务器实例相关联;这样,同一服务器上的不同服务器实例便可使用不同端口来侦听各个端点。Each port number on a computer system must be associated with only one endpoint, and each endpoint is associated with a single server instance; thus, different server instances on the same server listen on different endpoints with different ports. 因此,设置数据库镜像会话时在服务器网络地址中指定的端口会始终将会话定向到其端点与该端口关联的服务器实例。Therefore, the port you specify in the server network address when you set up a database mirroring session will always direct the session to the server instance whose endpoint is associated with that port.

    在服务器实例的服务器网络地址中,只有通过与其镜像端点关联的端口号才能将实例与计算机上的所有其他实例区分开来。In the server network address of a server instance, only the number of the port associated with its mirroring endpoint distinguishes that instance from any other instances on the computer. 下图显示了一台计算机上两个服务器实例的服务器网络地址。The following figure illustrates the server network addresses of two server instances on a single computer. 默认实例使用端口 7022 ,命名实例使用端口 7033The default instance uses port 7022 and the named instance uses port 7033. 这两个服务器实例的服务器网络地址分别为: TCP://MYSYSTEM.Adventure-works.MyDomain.com:7022TCP://MYSYSTEM.Adventure-works.MyDomain.com:7033The server network address for these two server instances are, respectively: TCP://MYSYSTEM.Adventure-works.MyDomain.com:7022 and TCP://MYSYSTEM.Adventure-works.MyDomain.com:7033. 请注意,地址中不包含服务器实例名。Note that the address does not contain the name of the server instance.

    默认实例的服务器网络地址Server network addresses of a default instance

    若要标识当前与服务器实例的数据库镜像端点关联的端口,请使用以下 Transact-SQLTransact-SQL 语句:To identify the port currently associated with database mirroring endpoint of a server instance, use the following Transact-SQLTransact-SQL statement:

    SELECT type_desc, port FROM sys.tcp_endpoints  
    

    找到 type_desc 值为“DATABASE_MIRRORING”的行,然后使用对应的端口号。Find the row whose type_desc value is "DATABASE_MIRRORING," and use the corresponding port number.

示例Examples

A.A. 使用系统名称Using a system name

以下服务器网络地址指定系统名称 SYSTEM46和端口 7022The following server network address specifies a system name, SYSTEM46, and port 7022.

ALTER DATABASE AdventureWorks SET PARTNER ='tcp://SYSTEM46:7022';  

B.B. 使用完全限定域名Using a fully qualified domain name

以下服务器网络地址指定完全限定域名 DBSERVER8.manufacturing.Adventure-Works.com和端口 7024The following server network address specifies a fully qualified domain name, DBSERVER8.manufacturing.Adventure-Works.com, and port 7024.

ALTER DATABASE AdventureWorks SET PARTNER ='tcp://DBSERVER8.manufacturing.Adventure-Works.com:7024';  

C.C. 使用 IPv4Using IPv4

以下服务器网络地址指定 IPv4 地址 10.193.9.134和端口 7023The following server network address specifies an IPv4 address, 10.193.9.134, and port 7023.

ALTER DATABASE AdventureWorks SET PARTNER ='tcp://10.193.9.134:7023';  

D.D. 使用 IPv6Using IPv6

以下服务器网络地址包含 IPv6 地址 2001:4898:23:1002:20f:1fff:feff:b3a3和端口 7022The following server network address contains an IPv6 address, 2001:4898:23:1002:20f:1fff:feff:b3a3, and port 7022.

ALTER DATABASE AdventureWorks SET PARTNER ='tcp://[2001:4898:23:1002:20f:1fff:feff:b3a3]:7022';  

查找完全限定域名Finding the Fully Qualified Domain Name

若要查找系统的完全限定域名,请在该系统的 Windows 命令提示符下,输入:To find the fully qualified domain name of a system, at the Windows command prompt on that system, enter:

IPCONFIG /ALLIPCONFIG /ALL

若要形成完全限定的域名,请将 <host_name><Primary_Dns_Suffix> 的值连接一起,如下所示:To form the fully qualified domain name, concatenate the values of <host_name> and <Primary_Dns_Suffix> as follows:

<host_name> .<host_name> . <Primary_Dns_Suffix><Primary_Dns_Suffix>

例如,IP 配置For example, the IP configuration

Host Name . . . . . . : MYSERVER

Primary Dns Suffix . . . : mydomain.Adventure-Works.com

等同于以下完全限定域名:equates to the following fully qualified domain name:

MYSERVER.mydomain.Adventure-Works.com

示例Examples

以下示例显示了其他域中名为 REMOTESYSTEM3 的计算机系统上的某个服务器实例的服务器网络地址。The following example shows the server network address for a server instance on a computer system named REMOTESYSTEM3 in another domain. 域信息为 NORTHWEST.ADVENTURE-WORKS.COM,数据库镜像端点的端口为 7025The domain information is NORTHWEST.ADVENTURE-WORKS.COM, and the port of the database mirroring endpoint is 7025. 假设具有这些示例组件,则服务器网络地址将为:Given these example components, the server network address is.

TCP://REMOTESYSTEM3.NORTHWEST.ADVENTURE-WORKS.COM:7025

以下示例显示了名为 DBSERVER1的计算机系统上的某个服务器实例的服务器网络地址。The following example shows the server network address for a server instance on a computer system named DBSERVER1. 此系统位于本地域中,并由其系统名称明确标识。This system is in the local domain and is unambiguously identified by its system name. 数据库镜像端点的端口为 7022The port of the database mirroring endpoint is 7022.

TCP://DBSERVER1:7022

相关任务Related Tasks

另请参阅See Also

数据库镜像 (SQL Server) Database Mirroring (SQL Server)
数据库镜像终结点 (SQL Server)The Database Mirroring Endpoint (SQL Server)