I start a Windows SQL Server in a Docker Container on a Windows Server 2016 virtual machine with this command:
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
Afterwards I want to start the SQL Agent with this command:
docker container exec mssql-server cmd.exe /C "net start sqlserveragent"
Unfortunately I get this Output:
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
When I type NET HELPMSG 3534
I get:
The service did not report an error.
I am completely out of ideas. On my local machine this works fine, but not on the build server.
Any help appreciated.
Edit:
I opened the SQL Server Management Studio and noticed the SQL Server Agent (Agent XPs disabled)
node.
So I went through everything in https://www.mssqltips.com/sqlservertip/2729/how-to-start-sql-server-agent-when-agent-xps-show-disabled/. Afterwards I executed
exec sp_configure 'Agent XPs'
and the result was:
But when I tried to start the agent, I got the exact same error message from above (service ist starting... service could not be started... no error reported).
The interesting thing is, when I run
exec sp_configure 'Agent XPs'
again, I get this:
How is it possible, that the start-agent-command disables the Agent XPs?
Edit2: I just learned from a comment at https://community.spiceworks.com/topic/293771-sql-server-agent-agent-xps-disabled-sql-server-2008 that the agent configures this values automatically when it is started and stopped. So I shouldn't enabled it manually.
Edit3: After a comment from Jeroen Mostert I looked into the EventLog. I used the following command:
docker container exec mssql-server powershell.exe "Get-EventLog Application -Newest 100"
This is the result from the Application-Log
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.
You can see, that I have manually enabled the Agent XPs
. Then I ran the command from above to start the agent, which gave me the next two lines
The System-EventLog gave me:
Time EntryType Source InstanceID Message
---- --------- ------ ---------- -------
Jun 25 10:37 Information Service Control Manager 1073748860 The SQL Server Agent (MSSQLSERVER) service entered the stopped state.
Edit 4:
As per the comment from Dan Guzman: this is the content of SQLAGENT.OUT
:
2019-07-09 11:03:44 - ? [000]
2019-07-09 11:03:44 - ? [098] SQLServerAgent terminated (normally)
Edit 5:
The version is (select @@version
) is:
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)
It's because you've installed SQL Server Express (indicated by the instance name SQLEXPRESS), SQL Server Agent is not supported in this version, it installs the service, but it does not allow it to run. You need one of the non-free SQL server editions in order to use SQL Server Agent. Save this answer.
To start, stop, or restart the SQL Server Agent Service In Object Explorer, click the plus sign to expand the server where you want to manage SQL Server Agent Service. Right-click SQL Server Agent, and then select either Start, Stop, or Restart. In the User Account Control dialog box, click Yes.
Check the SQL error log for any related stack dumps or messages. This exception forces SQL Server to shutdown. To recover from this error, restart the server (unless SQLAgent is configured to auto restart).
Description:The SQL Server (MSSQLSERVER) service failed to start due to the following error: The service did not start due to a logon failure. Solution: We need to update the password in services. The right way to do itisto use SQL Server Configuration Manager and type in new password(under Log On tab).
My solution was to upgrade the build-server to Windows Server 2019. That's it. Then everything worked without any further change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With