Migrate Citrix databases to new database SQL server (cluster, Always On or Mirroring)

Migrate Citrix databases to new database SQL server (cluster, Always On or Mirroring)

book

Article ID: CTX280675

calendar_today

Updated On:

Description

You can follow this article if your objective is to migrate your Citrix databases from one SQL server to another. 


Instructions

1. Take a backup of Citrix Servers / Databases (note logon /user mappings to the DDC). *VERY IMPORTANT*
2. Close down Studio (Don’t make any configuration changes).
3. Power down old SQL server
4. Create new SQL server add domain and configure IP. (if not already completed)
5. Restore Citrix SQL databases from a backup to the new server.
6. Create logons for the DDC(S).
Step 6 is when you are creating your new SQL database during the install you create a logon for the DDC(S) to allow them access to the database.

In my Screen shot “ME” is my domain and “DDC” is my delivery controller.

7. Setting the Connection Strings to point at the new SQL server
*We are doing the below steps on all DDC's*
This is very important that this step is completed successfully otherwise the environment will not work correctly
  1. Disable Logging in order to avoid issues on changing connection string for logging connection. https://support.citrix.com/article/CTX139447
You can skip this step but you will have to run the Logging command-line with "-force".
 
  1. Open Administrator PowerShell Window and run the following command
  • Asnp Citrix*                                                                (This loads the Citrix snap-in commandlets)
 
  1. Retrieve the Connection Strings for each DB
Site database = Get-BrokerDBConnection
Monitoring database = Get-MonitorDBConnection –DataStore Monitor
Configuration logging database = Get–LogDBConnection –DataStore Logging
                               
                                -Please take note of these and change for string in accordance to the new hostname
Then check all services connection strings :
Get-Command -Name get-*DBConnection
Get-Command -Name get-*ServiceStatus - to check the status of all citrix services that communicate with DB
Get-Command -Name get-*ServiceStatus | select name

Next step will be to check the connection string for Logging and Monitoring Data store:
Get-LogDataStore
Get-MonitorDataStore
 
PS Get-LogDataStore  onnectionString  DataStore  DatabaseType  provi der  Stat u s  Data Stor e  D a b as eType  provi der  Stat us  : Server—SQL; Initial Catalog—CitrixticSite; Integrated SecuritFTrue  : Site  : MssQL  : Conf gLogg•ingSi  Initial Catalog<itriXtiCLogging; Integrated  ; Logg i ng  M5SQL  S Get—MonitorDataStore  onnectionString  DataStor e  DatabaseType  Provi der  SchenaName  Status  onnectionString  DataStor e  DatabaseType  Provi der  SchenaVame  Status  : Server—SQL; Initial Cataloq=CitrixticSite; Integrated Security—True  . Site  : SqISeruer  : MssqL  : Momtor  : Server—SQL; Initial Catalog=CitrixticNonitoring; Integrated Security—True  : Monitor  : SqIServer  : MSSQL  : Monitor-Data
After we found out all these names we have to change all connection strings to $null.
 
Set-AcctDBConnection -DBConnection $null
Set-AnalyticsDBConnection -DBConnection $null
Set-AppLibDBConnection -DBConnection $null
Set-BrokerDBConnection -DBConnection $null
Set-ConfigDBConnection -DBConnection $null
Set-EnvTestDBConnection -DBConnection $null
Set-HypDBConnection -DBConnection $null
Set-OrchDBConnection -DBConnection $null
Set-ProvDBConnection -DBConnection $null
Set-SfDBConnection -DBConnection $null
Set-TrustDBConnection -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
 
If you will encounter any error while running those commands you should run again the failing commands, with -force.
For example, let's say that you encounter an error while running the following command: Set-MonitorDBConnection -Datastore Monitor -DBConnection $null
 
PS —Oatastore Monitor  d5 - 5etrV,nnf
 
In order to fix that, you should just run the same command-line followed by -force.
Set-MonitorDBConnection -Datastore Monitor -DBConnection $null -force
 
PS Set—MonitortXConnection -Datastore Monitor -Dæonnection Snull -force  ServiceStatus Extralnfo  DELIn ed
 
Finally, copy in notepad the following connection strings and run them in this order:

# Site DB
$cs = "Server=SQL;Initial Catalog=CitrixticSite;Integrated Security=True"
# Logging DBget
$csl = "Server=SQL;Initial Catalog=CitrixticLogging;Integrated Security=True"
# Monitor DB
$csm = "Server=SQL;Initial Catalog=CitrixticMonitoring;Integrated Security=True"
 
SCS  SCSI  Scsm  PS  nistrator.  C nistrator.  C nistrator.  C nistrator.  C nistrator.  Initial Catalog—CitrixtiCSite; Integrated  Initial ng; Integrated Security—True"  "Server—SQL; Initial Catalog—Citrixticmonitoring; Integrated SecuritFTrue"
 

Set-AdminDBConnection -DBConnection $cs
Set-AcctDBConnection -DBConnection $cs
Set-AnalyticsDBConnection -DBConnection $cs
Set-AppLibDBConnection -DBConnection $cs
Set-BrokerDBConnection -DBConnection $cs
Set-ConfigDBConnection -DBConnection $cs
Set-EnvTestDBConnection -DBConnection $cs
Set-HypDBConnection -DBConnection $cs
Set-OrchDBConnection -DBConnection $cs
Set-ProvDBConnection -DBConnection $cs
Set-SfDBConnection -DBConnection $cs
Set-TrustDBConnection -DBConnection $cs
Set-LogDBConnection -DBConnection $cs 
Set-LogDBConnection -Datastore Logging -DBConnection $null

Set-LogDBConnection -Datastore Logging -DBConnection $csl
 Set-MonitorDBConnection -DBConnection $cs
Set-MonitorDBConnection -Datastore Monitor -DBConnection $null
Set-MonitorDBConnection -Datastore Monitor -DBConnection $csm

 
 
All this connections strings that we are trying to change via PowerShell are found in Registry, on the DDC, under HKLM\SOFTWARE\Citrix\XDservices and HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\DesktopServer\DataStore\Connections\Controller