LEEEJEFFRIES.COM

XenDesktop Database Testing and Troubleshooting

 | 

XenDesktop and its database connection is a tricky one, back in the old days of 6.5 you had a single connection. Now you have each service instance registered in the database with multiple connections from these services.

When you’ve complete a farm upgrade and you can no longer log into Studio or when a single service starts to flap and you see errors in the event viewer it can be a little nail biting.

So what do you do when it goes a bit wobbly, there are some nice steps in PowerShell to ensure you are able to connect to the database, view the service status and if necessary re-register all the services.

There is a XenDesktop tool for checking the database (XDDBDiag): https://support.citrix.com/article/CTX128075

Feel free to try this but beware, I’ve seen it go wrong when this tool is used on newer version occasionally.

We’ll be moving forward with PowerShell, Let’s do it!

Fire up PowerShell as an administrator on a controller or a machine with Studio installed.

Asnp Citrix*

This will load all the Citrix snap-ins.

Get-ConfigDBConnection

This will display the current database connection in use by your farm.

So just for fun, let’s check the connection is fine

Test using the below script, replace the variables from what you see above:

## Replace with the New SQL server, and instance if present

## Replace with the name of your restored Database ## ##

$ServerName=”LJ-XDC-01\sqlexpress”

$SiteDBName=”CitrixHome_LabSite”

$cs=”Server=$ServerName; Initial Catalog=$SiteDBName; Integrated Security=True”

Test-AcctDBConnection -DBConnection $cs

Test-AdminDBConnection -DBConnection $cs

Test-AnalyticsDBConnection -DBConnection $cs # 7.6 and newer

Test-AppLibDBConnection -DBConnection $cs # 7.8 and newer

Test-BrokerDBConnection -DBConnection $cs

Test-ConfigDBConnection -DBConnection $cs

Test-EnvTestDBConnection -DBConnection $cs

Test-HypDBConnection -DBConnection $cs

Test-LogDBConnection -DBConnection $cs

Test-MonitorDBConnection -DBConnection $cs

Test-OrchDBConnection -DBConnection $cs # 7.11 and newer

Test-ProvDBConnection -DBConnection $cs

Test-SfDBConnection -DBConnection $cs

Test-TrustDBConnection -DBConnection $cs # 7.11 and newer

If all goes to plan, you’ll get some “OK” feedback.

So the Database connection is OK.

If you see that a particular connection is not OK this will be your problem. My recommendation would be to directly restore from a backup. Don’t hack and slash the Citrix Site DB, you can end up with bigger problems.

Let’s check the services are all fine.

Get-AcctServiceStatus

Get-AdminServiceStatus

Get-AnalyticsServiceStatus # 7.6 and newer

Get-AppLibServiceStatus # 7.8 and newer

Get-BrokerServiceStatus

Get-ConfigServiceStatus

Get-EnvTestServiceStatus

Get-HypServiceStatus

Get-LogServiceStatus

Get-MonitorServiceStatus

Get-OrchServiceStatus # 7.11 and newer

Get-TrustServiceStatus # 7.11 and newer

Get-ProvServiceStatus

Get-SfServiceStatus

These command will ask the Controller to check all its services for a status.

Again, you will get some “OK” feedback.

If for any reason the feedback is not that great, you can re-register these service instances with the database.

So, let’s take a look at the registered service instances.

Get-ConfigRegisteredServiceInstance

To re-register a specific service you can filter:

_Get-ConfigRegisteredServiceInstance -ServiceType “Admin” Unregister-ConfigRegisteredServiceInstance_

Or to simply re-register all services

_Get-ConfigRegisteredServiceInstance Unregister-ConfigRegisteredServiceInstance_
_Get-BrokerServiceInstance Register-ConfigServiceInstance_

Run this on each controller in the farm and you should get some feedback.

If you compare the ServiceInstanceUid Before and After you will see a difference in how its registered.

BEFORE:

Address : https://lj-xdc-01.lj.local/scripts/ctxadmin/ctxadmin.dll

Binding : XML_HTTPS

InterfaceType : XML.SSL.Admin

Metadata : {}

MetadataMap : {}

ServiceAccount : LJ\LJ-XDC-01$

ServiceAccountSid : S-1-5-21-699119681-375327193-915452706-1660

ServiceGroupName : Home_Lab

ServiceGroupUid : dc3f5b0c-b38c-4ad0-89a7-b85a7bf5e10d

ServiceInstanceUid : 5d9a21e3-7b8c-4bbb-8f7f-54a2733737e9

ServiceType : Broker

Version : 1

AFTER:

Address : http://lj-xdc-01.lj.local/Citrix/BrokerEnvTests/v1

Binding : wcf_HTTP_kerb

InterfaceType : EnvironmentTest

Metadata :

MetadataMap :

ServiceAccount : LJ\LJ-XDC-01$

ServiceAccountSid : S-1-5-21-699119681-375327193-915452706-1660

ServiceGroupName : Home_Lab

ServiceGroupUid : dc3f5b0c-b38c-4ad0-89a7-b85a7bf5e10d

ServiceInstanceUid : 09b1753c-fb26-41a4-a5e0-d3d80c2f2317

ServiceType : Broker

Version : 1

Thank to Citrix for the awesome articles:

https://support.citrix.com/article/CTX140319

https://support.citrix.com/article/CTX200446

https://docs.citrix.com/en-us/xenapp-and-xendesktop/7-6/cds-sdk-wrapper-rho/xad-commands/citrix-configuration-admin-v2-wrapper-xd76/register-configserviceinstance-xd76.html

About Me

Photo of Leee Jeffries

I'm an IT professional with over 15 years of experience in the IT industry, I've worked in many fields in my career. This blog is to share my experience, tips and tricks.