Citrix Virtual Apps and Desktops contains of 3 databases, Logging, Monitoring and site database. Logging and Monitoring can be moved with GUI(Studio) but Site need to be done by PowerShell. After some struggling and no good documentation or guides I finally found a solution that a want to share.
Logging and Monitoring
As mention this databases can be moved within Studio. Do it like this:
- Stopp database logging and monitoring
- Stop Logging with this PowerShell command: “Set-LogSite -State Disabled”
- Stop monitoring with this PowerShell command: “Set-MonitorConfiguration -DataCollectionEnabled $False”
- Take full SQL backup of both database
- Logg into Studio and click “Configuration”. Mark Logging or Monitoring database and choose “Change Database” on right side. Repeat this operation for both databases.
4. After both database i created on new SQL you need to restore backup to get old data. If you dont need old data can you skip this step.
This database need to be moved with PowerShell. Start on first DDC and complete this before start on second DDC.
- Backup old database and restore on new SQL. Remember to control that ACL on database is correct. (Same as old server)
- First step is to remove DBConnection on DDC with following PowerShell command:
## Load the Citrix snap-ins asnp Citrix.* ## Disable configuration logging for the XD site: Set-LogSite -State Disabled ## Clear the current DDC database connections Set-ConfigDBConnection -DBConnection $null 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-AcctDBConnection -DBConnection $null Set-AnalyticsDBConnection -DBConnection $null # 7.6 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 #Monitoring Database Set-MonitorDBConnection -DBConnection $null #Site Database Set-LogDBConnection -DataStore Logging -DBConnection $null #Logging Database Set-LogDBConnection -DBConnection $null #Site Database Set-AdminDBConnection -DBConnection $null -force
2. Next you need to restart all Citrix services. This can be done with PowerShell:
Get-Service Citrix* | Stop-Service -Force Get-Service Citrix* | Start-Service
3. Before add new connection, control that DBConnection is clean. Output of this command should be “Empty filed”:
Get-ConfigDBConnection Get-AcctDBConnection Get-AnalyticsDBConnection # for 7.6 and newer Get-AppLibDBConnection # for 7.8 and newer Get-OrchDBConnection # for 7.11 and newer Get-TrustDBConnection # for 7.11 and newer Get-HypDBConnection Get-ProvDBConnection Get-BrokerDBConnection Get-EnvTestDBConnection Get-SfDBConnection Get-MonitorDBConnection Get-LogDBConnection Get-AdminDBConnection
4. To set new DBConnection value, run following commands. Remember to correct db Servername and DBName before you run.
$ServerName = "NEW SQL SERVER FQDN" $SiteDBName = "CTX_Site" $LogDBName = "CTX_Log" $MonitorDBName = "CTX_Mon" $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 Set-LogSite -State Enabled
5. Finally run the check again to control that all field has value. (Same as point 3) Also control Studio that is starts normal and show that Site database also has been moved.
Another good article that cover some other detailed can be read here.
One Reply to “Citrix VAD Database migration”
Aren’t you migrating the logging and monitoring databases twice..?
If you use the GUI to migrate the Logging and Monitoring databases, you should edit out the copied powershell code where the logging and monitoring database connections are cleared and migrated (set) again!
Also, services do not NEED to be restarted, only if errors occur. And they shouldn’t if you edited out the logging and monitoring DB clear (and set-!) lines.
I have two questions about database migrations that are not answered anywhere, so maybe you can help.
1) Can I live migrate the logging and monitoring databases while normal operations continue? That means making changes within Studio and users connecting during the day?
and 2) I have an old long-time upgraded database where all databases are in one big database. These days they are split in three separate DBs. What happens to the tables in the ‘old’ database, are they (re)moved or do they stay and just not being used anymore?