SQL Server Express 2005使用命令工具设置tcp监听端口
我正在使用以下命令对 SQL Server Express 2005 进行静默安装,
SECURITYMODE=SQL DISABLENETWORKPROTOCOLS=0 SAPWD="****" ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,Client_Components,Connectivity,SDK
我需要知道是否有参数或命令行实用程序来配置服务以侦听端口 7005(参见图片)
http://www.databasejournal.com/img/2007/01/mak_CLT_image002.jpg
- 我还需要创建使用命令行的别名
谢谢
I am making silent installation for SQL Server Express 2005 using the following command
SECURITYMODE=SQL DISABLENETWORKPROTOCOLS=0 SAPWD="****" ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,Client_Components,Connectivity,SDK
I need to know is there a parameter or a command line utility to configure the service to listen to port 7005 (see picture)
http://www.databasejournal.com/img/2007/01/mak_CLT_image002.jpg
- Also I need to create an alias using command line
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我目前正在尝试解决这个问题,这是我发现的:
要使 Sql 服务器完全侦听 TCP,您需要对其进行配置才能执行此操作。您可以使用 sac.exe 从文件加载配置。转到配置为启用 TCP/IP(以及其他任何内容)的工作 SQL 服务器并运行“sac.exe out settings.txt”。现在,在您想要启用 tcp 的计算机上,运行“sac.exe in settings.txt”,然后重新启动该服务。 sac.exe 位于“%programfiles%\Microsoft SQL Server\90\Shared”目录
要配置到特定端口,您必须编辑注册表值。这将向您显示编辑 http://support.microsoft.com/kb/823938 但是,要编写此脚本,您需要在 .bat 文件中使用“REG ADD”命令,并为相应的键提供适当的值。对我来说,它是 HKLM\Microsoft SQL Server\MSSQL.1\MSSQLServer\SuperSocketNetLib\Tcp\IPAll\TcpPort 并将其设置为端口号(sql 默认为 1433),然后设置 HKLM\Microsoft SQL Server\MSSQL.1\ MSSQLServer\SuperSocketNetLib\Tcp\IPAll\TcpDynamicPorts 为空。
重新启动 SQL Server 代理(我的计算机上的 Net Stop "Sql Server (SQLEXPRESS)" Net start "Sql Server (SQLEXPRESS)")
希望这可以帮助您或搜索此信息的其他人(像我一样)
I'm currently trying to mess with this, here's what I've found:
To make Sql server listen on TCP at all, you need to configure it to do so. You can use sac.exe to load a configuration from a file. Go to a working sql server configured with TCP/IP enabled (and whatever else) and run "sac.exe out settings.txt". Now, on a computer you wish to enable tcp on, run "sac.exe in settings.txt" and then restart the service. sac.exe is in the "%programfiles%\Microsoft SQL Server\90\Shared" directory
To configure to a specific port, you'll have to edit the registry values. This will show you the keys to edit http://support.microsoft.com/kb/823938 however to script this, you'll need to use the "REG ADD" command in a .bat file and give the appropriate value to the appropriate key. FOr me, it's HKLM\Microsoft SQL Server\MSSQL.1\MSSQLServer\SuperSocketNetLib\Tcp\IPAll\TcpPort and set it to the port number (default for sql is 1433) and then set HKLM\Microsoft SQL Server\MSSQL.1\MSSQLServer\SuperSocketNetLib\Tcp\IPAll\TcpDynamicPorts to empty.
Restart the SQL Server Agent (Net Stop "Sql Server (SQLEXPRESS)" Net start "Sql Server (SQLEXPRESS)" on my machine)
Hope this helps you or someone else searching for this information (like me)
我知道这更像是一种解决方法,而不是正确的解决方案,但您可以在 SQL Server 静默安装过程中启用 SQL Browser 服务,而不是指定(然后从应用程序连接到)某个 TCP 端口。这将使您的应用程序能够根据实例名称而不是 TCP 端口连接到您感兴趣的实例。
创建新连接时可能会产生性能损失,因为客户端需要额外的网络往返来获取实例的端口,但是(a)对于具有长期连接的客户端-服务器应用程序,它不会是一个问题,并且(b)对于具有连接池的应用程序服务器应用程序,配置良好的池不会受到太大影响(我认为),或者可能需要稍微更多的连接才能实现相同的性能。
另一项优点是,您可以在同一主机上拥有多个 SQL Server 实例,而不必关心端口。例如,在您(和我的)静默安装场景中,您必须首先检查您想要的端口是否被另一个实例使用。使用 SQL 浏览器,您的安装中就不再需要此逻辑。
I know this is more a workaround than a proper solution, but instead of specifying (and then connecting to from your application) a certain TCP port, you can instead enable the SQL Browser service during the silent installation of SQL Server. This will enable your app to connect to the instance you're interested based on the Instance Name, not the TCP port.
It may have a performance penalty on creating a new connection, since an additional network round-trip is needed for the client to acquire the port for the Instance, but (a) for client-server apps with long-living connections it won't be a problem, and (b) for app-server apps with connection pooling, a well-configured pool won't be affected much (I think), or it may need slightly more connections to achieve the same performance.
An additional advantage is that you can have more than one SQL Server instance on the same host and not care about ports. For example, in your (and mine) silent installation scenario, you would have to first check whether the port you want is used by another instance. Using the SQL Browser removes the need for this logic in your installation.