SQL Server专用管理员连接(Dedicated Admin Connection(DAC))
admin
2023-06-06 10:01:24
0

SQL Server专用管理员连接(Dedicated Admin Connection(DAC))

 

只有 SQL Server sysadmin 角色的成员可以使用 DAC 连接。默认情况下,只能从服务器上运行的客户端建立连接。

 

打开SSMS,在“Connect to Server”窗口,选择“Cancel”,然后选择File菜单,下拉菜单选择“New”、“Database Engine Query”。

SQL Server专用管理员连接(Dedicated Admin Connection(DAC))

输入“admin:.”,点击“Connect”。

SQL Server专用管理员连接(Dedicated Admin Connection(DAC))

默认不允许使用网络连接DAC,需要通过sp_configure配置“remote admin connections”选项。

 

先来看看配置的默认值:

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

或者

sp_configure 'remote admin connections'

SQL Server专用管理员连接(Dedicated Admin Connection(DAC))

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”。

SQL Server专用管理员连接(Dedicated Admin Connection(DAC))

输入域名或IP即可。

 

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

 

另一种打开方式是在命令行界面通过SqlCMD使用特殊的管理员开关(-A),提供对DAC的支持。

 

本地DAC连接:

SQL Server专用管理员连接(Dedicated Admin Connection(DAC))

远程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))

相关内容

热门资讯

筑牢文化根基 激发创新活力——... 新华社深圳5月23日电 题:筑牢文化根基 激发创新活力——2026文化强国建设高峰论坛综述新华社记者...
神舟二十三号发射场区开展全系统... 央广网北京5月23日消息(记者邢斯嘉 张棉棉 王家伟)据中央广播电视总台中国之声《新闻和报纸摘要》报...
雷军余承东预警:手机只会越来越... 快科技5月22日消息,在小米17 Max新品发布会上,小米创办人雷军公开表态,未来两年内存价格还会持...
9项科学实验将上行中国空间站 ... 央视网消息:记者从中国科学院空间应用工程与技术中心了解到,神舟二十三号载人飞船 将携带9项科学实验上...
发射流程进入临射倒计时,神舟二... 5月23日,神舟二十三号载人飞行任务新闻发布会上,发言人介绍,经研究决定,瞄准北京时间5月24日23...
意大利罗马上万人举行反战游行,... 当地时间23日,上万意大利民众在首都罗马走上街头,举行反战抗议示威活动,抗议地区冲突与军备扩张带来的...
孙杨还没明白,公众为什么不溺爱... 随着最新一期《妻子的浪漫旅行》播出,不知多少人共情了被孙杨气哭的张豆豆,猛然发现自己出走半周却还是被...
空调板掰了一下不归位了 如果空调板掰了一下不归位了,你可以尝试以下方法来解决问题:1. 重新调整:再次轻轻掰动空调板,看是否...
美的空调一下制冷一下不制冷 1、如果空调内部的氟利昂过多,再运行一段时间之后,压力过高就会进入保护状态,等到系统凉下来之后又可恢...
空调遥控器摔一下不显示了 原因可能是电池摔错位了,可以重新连接好正负极解决;原因可能是红外灯接触不良,可以维修发射器解决;原因...