Citrix Virtual Apps and Desktops

Upgrade the database and site

You upgrade the database and the site after you upgrade the Delivery Controllers. For the high-level overview, see Step 8: Upgrade database and site.

Check Verify your permissions for the permissions required to update the schema of the SQL Server databases. Choose an upgrade method based on your database permissions:

  • Automatic upgrade. If you have permission to update the SQL Server database schema, run an automatic upgrade. See Upgrade the database and site automatically.
  • Manual upgrade. If you do not have those permissions, run a manual upgrade that uses scripts. Work with your database administrator, who has the required permissions. See Upgrade the database and site manually.

    In a manual upgrade, tasks are split between two roles:

    • The Site Manager user generates the scripts. The user then runs the scripts that enable and disable services.
    • The database administrator runs the scripts that update the database schema. The administrator uses the SQLCMD utility or SQL Server Management Studio in SQLCMD mode.

Note:

In a multi-zone deployment, run the automatic dbschema upgrade in the same zone that hosts the site’s SQL Server databases. Otherwise, the automatic upgrade might fail.

Before you upgrade, back up the database. See CTX135207. During a database upgrade, product services are disabled. During the disabled period, Controllers cannot broker new connections for the site, so plan carefully.

Review database schema upgrades

When you update your deployment, several database schemas can be upgraded. The following table lists the schemas that are upgraded:

Dbschema updates

The table uses these terms:

  • Site: The Site Datastore. The schema update is made to the Site Datastore.
  • Monitor: The Monitor Datastore. The schema update is made to the Monitor Datastore.
  • Config: The Configuration table. The Studio version, licensing information, or both are updated in the Configuration table.
  • Logging: The Logging Datastore. The schema update is made to the Logging Datastore.

Upgrade the database and site automatically

You can upgrade the database and site automatically using Site Manager or the PowerShell SDK cmdlet.

Upgrade automatically using Site Manager

  1. Launch Site Manager on the upgraded Delivery Controllers.
  2. Indicate that you want to start the site upgrade automatically and confirm that you are ready.

Upgrade automatically using the PowerShell cmdlet

As an alternative to using Site Manager, use the PowerShell SDK cmdlet Update-XDSite to automatically upgrade the database and site. For more information, see Citrix Virtual Apps and Desktops SDK Guide.

  1. On the second Delivery Controller, open a PowerShell session.
  2. Run the Update-XDSite cmdlet.

The cmdlet automatically detects all components that require upgrading and performs the following actions:

  • Disconnects database connections, updates the necessary database tables, and reconnects services. If the database was already upgraded by other scripts or standalone tools, this step is skipped.
  • Runs any additional upgrade steps required for the environment. Global-level upgrades that are already complete are skipped.

Upgrade the database and site manually

  1. Launch Site Manager on the upgraded Delivery Controllers.
  2. Indicate that you want to upgrade the site manually. The wizard checks for License Server compatibility and requests confirmation.
  3. Confirm that you have backed up the database.

    The wizard generates and displays the scripts and a checklist of upgrade steps. If a database’s schema has not changed since the product version being upgraded, that script is not generated. For example, if the logging database schema does not change, the UpgradeLoggingDatabase.sql script is not generated.

  4. Run the following scripts in the order shown.

    • DisableServices.ps1: The Site Manager user runs this PowerShell script on a Controller to disable product services.
    • UpgradeSiteDatabase.sql: The database administrator runs this SQL script on the server containing the Site database
    • UpgradeMonitorDatabase.sql: The database administrator runs this SQL script on the server containing the Monitor database.
    • UpgradeLoggingDatabase.sql: The database administrator runs this SQL script on the server containing the Configuration Logging database. Run this script only if this database changes (for example, after applying a hotfix).
    • EnableServices.ps1: The Site Manager user runs this PowerShell script on a Controller to enable product services.

    After the database upgrade completes and product services are enabled, Site Manager automatically tests the environment and configuration, and then generates an HTML report. If problems are identified, you can restore the database backup. After resolving issues, you can upgrade the database again.

  5. After completing the checklist tasks, click Finish upgrade.

Replace SQL Server Express LocalDB

Microsoft SQL Server Express LocalDB is a feature of SQL Server Express that Local Host Cache uses on a standalone basis. Local Host Cache does not require any components of SQL Server Express other than SQL Server Express LocalDB.

When upgrading Delivery Controllers to Citrix Virtual Apps and Desktops version 2203 LTSR or later versions, the supported version is SQL Server Express LocalDB 2019 or SQL Server Express LocalDB 2022.

There are two ways of updating SQL Server Express LocalDB:

Automatic update

When you upgrade Delivery Controllers, the metainstaller automatically installs the latest compatible version of the SQL Server Express LocalDB. The metainstaller does not uninstall the old LocalDB version. You must manually uninstall the old version after you confirm the new version works correctly.

Verify new SQL Server Express LocalDB installation

Before uninstalling the old version, verify that the new SQL Server Express LocalDB installation is working correctly:

  1. Use Command Prompt to navigate to the SqlLocalDB instance:

    • For SQL LocalDB 2014: cd C:\Program Files\Microsoft SQL Server\120\Tools\Binn
    • For SQL LocalDB 2017: cd C:\Program Files\Microsoft SQL Server\140\Tools\Binn
    • For SQL LocalDB 2019: cd C:\Program Files\Microsoft SQL Server\150\Tools\Binn
    • For SQL LocalDB 2022: cd C:\Program Files\Microsoft SQL Server\160\Tools\Binn
  2. Run SqlLocalDB i.

    You must see two files: CitrixHA and MSSQLLocalDB.

Manual update

Prerequisites

  • The Citrix Virtual Apps and Desktops installation media.
  • The PsExec tool from the Windows Sysinternals toolbox.

Procedure

  1. Complete the upgrade of your Citrix Virtual Apps and Desktops components, databases, and site. (Those database upgrades affect the site, monitoring, and configuration logging databases. They do not affect the Local Host Cache database that uses SQL Server Express LocalDB.)
  2. Log on to the Delivery Controller, where you would like to update SQL Server Express LocalDB.
  3. Download PsExec from Microsoft and place it in an easily accessible location on that Delivery Controller, such as C:\Temp.
  4. Stop the Citrix High Availability Service on the Delivery Controller from the Windows System Services.
  5. Open the Command Prompt on the Delivery Controller, navigate to the location with PsExec (example, C:\Temp), and then run the following command to elevate the command prompt with the Network Service account:

    psexec -i -u "NT AUTHORITY\NETWORKSERVICE" cmd
    <!--NeedCopy-->
    
  6. Run whoami to confirm that the command prompt is running as the Network Service account. You must get the following output: nt authority\networkservice.
  7. Use the command prompt to navigate to the SQL LocalDB instance:

    • If upgrading from SQL LocalDB 2014:

       cd "C:\Program Files\Microsoft SQL Server\120\Tools\Binn"
       <!--NeedCopy-->
      
    • If upgrading from SQL LocalDB 2017:

       cd "C:\Program Files\Microsoft SQL Server\140\Tools\Binn"
       <!--NeedCopy-->
      
    • If upgrading from SQL LocalDB 2019:

       cd "C:\Program Files\Microsoft SQL Server\150\Tools\Binn"
       <!--NeedCopy-->
      
  8. Stop and delete the SQL LocalDB instance: CitrixHA.

    SqlLocalDB stop CitrixHA
    
    SqlLocalDB delete CitrixHA
    <!--NeedCopy-->
    
  9. Remove the following files from the Delivery Controller:

    C:\Windows\ServiceProfiles\NetworkService\HADatabaseName.*
    C:\Windows\ServiceProfiles\NetworkService\HADatabaseName_log.*
    C:\Windows\ServiceProfiles\NetworkService\HAImportDatabaseName.* (if exists)
    C:\Windows\ServiceProfiles\NetworkService\HAImportDatabaseName_log.* (if exists)
    <!--NeedCopy-->
    
  10. Uninstall your existing SQL LocalDB SQL Server Express from the Delivery Controller using the native Windows feature for removing programs.
  11. Reboot the Delivery Controller after the uninstallation is complete.
  12. Stop the Citrix High Availability Service on the Delivery Controller from the Windows System Services.
  13. Mount the Citrix Virtual Apps and Desktops installation media to your Delivery Controller.
  14. Install SQL Server Express LocalDB 2022 as an administrator on the Delivery Controller.

    1. Use the sqllocaldb.msi file in the Support > SQLLocalDB folder of the Citrix Virtual Apps and Desktops installation media. For example, if the installation media is mounted to the E drive letter, the file can be found at E:\Support\SQLLocalDB\sqllocaldb.msi. A restart is required to complete the installation.
    2. The new SQL LocalDB must be in C:\Program Files\Microsoft SQL Server\160\Tools\Binn.
  15. Start the Citrix High Availability Service on the Delivery Controller from the Windows System Services.
  16. In the Command Prompt of the Delivery Controller, navigate to C:\Program Files\Microsoft SQL Server\160\Tools\Binn and run SqlLocalDB i to confirm that the CitrixHA instance was created. The CitrixHA must be included in the list of instances returned.

    Note:

    It can take up to 15 minutes for the CitrixHA database to be created after starting the Citrix High Availability Service.

  17. Ensure that the Local Host Cache database files are created to confirm that the High Availability Service (secondary broker) can take over if needed.

    1. On the Delivery Controller, browse to C:\Windows\ServiceProfiles\NetworkService.
    2. Verify that HaDatabaseName.mdf and HaDatabaseName_log.ldf are created.
  18. Repeat the steps on the remaining Delivery Controllers.
Upgrade the database and site