淺析SQL Server數據庫專用管理員連接DAC的使用
當SQL Server因系統(tǒng)資源不足,或其它異常導致無法建立數據庫連接時, 可以使用系統(tǒng)預留的DAC連接到數據庫,進行一些問題診斷和故障排除。DAC只能使用有限的資源。請勿使用DAC運行需要消耗大量資源的查詢,否則可能發(fā)生嚴重的阻塞。可在聯機幫助中搜索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) 已成功與服務器建立連接,但是在登錄過程中發(fā)生錯誤。
原因為已經存在一個活動的DAC連接,不允許建立第二個DAC連接。 這條描述可以在ErrorLog中看到。
檢查當前已建立的的DAC連接命令如下:
- SELECT t2.session_id
- FROM sys.tcp_endpoints as t1 JOIN sys.dm_exec_sessions as t2
- ON t1.endpoint_id =t2.endpoint_id
- WHERE t1.name='Dedicated Admin Connection'
- SELECT t2.session_id
- FROM sys.tcp_endpoints as t1 JOIN sys.dm_exec_sessions as t2
- ON t1.endpoint_id = t2.endpoint_id
- WHERE t1.name='Dedicated Admin Connection'
除本地支持DAC連接外,也可以打開遠程DAC連接功能, 打開命令如下:
- sp_configure 'remote admin connections', 1;
- GO
- RECONFIGURE;
- GO
- sp_configure 'remote admin connections', 1;
- GO
- RECONFIGURE;
- GO
本文就介紹到這里,如果想了解更多關于SQL Server數據庫的文章,可以到這里:http://database.51cto.com/sqlserver/。
【編輯推薦】