隐藏 SQL Server 数据库引擎的实例Hide an Instance of SQL Server Database Engine

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

本主题说明如何使用 SQL Server 配置管理器在 数据库引擎Database Engine 中隐藏 SQL Server 2017SQL Server 2017 实例。This topic describes how to hide an instance of the 数据库引擎Database Engine in SQL Server 2017SQL Server 2017 by using SQL Server Configuration Manager. SQL ServerSQL Server 使用 SQL ServerSQL Server 浏览器服务来枚举安装在计算机上的 数据库引擎Database Engine 实例。uses the SQL ServerSQL Server Browser service to enumerate instances of the 数据库引擎Database Engine installed on the computer. 这使客户端应用程序可以浏览服务器,并帮助客户端区别同一台计算机上的多个 数据库引擎Database Engine 实例。This enables client applications to browse for a server, and helps clients distinguish between multiple instances of the 数据库引擎Database Engine on the same computer. 您可以使用以下过程防止 SQL Server Browser 服务向尝试通过使用 数据库引擎Database Engine “浏览” 按钮来查找实例的客户端计算机公开 实例。You can use the following procedure to prevent the SQL Server Browser service from exposing an instance of the 数据库引擎Database Engine to client computers that try to locate the instance by using the Browse button.

使用 SQL Server 配置管理器Using SQL Server Configuration Manager

隐藏 SQL Server 数据库引擎实例To hide an instance of the SQL Server Database Engine

  1. 在“SQL Server 配置管理器”中,展开“SQL Server 网络配置”、右键单击“<服务器实例> 的协议”,然后选择“属性” 。In SQL Server Configuration Manager, expand SQL Server Network Configuration, right-click Protocols for <server instance>, and then select Properties.

  2. “标志” 选项卡的 “隐藏实例” 框中,选择 “是” ,然后单击 “确定” 关闭对话框。On the Flags tab, in the HideInstance box, select Yes, and then click OK to close the dialog box. 对于新连接,更改会立即生效。The change takes effect immediately for new connections.

RemarksRemarks

如果你隐藏命名实例,你将需要在连接字符串中提供端口号才能连接到隐藏的实例,即使浏览器服务正在运行也是如此。If you hide a named instance, you will need to provide the port number in the connection string to connect to the hidden instance, even if the browser service is running. 对于命名隐藏实例,我们建议你使用静态端口而不是动态端口。We recommend that you use a static port instead of a dynamic port for the named hidden instance.
有关详细信息,请参阅将服务器配置为侦听特定 TCP 端口(SQL Sever 配置管理器)For more information, see Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager).

群集Clustering

如果你隐藏群集命名实例,则群集服务可能无法连接到 SQL ServerSQL ServerIf you hide a clustered named instance, cluster service may not be able to connect to SQL ServerSQL Server. 这将导致群集实例的“IsAlive”检查失败,并且 SQL ServerSQL Server 将进入离线状态 。This will cause the cluster instance's IsAlive check to fail and SQL ServerSQL Server will go offline. 我们建议在群集实例的所有节点中创建别名,以反映你为该实例配置的静态端口。We recommend that you create an alias in all the nodes of the clustered instance to reflect the static port that you configured for the instance.
有关详细信息,请参阅创建或删除供客户端使用的服务器别名(SQL Server 配置管理器)For more information, see Create or Delete a Server Alias for Use by a Client (SQL Server Configuration Manager).

如果隐藏群集命名实例,当 LastConnect 注册表项 (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SNI11.0\LastConnect) 具有的端口与SQL ServerSQL Server 正在侦听的端口不同时,群集服务可能无法连接到 SQL ServerSQL ServerIf you hide a clustered named instance, cluster service may not be able to connect to SQL ServerSQL Server if the LastConnect registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SNI11.0\LastConnect) has a different port than the port that SQL ServerSQL Server is listening on. 如果群集服务无法建立与 SQL ServerSQL Server的连接,则你可能会看到类似于以下内容的错误:If the cluster service is unable to make a connection to the SQL ServerSQL Server, you might see an error similar to the following:
事件 ID:1001:事件名称:故障转移群集资源死锁。Event ID: 1001: Event Name: Failover clustering resource deadlock.

另请参阅See Also

服务器网络配置 Server Network Configuration
SQL 虚拟服务器客户端连接的说明 Description of SQL Virtual Server client connections
如何将静态端口分配到 SQL Server 命名实例并避免常见缺陷How to assign a static port to a SQL Server named instance - and avoid a common pitfall