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

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) - 仅限 Windows 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) - Windows only 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance

若要参与 Always On 可用性组Always On availability groups 或数据库镜像,服务器实例需要有自己专用的“数据库镜像端点” 。To participate in Always On 可用性组Always On availability groups or database mirroring a server instance requires its own, dedicated database mirroring endpoint. 此端点用途特殊,专门用于接收来自其他服务器实例的这些连接。This endpoint is a special-purpose endpoint that is used exclusively to receive connections from other server instances. 在某一给定服务器实例上,与任何其他服务器实例的每个 Always On 可用性组Always On availability groups 或数据库镜像连接都使用单个数据库镜像端点。On a given server instance, every Always On 可用性组Always On availability groups or database mirroring connection to any other server instance uses a single database mirroring endpoint.

数据库镜像端点使用传输控制协议 (TCP) 在参与数据库镜像会话或承载可用性副本的服务器实例之间发送和接收消息。Database mirroring endpoints use Transmission Control Protocol (TCP) to send and receive messages between the server instances participating database mirroring sessions or hosting availability replicas. 数据库镜像端点在唯一的 TCP 端口号上进行侦听。The database mirroring endpoint listens on a unique TCP port number.

备注

客户端与主体服务器或主副本的连接不使用数据库镜像端点。Client connections to a principal server or primary replica do not use the database mirroring endpoint.

备注

后续版本的 Microsoft SQL Server 将删除数据库镜像功能。The database mirroring feature will be removed in a future version of Microsoft SQL Server. 请避免在新的开发工作中使用该功能,并着手修改当前还在使用数据库镜像的应用程序,以便改用 Always On 可用性组Always On availability groupsAvoid using this feature in new development work, and plan to modify applications that currently use database mirroring to use Always On 可用性组Always On availability groups instead.

服务器网络地址Server Network Address

服务器实例的网络地址(其“服务器网络地址”或“终结点 URL”)包含其端点的端口号,以及主机的系统名称和域名。The network address of a server instance (its server network address or Endpoint URL) contains the port number of its endpoint, as well as the system and domain name of its host computer. 端口号唯一标识特定的服务器实例。The port number uniquely identifies a specific server instance.

下图具体说明了如何将同一服务器上的两个服务器实例进行唯一标识。The following figure illustrates how two server instances on the same server are uniquely identified. 两个服务器实例的服务器网络地址均包含相同的系统名称 MYSYSTEM和域名 Adventure-Works.MyDomain.comThe server network addresses of both server instances contain the same system name, MYSYSTEM, and domain name, Adventure-Works.MyDomain.com. 若要使系统能够路由到服务器实例的连接,服务器网络地址需要包括与特定服务器实例的镜像端点相关联的端口号。To enable the system to route connections to a server instance, a server network address includes the port number associated with the mirroring endpoint of a particular server instance.

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

默认情况下, SQL ServerSQL Server 实例不包含数据库镜像端点。By default, an instance of SQL ServerSQL Server does not contain a database mirroring endpoint. 在建立数据库镜像会话时,必须手动创建它们。These must be created manually as part of setting up a database mirroring session. 系统管理员必须在将要参与数据库镜像的每个服务器实例中分别创建端点。The system administrator must create a separate endpoint in each server instance that is to participate in database mirroring. 请注意,如果某一给定计算机上的多个服务器实例要求数据库镜像端点,则为每个端点都指定不同的端口号。Note that if more than one server instance on a given computer requires a database mirroring endpoint, specify a different port number for each endpoint.

重要

如果运行 SQL ServerSQL Server 的计算机具有防火墙,则防火墙配置必须允许端点中指定的端口的传入和发送连接。If the computer running SQL ServerSQL Server has a firewall, the firewall configuration must allow both incoming and outgoing connections for the port specified in the endpoint.

对于数据库镜像和 Always On 可用性组Always On availability groups,身份验证和加密在端点配置。For database mirroring and Always On 可用性组Always On availability groups, authentication and encryption are configured on the endpoint. 有关详细信息,请参阅 针对数据库镜像和 AlwaysOn 可用性组的传输安全性 (SQL Server)For more information, see Transport Security for Database Mirroring and Always On Availability Groups (SQL Server).

重要

请勿重新配置正在使用的数据库镜像端点。Do not reconfigure an in-use database mirroring endpoint. 服务器实例使用彼此的端点来了解其他系统的状态。The server instances use each other's endpoints to learn the state of the other systems. 如果重新配置端点,则可能会重新启动此端点,从而导致其他服务器实例出现错误。If the endpoint is reconfigured, it might restart, which can appear to be an error to the other server instances. 这对于自动故障转移模式尤为重要,在此模式下,在伙伴上重新配置端点可能会导致故障转移。This is particularly important for automatic failover mode, in which reconfiguring the endpoint on a partner could cause a failover to occur.

为数据库镜像端点确定身份验证类型Determining the Authentication Type for a Database Mirroring Endpoint

理解您的服务器实例的 SQL ServerSQL Server 服务帐户将确定您可以将何种类型的身份验证用于数据库镜像端点十分重要,下面将阐释这一点:It is important to understand that the SQL ServerSQL Server service accounts of your server instances determine what type of authentication you can use for your database mirroring endpoints, as follows:

  • 如果每个服务器实例都在某一域服务帐户下运行,则您可以将 Windows 身份验证用于您的数据库镜像端点。If every server instance is running under a domain service account, you can use Windows Authentication for your database mirroring endpoints. 如果所有服务器实例使用相同的域用户帐户运行,则正确的用户登录名将自动存在于全部两个 master 数据库中。If all the server instances run as the same domain user account, the correct user logins exist automatically in both master databases. 这样可简化可用性数据库的安全配置并建议这样做。This simplifies the security configuration for the availability databases and is recommended.

    如果为某一可用性组托管可用性副本的任何服务器实例以不同的帐户身份运行,则必须在其他服务器实例上的 master 中创建每个登录帐户。If any server instances that are hosting the availability replicas for an availability group run as different accounts, the login each account must be created in master on the other server instance. 然后,必须向该登录名授予 CONNECT 权限,以便连接到该服务器实例的数据库镜像端点。Then, that login must be granted CONNECT permissions to connect to the database mirroring endpoint of that server instance. 有关详细信息,请参阅 设置数据库镜像或 AlwaysOn 可用性组的登录帐户 (SQL Server)For more information, Set Up Login Accounts for Database Mirroring or Always On Availability Groups (SQL Server).

    如果您的服务器实例使用 Windows 身份验证,则您可以通过使用 Transact-SQLTransact-SQL、PowerShell 或新建可用性组向导创建数据库镜像端点。If your server instances use Windows Authentication, you can create database mirroring endpoints by using Transact-SQLTransact-SQL, PowerShell, or the New Availability Group Wizard.

    备注

    如果要承载可用性副本的服务器实例缺少数据库镜像端点,则新建可用性组向导可以自动创建使用 Windows 身份验证的数据库镜像端点。If a server instance that is to host an availability replica lacks a database mirroring endpoint, the New Availability Group Wizard can automatically create a database mirroring endpoint that uses Windows Authentication. 有关详细信息,请参阅 使用可用性组向导 (SQL Server Management Studio)For more information, see Use the Availability Group Wizard (SQL Server Management Studio).

  • 如果任何服务器实例正在以内置帐户(例如 Local System、Local Service 或 Network Service)或非域帐户运行,则您必须使用证书来进行端点身份验证。If any server instance is running under a built-in account, such as Local System, Local Service, or Network Service, or a nondomain account, you must use certificates for endpoint authentication. 如果您正在使用证书来用于您的数据库镜像端点,则您的系统管理员必须配置每个服务器实例,以在出站连接和进站连接中使用证书。If you are using certificates for your database mirroring endpoints, your system administrator must configure each server instance to use certificates on both outbound and inbound connections.

    没有使用证书来配置数据库镜像安全性的任何自动方法。There is no automated method for configuring database mirroring security using certificates. 你将需要使用 CREATE ENDPOINT Transact-SQLTransact-SQL 语句或 New-SqlHadrEndpoint PowerShell cmdlet。You will need to use either CREATE ENDPOINT Transact-SQLTransact-SQL statement or the New-SqlHadrEndpoint PowerShell cmdlet. 有关详细信息,请参阅 CREATE ENDPOINT (Transact-SQL)For more information, see CREATE ENDPOINT (Transact-SQL). 有关在服务器实例上启用证书身份验证的信息,请参阅 使用数据库镜像终结点证书 (Transact-SQL)For information about enabling certificate authentication on a server instance, see Use Certificates for a Database Mirroring Endpoint (Transact-SQL).

配置数据库镜像端点To Configure a Database Mirroring Endpoint

查看有关数据库镜像端点的信息To View Information About the Database Mirroring Endpoint

另请参阅See Also

针对数据库镜像和 AlwaysOn 可用性组的传输安全性 (SQL Server) Transport Security for Database Mirroring and Always On Availability Groups SQL Server)
数据库镜像配置故障排除 (SQL Server) Troubleshoot Database Mirroring Configuration (SQL Server)
sys.dm_hadr_availability_replica_states (Transact-SQL) sys.dm_hadr_availability_replica_states (Transact-SQL)
sys.dm_db_mirroring_connections (Transact-SQL)sys.dm_db_mirroring_connections (Transact-SQL)