负载均衡
会话录制支持跨会话录制服务器进行负载均衡。要使用此功能,请在 Citrix ADC 上配置负载均衡,以便会话录制服务器可以实现负载均衡和自动故障转移。
已实现一项增强功能,即某些负载均衡配置可以在所有会话录制服务器之间同步。
注意:
此功能需要 7.16 或更高版本的会话录制服务器和会话录制代理。
为支持负载均衡而对会话录制进行的更改:
- 所有会话录制服务器共享一个文件夹来存储录制文件。
- 所有会话录制服务器共享一个会话录制数据库。
- (推荐)仅安装一个会话录制策略控制台,并且所有会话录制服务器共享此控制台。
配置负载均衡
要使用此功能,请在 Citrix ADC 和各个会话录制组件上执行以下步骤:
配置负载均衡(Citrix ADC 部分)
配置负载均衡服务器
将会话录制服务器添加到 Citrix ADC 中的负载均衡服务器。
对负载均衡服务进行配置
- 为每个会话录制服务器上所需的每个协议添加负载平衡服务。
- (建议)选择相关的协议监视器以绑定每个服务监视器。
配置负载平衡虚拟服务器
- 根据所需的协议,使用相同的 Citrix ADC VIP 地址创建虚拟服务器,并将虚拟服务器绑定到相关的负载平衡服务。
- 在每个虚拟服务器上配置持久性。
- (建议) 选择最小带宽 (LEASTBANDWITH) 或最小数据包 (LEASTPACKETS) 作为负载均衡方法,而不是默认的最小连接数 (LEASTCONNECTION) 方法。
- 创建证书以使 HTTPS 虚拟服务器处于 UP 状态。
配置负载平衡(会话录制部分)
在安装了会话录制服务器的每台服务器上,执行以下操作
- (建议)在会话录制服务器安装过程中键入相同的会话录制数据库名称。
- 如果您选择管理员日志记录功能,Citrix 建议您在安装每个会话录制服务器时键入相同的管理员日志记录数据库名称。
- 在与所有会话录制服务器计算机帐户共享文件存储文件夹的读/写权限后,将会话录制服务器属性中的文件存储文件夹更改为共享文件夹。有关详细信息,请参阅指定录制件的还原位置。
- 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)
-
如果您为会话录制存储管理器消息队列选择 HTTP 或 HTTPS 协议,请为 Citrix ADC VIP 地址创建主机记录,在 C:\Windows\System32\msmq\Mapping\sample_map 中添加重定向,然后重新启动消息队列服务。
重定向类似于以下内容:
<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-->其中 <ADCHost> 是创建的 Citrix ADC VIP 地址的完全限定域名,而 <LocalFqdn> 是本地主机的完全限定域名。
-
(推荐) 配置一个会话录制服务器注册表后,您可以使用以下脚本从该服务器注册表导出配置,并将注册表导入到其他会话录制服务器注册表。您还可以使用该脚本为消息队列添加重定向映射。
# 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. 脚本运行后,EnableLB 值将添加到其他会话录制服务器注册表项中,并且 sr_lb_map.xml 文件将添加到 C:\Windows\System32\msmq\Mapping 路径。
在安装了会话录制代理的计算机上,在会话录制代理属性中执行以下操作
- 如果您为会话录制存储管理器消息队列选择 HTTP 或 HTTPS 协议,请在 会话录制服务器 文本框中键入 Citrix ADC VIP 地址的 FQDN。
- 如果您为会话录制存储管理器消息队列选择默认的 TCP 协议,请在 会话录制服务器 文本框中键入 Citrix ADC VIP 地址。
在安装了会话录制播放器的计算机上,执行以下操作
添加 Citrix ADC VIP 地址或其 FQDN 作为连接的会话录制服务器。
在安装了会话录制数据库的 SQL Server 上,执行以下操作
将会话录制服务器的所有计算机帐户添加到共享的会话录制数据库,并为其分配 db_owner 权限。