About Me

My photo
I am MCSE in Data Management and Analytics with specialization in MS SQL Server and MCP in Azure. I have over 13+ years of experience in IT industry with expertise in data management, Azure Cloud, Data-Canter Migration, Infrastructure Architecture planning and Virtualization and automation. Contact me if you are looking for any sort of guidance in getting your Infrastructure provisioning automated through Terraform. I sometime write for a place to store my own experiences for future search and read by own blog but can hopefully help others along the way. Thanks.

SQL 2012 setup fails with "Wait on the database engine recovery handle failed in windows server 2008 R2 Cluster"


SQL 2012 setup fails with "Wait on the database engine recovery handle failed in windows server 2008 R2 Cluster"


When installing SQL Server 2012, sometimes  you might come across a situation where the setup fails towards the end  when trying to start the SQL Server services. 


while navigating  further, we will get this in detail.txt file
In setup bootstrap C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\2012XXXX_XXXXXX\detail.txt 

Issue 
======
(01) 2012-03-21 10:49:07 Slp: Inner exceptions are being indented
(01) 2012-03-21 10:49:07 Slp: 
(01) 2012-03-21 10:49:07 Slp: Exception type: Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineConfigException
(01) 2012-03-21 10:49:07 Slp:     Message: 
(01) 2012-03-21 10:49:07 Slp:         Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
(01) 2012-03-21 10:49:07 Slp:     HResult : 0x851a0019
(01) 2012-03-21 10:49:07 Slp:         FacilityCode : 1306 (51a)
(01) 2012-03-21 10:49:07 Slp:         ErrorCode : 25 (0019)
(01) 2012-03-21 10:49:07 Slp:     Data: 
(01) 2012-03-21 10:49:07 Slp:       SQL.Setup.FailureCategory = ConfigurationFailure
(01) 2012-03-21 10:49:07 Slp:       WatsonConfigActionData = REPAIR@CONFIGRC@SQL_ENGINE_CORE_INST
(01) 2012-03-21 10:49:07 Slp:       WatsonExceptionFeatureIdsActionData = System.String[]
(01) 2012-03-21 10:49:07 Slp:     Stack: 

Problem
=======
The root cause of this issue, in most cases, is that the profile of the user being used for the service account (in my case it was local system) is corrupted. 

Resolution
========
1) When the installation throws this error, click on OK and allow it to proceed. It will fail for Database Engine, but the SQL Server service should have been created. Check the Services console.

2) start-> run -> services.msc ->right click on the SQL Server Service -> change the service account( (if it is local system, give it a windows level account, and vice-versa).

Change the account for SQL Agent as well.

3)Next, try to start the service. It should come online.

4)However, you will not be able to log in to the SQL Server.

Start the instance of SQL Server in master-only recovery mode by entering one of the following commands at the command prompt. The parameters specified in these commands are case sensitive. The commands fail when the parameters are not specified as shown. 


C:\Program Files\Microsoft SQL Server\MSSQL11.MSQLSERVER\MSSQL\Binn>net start MSSQL$MSQLSERVER /f /T3608
The SQL Server (MSQLSERVER) service is starting.
The SQL Server (MSQLSERVER) service was started successfully.

6) Now try logging in to the server using admin connection from sqlcmd (sqlcmd admin:<server name>\<instance name> ...)

SQLCMD Command
here 192.168.2.99 is sql server Virtual server  IP Address. 
6. Once logged in, use the sp_addsrvrolemember '<domain\username>','sysadmin'.

Example:
C:\Program Files\Microsoft SQL Server\MSSQL11.MSQLSERVER\MSSQL\Binn>sp_addsrvrolemember 'ctl\AdminHostings','sysadmin'
Also add the builtin/administrators to the sysadmin role.
7. Now stop the service from the command prompt and start it from SQL Server configuration manager
You should be able to log into the server now.