4

I'm having trouble getting a basic xp0 environment set up on my local development machine. When I run docker-compose up it times out on the xconnect healthcheck because of a SQL login error to the Sitecore.Xdb.Collection.ShardMapManager database. When I connect to the SQL server with SQL Server Management Studio from my host (localhost,14433), I see that that database is not installed (its mdf/ldf files are not in the mssql-data folder, either).

Any ideas why that database wouldn't be included?

Error messages

Creating network "sitecore-xp0_default" with the default driver
Creating sitecore-xp0_mssql_1 ... done
Creating sitecore-xp0_solr_1  ... done
Creating sitecore-xp0_xconnect_1 ... done
Creating sitecore-xp0_id_1       ... done
Creating sitecore-xp0_cm_1       ... done
ERROR: for xdbsearchworker  Container "2cecc38acde2" is unhealthy.
ERROR: for xdbautomationworker  Container "2cecc38acde2" is unhealthy.
ERROR: for cortexprocessingworker  Container "2cecc38acde2" is unhealthy.
ERROR: for traefik  Container "692fab8efdaa" is unhealthy.
ERROR: Encountered errors while bringing up the project.

Things I've tried

  1. Cleaning and retrying (docker-compose down; .\clean.ps1; docker-compose up -d)
  2. Completely redownloading all images (docker-compose down; .\clean.ps1; docker image prune -a; docker-compose up -d)

Environment details

  • I'm using the ltsc-2019 getting-started examples from the Docker Examples Sitecore repo
  • I'm using the defaults for everything in the .env file and init.ps1
2
  • How exactly did you give the NETWORK SERVICE account access to the mssql-data folder on my host ?
    – Jaydari
    Jul 2 at 23:17
  • You can do it the standard way: right-click on the folder, select properties, click on the Security tab, click Add, and type in NETWORK SERVICE and hit enter, then set the permissions to at least Read and Write (Full Control also works). Jul 11 at 11:10

5 Answers 5

5

Quick fix

This turned out to be a permissions issue that prevented the ShardMapManager database (and accompanying shard databases) from being installed. To fix it, I needed to give the NETWORK SERVICE account access to the mssql-data folder on my host.

More info on troubleshooting

Run docker-compose logs mssql to see the logs for the SQL server. In my case, it showed the following error:

CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\data\Sitecore.Xdb.Collection.ShardMapManager.mdf'.

Since it was trying to create the database in a volume mapped to the host (and volume permissions are shared between host and container), I discovered I needed to adjust the permissions of that directory. I ran the following commands to see what account I needed to grant access to:

docker exec -it <container_id> powershell
Get-Process -IncludeUserName | ft -auto

enter image description here

These commands showed me that the sqlserver process was running as NT AUTHORITY\NETWORK SERVICE, which did not have access to the mssql-data folder. Granting access resolved the issue.

4

I faced this issue too during installation. Try the below steps:

  1. Run docker-compose stop on Powershell.
  2. Run docker-compose down on Powershell.
  3. Now run iisreset /stop on Powershell to make sure that the required ports are free.
  4. Now run docker-compose up -d on Powershell.

Hoping this solves your issue.

3
  • Hi Vinay, this worked for me after not knowing how I ended up breaking stuff. Jul 13, 2021 at 15:07
  • Glad that it worked for you Chris. Jul 14, 2021 at 17:22
  • This worked for me, thought it was a port issue as VS was also not connecting to TFS when docker was running
    – Sean T
    Sep 13, 2021 at 11:22
1

In addition to the correct answer: It is worth noting that running a clean on the host directory can help, especially after granting NETWORK SERVICE full access to the MSSQL directory as the databases will need to re-established at run time.

The clean.ps1 can be found here: https://github.com/Sitecore/docker-examples/blob/develop/getting-started/clean.ps1

Apologise for not adding this as a comment - I don't have enough reputational points to add comments apparently.

1

Possible root cause: In default init.ps1 in docker-example repository, SqlSaPassword does not meets SQL complexity requirements.

Troubleshoot

First of all, check the logs by running this command:

Docker logs <container-id> 

Eg. docker logs 2cecc38acde2

Alternatively, you can run this command as well: docker-compose logs mssql

You might see this error in logs:

Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardManagementException: Store Error: Cannot open database "Sitecore.Xdb.Collection.ShardMapManager" requested by the login. The login failed.
Login failed for user 'sa'.. The error occurred while attempting to perform the underlying storage operation during 'Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.StoreException: Error occurred while performing store operation. 

See the inner SqlException for details. ---> System.Data.SqlClient.SqlException: Cannot open database "Sitecore.Xdb.Collection.ShardMapManager" requested by the login. The login failed. Login failed for user 'sa'. 
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)

This error means the SQL password is not correctly set. Open the init.ps1 file and give a strong SQL admin password. I've used this script to generate the SQL password and save the init.ps1 file.

# SQL_SA_PASSWORD
# Need to ensure it meets SQL complexity requirements
Set-EnvFileVariable "SQL_SA_PASSWORD" -Value (Get-SitecoreRandomString 19 -DisallowSpecial -EnforceComplexity)

Run docker-compose down and then cd to docker folder and run .\clean.ps1

Now, run the .\init.ps1 -LicenseXmlPath C:\License\license.xml This script will set the strong password SQL SA password in .env file.

And then, docker-compose up -d

-1

I also faced this issue during installation. So I tried this.

Run docker-compose up -d in powershell for 2 3 times and it works.

1
  • Run it a few times is not a solution
    – Sean T
    Sep 14, 2021 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.