Background
Delivery Controller is a collection of services, each of which has its own SQL connection string. To change the SQL connection strings, you use PowerShell to change each service. Some points to keep in mind:
- Most of the Delivery Controller services connect to the same database (Site database), so you can set the same connection string for almost all of them
- Monitoring has two connection strings: one for the Site database, and another for the separate Monitoring database
- Logging has two connection strings: one for the Site database, and another for the separate Logging database
Getting Started
- Before changing the database port: Follow: CTX139447 How to Disable or Enable Configuration Logging Service in XenDesktop 7 using PowerShell https://support.citrix.com/article/CTX139447/how-to-disable-or-enable-configuration-logging-service-in-xendesktop-7-using-powershell
- Make the required port changes on SQL server and then make a note of the port number configured on SQL server
- Back up the Citrix Site, Monitoring and Logging databases
- Take a snapshot of the Delivery Controller virtual machine(s)
- It is expected that the Citrix databases are unavailable until the procedure is complete. Therefore, connections to the Site may be temporarily unavailable. It is best to complete all the steps in the following procedure within the same change window
- All Management Consoles should be closed. Citrix strongly recommends that no administrative changes be attempted until the Databases are back online and verified
Retrieve the existing Database connections
Run the following commands to see the existing database connection strings
## Load the Citrix snap-ins
asnp Citrix.*
## ## Get the current Delivery Controller database connections
Get-ConfigDBConnection
Get-AcctDBConnection
Get-AnalyticsDBConnection # 7.6 and newer
Get-AppLibDBConnection # 7.8 and newer
Get-OrchDBConnection # 7.11 and newer
Get-TrustDBConnection # 7.11 and newer
Get-HypDBConnection
Get-ProvDBConnection
Get-BrokerDBConnection
Get-EnvTestDBConnection
Get-SfDBConnection
Get-MonitorDBConnection
Get-MonitorDBConnection -DataStore Monitor
Get-LogDBConnection
Get-LogDBConnection -DataStore Logging
Get-AdminDBConnection
Test the new Database connection strings
1. Run the following commands to verify connectivity to the database
Adjust the variables to match your desired connection string. For example, to add custom port to the connection strings, then set the $ServerName variable to “DBServernameInstance,CustomPortNumber”.
asnp citrix.*
$ServerName = “<DBServernameInstance,CustomPortNumber>”
$SiteDBName = “<SiteDbName>”
$LogDBName = “<LoggingDbName>”
$MonitorDBName = “<MonitorDbName>”
$csSite = “Server=$ServerName;Initial Catalog=$SiteDBName;Integrated Security=True”
$csLogging = “Server=$ServerName;Initial Catalog=$LogDBName;Integrated Security=True”
$csMonitoring = “Server=$ServerName;Initial Catalog=$MonitorDBName;Integrated Security=True”
Test-AcctDBConnection -DBConnection $csSite
Test-AdminDBConnection -DBConnection $csSite
Test-AnalyticsDBConnection -DBConnection $csSite # 7.6 and newer
Test-AppLibDBConnection -DBConnection $csSite # 7.8 and newer
Test-BrokerDBConnection -DBConnection $csSite
Test-ConfigDBConnection -DBConnection $csSite
Test-EnvTestDBConnection -DBConnection $csSite
Test-HypDBConnection -DBConnection $csSite
Test-LogDBConnection -DBConnection $csSite
Test-LogDBConnection -DataStore Logging -DBConnection $csLogging
Test-MonitorDBConnection -DBConnection $csSite
Test-MonitorDBConnection -Datastore Monitor -DBConnection $csMonitoring
Test-OrchDBConnection -DBConnection $csSite # 7.11 and newer
Test-ProvDBConnection -DBConnection $csSite
Test-SfDBConnection -DBConnection $csSite
Test-TrustDBConnection -DBConnection $csSite # 7.11 and newer
Remove the existing Database connections
- At the Delivery Controller, open PowerShell as Administrator and run the following commands. This process clears the existing database connections.
## Load the Citrix snap-ins
asnp Citrix.*
## ## Clear the current Delivery Controller database connections
## Note: AdminDBConnection must be the last command
Set-ConfigDBConnection -DBConnection $null
Set-AcctDBConnection -DBConnection $null
Set-AnalyticsDBConnection -DBConnection $null # 7.6 and newer
Set-AppLibDBConnection -DBConnection $null # 7.8 and newer
Set-OrchDBConnection -DBConnection $null # 7.11 and newer
Set-TrustDBConnection -DBConnection $null # 7.11 and newer
Set-HypDBConnection -DBConnection $null
Set-ProvDBConnection -DBConnection $null
Set-BrokerDBConnection -DBConnection $null
Set-EnvTestDBConnection -DBConnection $null
Set-SfDBConnection -DBConnection $null
Set-MonitorDBConnection -DataStore Monitor -DBConnection $null
Set-MonitorDBConnection -DBConnection $null
Set-LogDBConnection -DataStore Logging -DBConnection $null
Set-LogDBConnection -DBConnection $null
Set-AdminDBConnection -DBConnection $null -force
- If you see the errors relating to unable to stop the Service or unable to change the connection strings, you must restart all the Citrix services.
Get-Service Citrix* | Stop-Service -Force
Get-Service Citrix* | Start-Service
After restarting all the Citrix services, if you still see the errors, you must restart the server.
- Rerun the original set of commands to confirm that the existing connection is properly removed.
- These cmdlets should not return anything:
## Load the Citrix snap-ins
asnp Citrix.*
## ## Get the current Delivery Controller database connections
Get-ConfigDBConnection
Get-AcctDBConnection
Get-AnalyticsDBConnection # 7.6 and newer
Get-AppLibDBConnection # 7.8 and newer
Get-OrchDBConnection # 7.11 and newer
Get-TrustDBConnection # 7.11 and newer
Get-HypDBConnection
Get-ProvDBConnection
Get-BrokerDBConnection
Get-EnvTestDBConnection
Get-SfDBConnection
Get-MonitorDBConnection
Get-LogDBConnection
Get-AdminDBConnection
Specify the new Database connection strings
- Run the following commands to set the new connection strings.
- Adjust the variables to match your desired connection string. For example, to to add custom port to the connection strings, then set the $ServerName variable to “DBServernameInstance,CustomPortNumber”.
- Repeat this for the $csLogging and $csMonitoring variables
## Replace <dbserver> with the SQL server name,custom port and instance if present
## Replace <dbname> with the name of your restored Database
## Note: AdminDBConnection should be first
$ServerName = “<DBServernameInstance,CustomPortNumber>”
$SiteDBName = “<SiteDbName>”
$LogDBName = “<LoggingDbName>”
$MonitorDBName = “<MonitorDbName>”
$csSite = “Server=$ServerName;Initial Catalog=$SiteDBName;Integrated Security=True”
$csLogging = “Server=$ServerName;Initial Catalog=$LogDBName;Integrated Security=True”
$csMonitoring = “Server=$ServerName;Initial Catalog=$MonitorDBName;Integrated Security=True”
Set-AdminDBConnection -DBConnection $csSite
Set-ConfigDBConnection -DBConnection $csSite
Set-AcctDBConnection -DBConnection $csSite
Set-AnalyticsDBConnection -DBConnection $csSite # 7.6 and newer
Set-HypDBConnection -DBConnection $csSite
Set-ProvDBConnection -DBConnection $csSite
Set-AppLibDBConnection –DBConnection $csSite # 7.8 and newer
Set-OrchDBConnection –DBConnection $csSite # 7.11 and newer
Set-TrustDBConnection –DBConnection $csSite # 7.11 and newer
Set-BrokerDBConnection -DBConnection $csSite
Set-EnvTestDBConnection -DBConnection $csSite
Set-SfDBConnection -DBConnection $csSite
Set-LogDBConnection -DBConnection $csSite
Set-LogDBConnection -DataStore Logging -DBConnection $null
Set-LogDBConnection -DBConnection $null
Set-LogDBConnection -DBConnection $csSite
Set-LogDBConnection -DataStore Logging -DBConnection $csLogging
Set-MonitorDBConnection -DBConnection $csSite
Set-MonitorDBConnection -DataStore Monitor -DBConnection $null
Set-MonitorDBConnection -DBConnection $null
Set-MonitorDBConnection -DBConnection $csSite
Set-MonitorDBConnection -DataStore Monitor -DBConnection $csMonitoring
Note: It is important to verify that all the preceding Set-<service>DBConnection commands have returned a result of OK. If the result is other than OK for any of these commands, it might be necessary to enable logging or tracing to determine the cause of the connection failure.
Note: The Set-LogDBConnection -DBConnection $null and Set-MonitorDBConnection -DBConnection $null will return DBUnconfigured instead of OK.