XenDesktop 7.X使用powershell配置数据库 mirror、Always On、Cluster、单机和迁移手册

  重新配置DDC连接数据库之前,需要先将数据库迁移到新的数据库服务器,每台DDC的数据库帐号权限应提前配置,并在每台新数据库安全列表中能够显示出DDC的数据库帐号。
  7.X版本使用DDC的计算机帐号连接数据库,如果新的数据库上没有计算机帐号,可以使用命令在数据库上创建DDC计算机帐号。命令如下:

CREATE LOGIN [<domainname>\<computername>$] FROM WINDOWS;

  注意:
  1.本手册根据XenDesktop 7.15版本撰写,版本不同,命令使用稍有差异。可以使用get-command命令获取当前版本的命令。另外,在操作之前做好数据库备份和DDC快照,以备失败恢复。
  2.powershell要以管理员权限运行,同时也要有XenDesktop管理员权限。
  3.如果powershell中没有Citrix命令,加载Citrix命令集,请在powershell中,运行以下命令:

asnp citrix.*

数据库连接参数

单机、Cluster

$ServerName = "<dbserver>"
$FailoverServerName = "<Failoverdbserver>"
$SiteDBName = "<SiteDbName>"
$LogDBName = "<LoggingDbName>"
$MonitorDBName = "<MonitorDbName>"
$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"

镜像

$ServerName = "<dbserver>"
$FailoverServerName = "<Failoverdbserver>"
$SiteDBName = "<SiteDbName>"
$LogDBName = "<LoggingDbName>"
$MonitorDBName = "<MonitorDbName>"
$csSite = "Server=$ServerName;Initial Catalog=$SiteDBName;Integrated Security=True;Failover Partner=$FailoverServerName"
$csLogging = "Server=$ServerName;Initial Catalog=$LogDBName;Integrated Security=True;Failover Partner=$FailoverServerName"
$csMonitoring = "Server=$ServerName;Initial Catalog=$MonitorDBName;Integrated Security=True;Failover Partner=$FailoverServerName"

Always On

$ServerName = "<dbserver>"
$SiteDBName = "<SiteDbName>"
$LogDBName = "<LoggingDbName>"
$MonitorDBName = "<MonitorDbName>"
$csSite = "Server=$ServerName;Initial Catalog=$SiteDBName;Integrated Security=True;MultiSubnetFailover=True"
$csLogging = "Server=$ServerName;Initial Catalog=$LogDBName;Integrated Security=True;MultiSubnetFailover=True"
$csMonitoring = "Server=$ServerName;Initial Catalog=$MonitorDBName;Integrated Security=True;MultiSubnetFailover=True"

1.获取当前XenDesktop版本支持DDC连接数据库的命令

get-command set-*DBConnection

2.获取并保存当前DDC的数据库连接信息

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-MonitorDBConnection -DataStore Monitor
Get-LogDBConnection
Get-LogDBConnection -DataStore Logging
Get-AdminDBConnection

3.断开第一台DDC的数据库连接

## 关闭日志服务功能
Set-LogSite -State "Disabled"
## 关闭监控日志服务功能
Set-MonitorConfiguration -DataCollectionEnabled $False
Set-ConfigDBConnection -DBConnection $null
Set-AcctDBConnection -DBConnection $null
Set-AnalyticsDBConnection -DBConnection $null # for 7.6 and newer
Set-AppLibDBConnection -DBConnection $null # for 7.8 and newer
Set-OrchDBConnection -DBConnection $null # for 7.11 and newer
Set-TrustDBConnection -DBConnection $null # for 7.11 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
Set-MonitorDBConnection -DBConnection $null
Set-LogDBConnection -DataStore Logging -DBConnection $null
Set-LogDBConnection -DBConnection $null
Set-AdminDBConnection -DBConnection $null -force

## 如果在断开DDC数据库连接过程中出现任何错误,请运行以下命令后重试。
Get-Service Citrix* | Stop-Service -Force
Get-Service Citrix* | Start-Service

4.断开其它DDC的数据库连接

Reset-MonitorDataStore –DataStore Monitor
Reset-LogDataStore –DataStore Logging
Set-ConfigDBConnection -DBConnection $null
Set-AcctDBConnection -DBConnection $null
Set-AnalyticsDBConnection -DBConnection $null # for 7.6 and newer
Set-AppLibDBConnection -DBConnection $null # for 7.8 and newer
Set-OrchDBConnection -DBConnection $null # for 7.11 and newer
Set-TrustDBConnection -DBConnection $null # for 7.11 and newer
Set-HypDBConnection -DBConnection $null
Set-ProvDBConnection -DBConnection $null
Set-BrokerDBConnection -DBConnection $null
Set-EnvTestDBConnection -DBConnection $null
Set-SfDBConnection -DBConnection $null
Set-MonitorDBConnection -DBConnection $null
Set-LogDBConnection -DBConnection $null
Set-AdminDBConnection -DBConnection $null -force

5.配置数据连接变量

$ServerName = "<dbserver>"
$SiteDBName = "<SiteDbName>"
$LogDBName = "<LoggingDbName>"
$MonitorDBName = "<MonitorDbName>"
$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"

6.配置第一台DDC连接新的数据库

Set-AdminDBConnection -DBConnection $csSite
Set-ConfigDBConnection -DBConnection $csSite
Set-AcctDBConnection -DBConnection $csSite
Set-AnalyticsDBConnection -DBConnection $csSite # for 7.6 and newer
Set-HypDBConnection -DBConnection $csSite
Set-ProvDBConnection -DBConnection $csSite
Set-AppLibDBConnection –DBConnection $csSite # for 7.8 and newer
Set-OrchDBConnection –DBConnection $csSite # for 7.11 and newer
Set-TrustDBConnection –DBConnection $csSite # for 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"
Set-MonitorConfiguration -DataCollectionEnabled $true

7.配置其它DDC连接新的数据库

Set-AdminDBConnection -DBConnection $csSite
Set-ConfigDBConnection -DBConnection $csSite
Set-AcctDBConnection -DBConnection $csSite
Set-AnalyticsDBConnection -DBConnection $csSite # for 7.6 and newer
Set-HypDBConnection -DBConnection $csSite
Set-ProvDBConnection -DBConnection $csSite
Set-AppLibDBConnection –DBConnection $csSite # for 7.8 and newer
Set-OrchDBConnection –DBConnection $csSite # for 7.11 and newer
Set-TrustDBConnection –DBConnection $csSite # for 7.11 and newer
Set-BrokerDBConnection -DBConnection $csSite
Set-EnvTestDBConnection -DBConnection $csSite
Set-SfDBConnection -DBConnection $csSite
Set-LogDBConnection -DBConnection $csSite
Set-MonitorDBConnection -DBConnection $csSite
Reset-MonitorDataStore –DataStore Monitor
Reset-LogDataStore –DataStore Logging

8.检查DDC的数据库连接信息

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-MonitorDBConnection -DataStore Monitor
Get-LogDBConnection
Get-LogDBConnection -DataStore Logging
Get-AdminDBConnection

9.测试DDC的数据库连接状态

Test-AcctDBConnection -DBConnection $csSite
Test-AdminDBConnection -DBConnection $csSite
Test-AnalyticsDBConnection -DBConnection $csSite # for 7.6 and newer
Test-AppLibDBConnection -DBConnection $csSite # for 7.8 and newer
Test-BrokerDBConnection -DBConnection $csSite
Test-ConfigDBConnection -DBConnection $csSite
Test-EnvTestDBConnection -DBConnection $csSite
Test-HypDBConnection -DBConnection $csSite
Test-LogDBConnection -DBConnection $csSite
Test-LogDBConnection -DataStore Logging -DBConnection $csLogging
Test-MonitorDBConnection -DBConnection $csSite
Test-MonitorDBConnection -Datastore Monitor -DBConnection $csMonitoring
Test-OrchDBConnection -DBConnection $csSite # for 7.11 and newer
Test-ProvDBConnection -DBConnection $csSite
Test-SfDBConnection -DBConnection $csSite
Test-TrustDBConnection -DBConnection $csSite # for 7.11 and newer

参考文档

How To Configure Database Mirroring and Always on High Availability
Update database connection strings when using SQL Server high availability solutions
How to use PowerShell to Change XenDesktop SQL Connection Strings
XenApp/XenDesktop 7.X : Basic Powershell Cmdlets for Delivery Controller’s Health Check

发表评论