docker container run --name mssql-server --detach --publish 1433:1433 --memory 2048mb --volume C:\_Data:C:\_Data --env sa_password=myPassword --env ACCEPT_EULA=Y microsoft/mssql-server-windows-developer
接下来,我想使用以下命令启动 SQL 代理:
docker container exec mssql-server cmd.exe /C "net start sqlserveragent"
不幸的是,我得到了这个输出:
The SQL Server Agent (MSSQLSERVER) service is starting.
The SQL Server Agent (MSSQLSERVER) service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534
当我输入
NET HELPMSG 3534
时,我会得到以下结果:The service did not report an error.
我完全没有思路。在我的本地机器上,这个可以正常工作,但是在构建服务器上却不能。
任何帮助都会很感激。
编辑:
我打开了 SQL Server Management Studio 并注意到SQL Server Agent(代理 XPs 已禁用)
节点。
所以我按照https://www.mssqltips.com/sqlservertip/2729/how-to-start-sql-server-agent-when-agent-xps-show-disabled/中的步骤进行了操作。之后我执行了
exec sp_configure 'Agent XPs'
结果如下:
但是当我尝试启动代理时,我得到了与上面完全相同的错误信息(服务正在启动... 服务无法启动... 没有报告错误)。
有趣的是,当我运行
exec sp_configure 'Agent XPs'
我再次遇到这个问题:
启动代理命令如何禁用代理 XPs?
编辑2:我从https://community.spiceworks.com/topic/293771-sql-server-agent-agent-xps-disabled-sql-server-2008的评论中得知,代理在启动和停止时会自动配置这些值。所以我不应该手动启用它。
编辑3:在Jeroen Mostert的评论后,我查看了事件日志。我使用了以下命令:
docker container exec mssql-server powershell.exe "Get-EventLog Application -Newest 100"
这是来自应用程序日志的结果
Time EntryType Source InstanceID Message
---- --------- ------ ---------- -------
Jun 25 10:37 Information SQLSERVERAGENT 1073741926 SQLServerAgent service successfully stopped.
Jun 25 10:37 Information MSSQLSERVER 1073757281 Configuration option 'Agent XPs' changed from 1 to 0. Run the RECONFIGURE statement to install.
Jun 25 10:36 Information MSSQLSERVER 1073757281 Configuration option 'Agent XPs' changed from 0 to 1. Run the RECONFIGURE statement to install.
你可以看到,我已手动启用了
Agent XPs
。然后我运行了上面的命令来启动代理程序,这给了我下面两行。系统事件日志告诉我:
Time EntryType Source InstanceID Message
---- --------- ------ ---------- -------
Jun 25 10:37 Information Service Control Manager 1073748860 The SQL Server Agent (MSSQLSERVER) service entered the stopped state.
编辑4: 根据Dan Guzman的评论: 这是SQLAGENT.OUT
的内容:
2019-07-09 11:03:44 - ? [000]
2019-07-09 11:03:44 - ? [098] SQLServerAgent terminated (normally)
编辑 5:版本是 (select @@version
) 是:
Microsoft SQL Server 2017 (RTM-CU3-GDR) (KB4052987) - 14.0.3015.40 (X64) Dec 22 2017 16:13:22 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor)
EXEC xp_readerrorlog 0, 2
。 - Dan Guzmantype "C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log\SQLAGENT.OUT"
来获取。 - Dan Guzman