Product Documentation

Load balancing

Nov 27, 2017

Previously available as an experimental feature, load balancing is a fully supported feature in this release. This feature is to support load balancing across the Session Recording Servers. To use this feature, configure load balancing on Citrix NetScaler so that the 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.

Changes to Session Recording in support of load balancing

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

Configure load balancing

To implement this feature, you must perform the following steps on Citrix NetScaler and on the various Session Recording components:

Configure load balancing (Citrix NetScaler part)

Configure load balancing servers

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

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 NetScaler 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) Enter the same Session Recording Database name during the Session Recording Server installation.
  2. If you choose the Administrator Logging feature, Citrix recommends that you enter 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 key in the Session Recording Server registry (HKEY_LOCAL_MACHINE\Software\Citrix\SmartAuditor\Server).
    KeyName: EnableLB;
    KeyValue: 1 (D_WORD, meaning enable)
  5. If you choose the HTTP or the HTTPS protocol for the Session Recording Storage Manager message queue, create a Host for the NetScaler VIP address, add redirection 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://<NetScalerHost>*/msmq/private$/CitrixSmAudData</from>
                        <to>http://<LocalFqdn>/msmq/private$/CitrixSmAudData</to>
            </redirection>
            <redirection>
                        <from>https://<NetScalerHost>*/msmq/private$/CitrixSmAudData</from>
                        <to>https://<LocalFqdn>/msmq/private$/CitrixSmAudData</to>
            </redirection>
</redirections>

Where <NetScalerHost> is the created FQDN of the NetScaler 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. Also, you can use the script to add redirection mapping for message queue.

Script Copy

# 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 NetScalerHost

       The host name or FQDN of NetScaler.

    .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 -NetScalerHost netscaler.xd.local

       .EXAMPLE

    SrServerConfigurationSync.ps1 -Action Import,AddRedirection -NetScalerHost netscaler.xd.local

       .EXAMPLE

    SrServerConfigurationSync.ps1 -Action Import,Export,AddRedirection -NetScalerHost netscaler.xd.local

#>

######################

# Parameters section #

######################

Param(

       [Parameter(Mandatory = $true)]

       [ValidateSet("Export", "Import", "AddRedirection")]

       [string[]] $Action,

       [Parameter(Mandatory = $false)]

       [string] $NetScalerHost

)

#############################

# 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 netscaler host is given; If not, exit normally with warning.

              If(([String]::IsNullOrEmpty($NetScalerHost)))

              {

                     Write-Host "No NetScaler 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://$NetScalerHost*/msmq/private$/CitrixSmAudData</from>

              <to>http://$LocalFqdn/msmq/private$/CitrixSmAudData</to>

       </redirection>

       <redirection>

              <from>https://$NetScalerHost*/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

}

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

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

6c. After the script executes, 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 above step, start a command prompt as an administrator ,and run the powershell.exe -file SrServerConfigurationSync.ps1 –Action Import,AddRedirection –NetScalerHost <NetScalerHost> command, where <NetScalerHost> is the created FQDN of the NetScaler VIP address.

6e. After the script executes, the EnableLB key is added to the other Session Recording Server registries 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, enter the FQDN of the NetScaler VIP address in the Session Recording Server text box.
  • If you choose the default TCP protocol for the Session Recording Storage Manager message queue, enter the NetScaler VIP address in the Session Recording Server text box.

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

Add the NetScaler 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.