您好,登錄后才能下訂單哦!
SQL Server專用管理員連接(Dedicated Admin Connection(DAC))
只有 SQL Server sysadmin 角色的成員可以使用 DAC 連接。默認情況下,只能從服務器上運行的客戶端建立連接。
打開SSMS,在“Connect to Server”窗口,選擇“Cancel”,然后選擇File菜單,下拉菜單選擇“New”、“Database Engine Query”。
輸入“admin:.”,點擊“Connect”。
默認不允許使用網絡連接DAC,需要通過sp_configure配置“remote admin connections”選項。
先來看看配置的默認值:
SELECT * FROM sys.configurations where name = 'remote admin connections'
或者
sp_configure 'remote admin connections'
Value默認為0,指明僅允許本地連接使用 DAC。Maximum為1,表明只運行一個遠程管理連接。
--啟用遠程DAC連接 sp_configure 'remote admin connections', 1; GO RECONFIGURE; GO
輸出:
Configuration option 'remote admin connections' changed from 0 to 1. Run the RECONFIGURE statement to install.
然后開啟SQL Server Browser服務,防火墻允許TCP 1434端口的訪問。
我們通過另一臺服務器上的SSMS建立DAC查詢連接,選擇File菜單,下拉菜單選擇“New”、“Database Engine Query”。
輸入域名或IP即可。
DAC在SSMS連接時,只能通過建立查詢窗口的方式打開。當SQL Server因系統資源不足,或其它異常導致無法建立數據庫連接時, 可以使用系統預留的DAC連接到數據庫,進行一些問題診斷和故障排除。DAC只能使用有限的資源。請勿使用DAC運行需要消耗大量資源的查詢,否則可能發生嚴重的阻塞。
另一種打開方式是在命令行界面通過SqlCMD使用特殊的管理員開關(-A),提供對DAC的支持。
本地DAC連接:
遠程DAC連接:
《SQL Server 2012 Internals》有這么一段話:
“
SQL Server maintains a set of tables that store information about all objects, data types, constraints,confguration options, and resources available to SQL Server. In SQL Server 2012, these tables are called the system base tables. Some of the system base tables exist only in the master database and contain system-wide information; others exist in every database (including master) and contain information about the objects and resources belonging to that particular database. Beginning with SQL Server 2005, the system base tables aren’t always visible by default, in master or any other database. You won’t see them when you expand the tables node in the Object Explorer in SQL Server Management Studio, and unless you are a system administrator, you won’t see them when you execute the sp_help system procedure. If you log on as a system administrator and select from the catalog view called sys.objects (discussed shortly), you can see the names of all the system tables. For example, the following query returns 74 rows of output on my SQL Server 2012 instance:
USE master;
SELECT name FROM sys.objects
WHERE type_desc = 'SYSTEM_TABLE';
But even as a system administrator, if you try to select data from one of the tables returned by the preceding query, you get a 208 error, indicating that the object name is invalid. The only way to see the data in the system base tables is to make a connection using the dedicated administrator connection (DAC), which Chapter 2, “The SQLOS,” explains in the section titled “The scheduler.” Keep in mind that the system base tables are used for internal purposes only within the Database Engine and aren’t intended for general use. They are subject to change, and compatibility isn’t guaranteed. In SQL Server 2012, three types of system metadata objects are intended for general use: Compatibility Views, Catalog Views, and Dynamic Management Objects.
”
例如,在SSMS中連接普通查詢連接,輸入:
SELECT * FROM sys.sysrmtlgns;
輸出:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'sys.sysrmtlgns'.
建立DAC連接,輸入:
SELECT net_transport,auth_scheme,client_net_address FROM sys.dm_exec_connections WHERE session_id=@@spid; SELECT * FROM sys.sysrmtlgns; SELECT * FROM sys.syslnklgns;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。