浅析SQL Server数据库专用管理员连接DAC的使用

树叶云

SQL Server因系统资源不足,或其它异常导致无法建立数据库连接时, 可以使用系统预留的DAC连接到数据库,进行一些问题诊断和故障排除。DAC只能使用有限的资源。请勿使用DAC运行需要消耗大量资源的查询,否则可能发生严重的阻塞。可在联机帮助中搜索DAC。

建议使用命令行下的sqlcmd连接进去,因为占用的资源更少,连接方法:开始 –> 运行 –> cmd 输入SQLCMD -E -SMQLinstance1 -A&(说明,-A即为指定DAC,其它参数见《联机帮助》)。

使用SQL Server Management Studio建立DAC连接时,服务器一栏输入:admin:主机名\实例名。

如果连接报错: “不支持管理员连接”,英文为:”Cannot connect to admin:SQLSERVER2008R2.”

原因为:This is because you can’t connect to the DAC in object explorer. You can however connect to it from a query window from management studio click <file> <New Database Engine Query>不能在“对象管理员”中使用DAC进行连接,可以在SQL Server Management Studio的菜单“文件 –> 新建 –> 数据库引擎查询”,再输入admin:主机名\实例名。

如果连接报错:A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 – The specified network name is no longer available.) (Microsoft SQL Server, Error: 64) 已成功与服务器建立连接,但是在登录过程中发生错误。

原因为已经存在一个活动的DAC连接,不允许建立第二个DAC连接。 这条描述可以在ErrorLog中看到。

检查当前已建立的的DAC连接命令如下:

  1. SELECT t2.session_id  
  2.  
  3. FROM sys.tcp_endpoints as t1 JOIN sys.dm_exec_sessions as t2  
  4.  
  5. ON t1.endpoint_id =t2.endpoint_id  
  6.  
  7. WHERE t1.name='Dedicated Admin Connection' 
  8.  
  9. SELECT t2.session_id  
  10.  
  11. FROM sys.tcp_endpoints as t1 JOIN sys.dm_exec_sessions as t2  
  12.  
  13. ON t1.endpoint_id = t2.endpoint_id  
  14.  
  15. WHERE t1.name='Dedicated Admin Connection' 

除本地支持DAC连接外,也可以打开远程DAC连接功能, 打开命令如下:

  1. sp_configure 'remote admin connections', 1;  
  2.  
  3. GO  
  4.  
  5. RECONFIGURE;  
  6.  
  7. GO  
  8.  
  9. sp_configure 'remote admin connections', 1;  
  10.  
  11. GO  
  12.  
  13. RECONFIGURE;  
  14.  
  15. GO 

本文就介绍到这里,如果想了解更多关于SQL Server数据库的文章,可以到这里:http://database./sqlserver/。

【编辑推荐】

  1. 在Sql Server 2005中导出登录用户信息脚本
  2. 使用SQL Trace来实现SQL Server的跟踪操作
  3. 用CHARINDEX方法实现对字段按指定顺序排序
  4. 在SQL SERVER 2005执行存储过程的权限分配问题
  5. 简述删除SQL SERVER 2000数据库日志的两种方法

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/251179.html<

(0)
运维的头像运维
上一篇2025-04-28 20:43
下一篇 2025-04-28 20:45

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注