Session Recording

Load balancing

Session Recording supports load balancing across Session Recording Servers. To use this feature, configure load balancing on Citrix ADC so that Session Recording Servers can achieve load balancing and automatic failover.

An enhancement has been achieved that some load balancing configurations can be synchronized among all Session Recording Servers.

Note:

This feature requires Version 7.16 or later of the Session Recording Server and Session Recording Agent.

Changes to Session Recording in support of load balancing:

  • All Session Recording Servers share one folder to store recording files.
  • All Session Recording Servers share one Session Recording Database.
  • (Recommended) Install only one Session Recording Policy Console and all Session Recording Servers share this Console.

Configure load balancing

To use this feature, perform the following steps on Citrix ADC and on the various Session Recording components:

Configure load balancing (Citrix ADC part)

Configure load balancing servers

Add the Session Recording Servers to the load balancing servers in Citrix ADC.

Configure load balancing services

  1. Add a load balancing service for each needed protocol on each Session Recording Server.
  2. (Recommended) Select the relevant protocol monitor to bind each service monitor.

Configure load balancing virtual servers

  1. Create virtual servers with the same Citrix ADC VIP address based on the needed protocols and bind the virtual servers to the relevant load balancing services.
  2. Configure persistence on each virtual server.
  3. (Recommended) Choose LEASTBANDWITH or LEASTPACKETS as the load balancing method rather than the default method (LEASTCONNECTION).
  4. Create a certificate to make the HTTPS virtual server UP.

Configure load balancing (Session Recording part)

On each server where you installed the Session Recording Server, do the following

  1. (Recommended) Type the same Session Recording Database name during the Session Recording Server installation.
  2. If you choose the Administrator Logging feature, Citrix recommends that you type the same Administrator Logging Database name when you install each Session Recording Server.
  3. After sharing the Read/Write permission of the file storage folder with all Session Recording Server machine accounts, change to use the file storage folder as the shared folder in Session Recording Server Properties. For more information, see Specify where recordings are restored.
  4. Add a value to the Session Recording Server registry key at HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\SmartAuditor\Server.
    Value name: EnableLB
    Value data: 1 (DWORD, meaning enable)
  5. If you choose the HTTP or the HTTPS protocol for the Session Recording Storage Manager message queue, create a host record for the Citrix ADC VIP address, add redirections in C:\Windows\System32\msmq\Mapping\sample_map, and restart the Message Queuing service.

    The redirection is similar to:

    <redirections xmlns="msmq-queue-redirections.xml">
            <redirection>
                        <from>http://<ADCHost>*/msmq/private$/CitrixSmAudData</from>
                        <to>http://<LocalFqdn>/msmq/private$/CitrixSmAudData</to>
            </redirection>
            <redirection>
                        <from>https://<ADCHost>*/msmq/private$/CitrixSmAudData</from>
                        <to>https://<LocalFqdn>/msmq/private$/CitrixSmAudData</to>
            </redirection>
    </redirections>
    <!--NeedCopy-->
    

    Where <ADCHost> is the created FQDN of the Citrix ADC VIP address, and <LocalFqdn> is the FQDN of the local host.

  6. (Recommended) After configuring one Session Recording Server registry, you can use the following script to export configurations from this Server registry and import the registry to the other Session Recording Server registries. You can also use the script to add redirection mapping for message queuing.

    # Copyright (c) Citrix Systems, Inc.  All rights reserved.
    <#
           .SYNOPSIS
    
           This script is used to sync configurations between Session Recording Servers for load balancing deployment.
    
           .DESCRIPTION
    
        Will do below kinds of actions:
    
        1. Export values from the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\SmartAuditor\Server to SrServerConfig.reg;
    
        2. Import from SrServerConfig.reg and overwrite values in registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\SmartAuditor\Server;
    
        3. Add redirection mapping sr_lb_map.xml in %windir%\System32\msmq\mapping\;
    
           3.1 sr_lb_map.xml will consist redirection rule for both http and https, and not port specific.
    
           .PARAMETER Action
    
           Export - to export the registry configurations of Session Recording Server to a registry file
    
           Import - to import the registry configurations of Session Recording Server from a registry file
    
           AddRedirection - to add HTTP/HTTPS redirection for MSMQ
    
           .PARAMETER ADCHost
    
           The host name or FQDN of Citrix ADC.
    
        .OUTPUTS
    
        Exported configuration file (SrServerConfig.reg) or backup configuration file (SrServerConfig.reg.bk)
    
           .EXAMPLE
    
           SrServerConfigurationSync.ps1 -Action Export
    
           .EXAMPLE
    
           SrServerConfigurationSync.ps1 -Action Import
    
           .EXAMPLE
    
        SrServerConfigurationSync.ps1 -Action AddRedirection -ADCHost netscaler.xd.local
    
           .EXAMPLE
    
        SrServerConfigurationSync.ps1 -Action Import,AddRedirection -ADCHost netscaler.xd.local
    
           .EXAMPLE
    
        SrServerConfigurationSync.ps1 -Action Import,Export,AddRedirection -ADCHost netscaler.xd.local
    
    #>
    
    ######################
    
    # Parameters section #
    
    ######################
    
    Param(
    
           [Parameter(Mandatory = $true)]
    
           [ValidateSet("Export", "Import", "AddRedirection")]
    
           [string[]] $Action,
    
           [Parameter(Mandatory = $false)]
    
           [string] $ADCHost
    
    )
    
    #############################
    
    # Default variables section #
    
    #############################
    
    $SR_SERVER_REG_PATH   = "HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\SmartAuditor\Server"
    
    $REG_FILE_PATH        = "SrServerConfig.reg"
    
    $REG_BACKUP_FILE_PATH = "SrServerConfig.reg.bk"
    
    $TEMP_REDIRECT_XML    = "sr_lb_map.xml"
    
    $REDIRECT_XML_PATH    = "$env:windir\System32\msmq\mapping"
    
    ############# MAIN ###############
    
    Try
    
    {
    
           If ($Action -Contains "export") {
    
                  Write-Host "Exporting current Session Recording Server Configuration to registry file: $REG_FILE_PATH ..." -ForegroundColor Green
    
                  & REG EXPORT $SR_SERVER_REG_PATH $REG_FILE_PATH /Y
    
                  Write-Host "Finish exporting." -ForegroundColor Green
    
           }
    
           If ($Action -Contains "import")
    
           {
    
                  If (!(Test-Path $REG_FILE_PATH))
    
                  {
    
                         Write-Host "No $REG_FILE_PATH founded. Aborted." -ForegroundColor Yellow
    
                         Exit 0
    
                  }
    
                  # Back up previous registry key
    
                  Write-Host "Backing up Session Recording Server Configuration to Registry file: $REG_BACKUP_FILE_PATH ..." -ForegroundColor Green
    
                  & REG EXPORT $SR_SERVER_REG_PATH $REG_BACKUP_FILE_PATH /Y
    
                  Write-Host "Importing Session Recording Server Configuration from Registry file: $REG_FILE_PATH ..." -ForegroundColor Green
    
                  & REG IMPORT $REG_FILE_PATH 2>$null
    
                  Write-Host "Finish importing." -ForegroundColor Green
    
           }
    
           If ($Action -Contains "addredirection")
    
           {
    
                  # Check if Citrix ADC host is given; If not, exit normally with warning.
    
                  If(([String]::IsNullOrEmpty($ADCHost)))
    
                  {
    
                         Write-Host "No Citrix ADC host name is specified. Finish adding redirection." -ForegroundColor Yellow
    
                         Exit 0
    
                  }
    
                  If (!(Test-Path $TEMP_REDIRECT_XML))
    
                  {
    
                         New-Item $TEMP_REDIRECT_XML -Type file
    
                  }
    
                  $SysInfo = Get-WmiObject -Class Win32_ComputerSystem
    
                  $LocalFqdn = "$($SysInfo.Name).$($SysInfo.Domain)"
    
                  $RedirectXmlContent =
    
    @"
    
    <redirections xmlns="msmq-queue-redirections.xml">
    
           <redirection>
    
                  <from>http://$ADCHost*/msmq/private$/CitrixSmAudData</from>
    
                  <to>http://$LocalFqdn/msmq/private$/CitrixSmAudData</to>
    
           </redirection>
    
           <redirection>
    
                  <from>https://$ADCHost*/msmq/private$/CitrixSmAudData</from>
    
                  <to>https://$LocalFqdn/msmq/private$/CitrixSmAudData</to>
    
           </redirection>
    
    </redirections>
    
    "@
    
                  # Don't take care of encoding
    
                  $RedirectXmlContent | Out-File -FilePath $TEMP_REDIRECT_XML
    
                  Write-Host "Copying $TEMP_REDIRECT_XML to $REDIRECT_XML_PATH ..." -ForegroundColor Green
    
                  Copy-Item $TEMP_REDIRECT_XML -Destination $REDIRECT_XML_PATH
    
                  Write-Host "Restarting MSMQ service ..." -ForegroundColor Green
    
                  Restart-Service msmq -Force
    
                  Write-Host "Finish adding HTTP/HTTPS Redirection for MSMQ." -ForegroundColor Green
    
           }
    
           Exit 0
    
    }
    
    Catch
    
    {
    
           Write-Host "$_.Exception.Message" -ForegroundColor Red
    
           Exit 1
    
    }
    
    Finally
    
    {
    
           # Nothing to do
    
    }
    
    <!--NeedCopy-->
    

6a. Save the preceding sample code as a PowerShell script, for example, SrServerConfigurationSync.ps1.

6b. On one Session Recording Server, after configuring the EnableLB registry value, start a command prompt as an administrator and run the powershell.exe -file SrServerConfigurationSync.ps1 –Action Export,AddRedirection –ADCHost <ADCHost> command, where <ADCHost> is the created FQDN of the Citrix ADC VIP address.

6c. After the script runs, an exported registry file named SrServerConfig.reg is generated and an sr_lb_map.xml file is added to the C:\Windows\System32\msmq\Mapping path.

6d. On other Session Recording Servers, copy SrServerConfig.reg generated in the preceding step, start a command prompt as an administrator, and run the powershell.exe -file SrServerConfigurationSync.ps1 –Action Import,AddRedirection –ADCHost <ADCHost> command, where <ADCHost> is the created FQDN of the Citrix ADC VIP address.

6e. After the script runs, the EnableLB value is added to the other Session Recording Server registry keys and an sr_lb_map.xml file is added to the C:\Windows\System32\msmq\Mapping path.

On the machine where you installed the Session Recording Agent, do the following in Session Recording Agent Properties

  • If you choose the HTTP or the HTTPS protocol for the Session Recording Storage Manager message queue, type the FQDN of the Citrix ADC VIP address in the Session Recording Server text box.
  • If you choose the default TCP protocol for the Session Recording Storage Manager message queue, type the Citrix ADC VIP address in the Session Recording Server text box.

On the machine where you installed the Session Recording Player, do the following

Add the Citrix ADC VIP address or its FQDN as the connected Session Recording Server.

On the SQL Server where you installed the Session Recording Database, do the following

Add all the Session Recording Server machine accounts to the shared Session Recording Database and assign them with the db_owner permission.

Load balancing