溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

SQL Server專用管理員連接(Dedicated Admin Connection(DAC))

發(fā)布時(shí)間:2020-07-15 21:31:02 來源:網(wǎng)絡(luò) 閱讀:4494 作者:UltraSQL 欄目:數(shù)據(jù)庫

SQL Server專用管理員連接(Dedicated Admin Connection(DAC))

 

只有 SQL Server sysadmin 角色的成員可以使用 DAC 連接。默認(rèn)情況下,只能從服務(wù)器上運(yùn)行的客戶端建立連接。

 

打開SSMS,在“Connect to Server”窗口,選擇“Cancel”,然后選擇File菜單,下拉菜單選擇“New”、“Database Engine Query”。

SQL Server專用管理員連接(Dedicated Admin Connection(DAC))

輸入“admin:.”,點(diǎn)擊“Connect”。

SQL Server專用管理員連接(Dedicated Admin Connection(DAC))

默認(rèn)不允許使用網(wǎng)絡(luò)連接DAC,需要通過sp_configure配置“remote admin connections”選項(xiàng)。

 

先來看看配置的默認(rèn)值:

SELECT * FROM sys.configurations where name = 'remote admin connections'

或者

sp_configure 'remote admin connections'

SQL Server專用管理員連接(Dedicated Admin Connection(DAC))

Value默認(rèn)為0,指明僅允許本地連接使用 DAC。Maximum為1,表明只運(yùn)行一個(gè)遠(yuǎn)程管理連接。

 

--啟用遠(yuǎn)程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服務(wù),防火墻允許TCP 1434端口的訪問。

我們通過另一臺服務(wù)器上的SSMS建立DAC查詢連接,選擇File菜單,下拉菜單選擇“New”、“Database Engine Query”。

SQL Server專用管理員連接(Dedicated Admin Connection(DAC))

輸入域名或IP即可。

 

DAC在SSMS連接時(shí),只能通過建立查詢窗口的方式打開。當(dāng)SQL Server因系統(tǒng)資源不足,或其它異常導(dǎo)致無法建立數(shù)據(jù)庫連接時(shí), 可以使用系統(tǒng)預(yù)留的DAC連接到數(shù)據(jù)庫,進(jìn)行一些問題診斷和故障排除。DAC只能使用有限的資源。請勿使用DAC運(yùn)行需要消耗大量資源的查詢,否則可能發(fā)生嚴(yán)重的阻塞。

 

另一種打開方式是在命令行界面通過SqlCMD使用特殊的管理員開關(guān)(-A),提供對DAC的支持。

 

本地DAC連接:

SQL Server專用管理員連接(Dedicated Admin Connection(DAC))

遠(yuǎn)程DAC連接:

SQL Server專用管理員連接(Dedicated Admin Connection(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;

SQL Server專用管理員連接(Dedicated Admin Connection(DAC))

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI