Die Wartung eines PVS-Servers ist relativ einfach. In einer Umgebung mit Lastenausgleich mit mindestens zwei PVS-Servern kann man einen Server herunterfahren, und die Verbindungen der Zielgeräte werden auf den anderen Server verschoben.
Leider gibt es manchmal eine Lücke zwischen Theorie und Realität… Wir hatten manchmal das Problem, dass die Sitzungen nicht an die zweite Sitzung übergeben wurden.
Ich sprach mit Sacha Thomet (@sacha81) und er erzählte mir von seinem Workarround. Ich sollte alle vDisks auf einem Server statisch konfigurieren, die Last ausgleichen und auf diese Weise die Sitzungen übertragen.
Da ich eine Umgebung mit einer großen Anzahl von vDisks verwalte, mache ich das nicht manuell. Aus diesem Grund habe ich dieses Skript / Cmdlet geschrieben. Affinität und Rebalancing werden nicht berücksichtigt.
Sei vorsichtig! Wenn du einen nicht funktionierenden Lastenausgleich hast, hast du ein Problem in deiner Konfiguration, und ich empfehle dir, das Problem als erstes zu beheben. Andernfalls wirst du früher oder später in Schwierigkeiten geraten.
Get-UDPvsDiskLoadblanceInfos
Mit diesem Cmdlet können die LoadBalancing Informationen von einem, mehreren oder allen vDisks ausgelesen werden.
Set-UDPvsDiskLoadblance
Um die vDisk Konfiguration vornehmen zu können, wird dieses Cmdlet verwendet. Es wird dabei die Site und den zu verwendeten Server angegeben, dies für einen oder mehrere Sites.
Set-UDPvsDiskLoadblance -Clear
Am Ende müssen die Einstellungen wieder zurückgesetzt werden, das heisst, alle vDisks wieder Loadbalancen.
Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
<# .NOTES =========================================================================== Created on: 29.03.2018 Created by: s.beckmann@unico.ws E-Mail: s.beckmann@unico.ch Organization: Unico Data AG Filename: Manage_Loadbalancing_of_vDisks.ps1 =========================================================================== .DESCRIPTION Cmdlet to configure loadbalancing on vDisks .CALL BY Import as module and use the cmdlet. .VERSION HISTORY 1.0 29.03.2018 - Initial release #> Function Get-UDPvsDiskLoadblanceInfos { <# .SYNOPSIS Get PVS vDisk information. .DESCRIPTION Get informations about the loadbalancing settings on vDisks. .PARAMETER DiskName The name of one or many vDisk, or wildecard .EXAMPLE Get-UDPvsDiskLoadblanceInfos -DiskName 'Win10' Get disk info about loadbalancing from vDsik Win10. .EXAMPLE Get-UDPvsDiskLoadblanceInfos -DiskName 'Win10','Win2012' Get disk info about loadbalancing from vDsik Win10 and Win2012. .EXAMPLE Get-UDPvsDiskLoadblanceInfos -DiskName '*' Get disk info about loadbalancing from all vDsiks. .EXAMPLE Get-UDPvsDiskLoadblanceInfos Get disk info about loadbalancing from all vDsiks. #> [CmdletBinding()] Param ( [Parameter( Mandatory = $False, Position = 0, ValueFromPipeline = $True )] [System.String[]] $DiskName = '*' ) foreach($Disk in $DiskName){ $Disks = Get-PvsDiskLocator -Fields Name,SiteName,ServerName | Where-Object {$_.Name -like $Disk} ForEach ($D in $Disks){ $Object = New-Object -TypeName psobject -Property @{ DiskName = $D.Name SiteName = $D.SiteName Servername = $D.ServerName } Write-Output $Object } } } Function Set-UDPvsDiskLoadblance { <# .SYNOPSIS Set PVS vDisk loadbalancing configuration. .DESCRIPTION Set loadbalancing configuration for one, many or all vDsiks. It's possible to set PVS Server per site and clear the static configuration. After loadbalancing is configured, the rebalancing will be started. .PARAMETER DiskName The name of one or manny vDisk, or wildecard .PARAMETER Server A hash table with Site and PVS Server .PARAMETER Clear To clear static loadbalancing configuration .EXAMPLE Set-UDPvsDiskLoadblance -DiskName 'Win10' -Server @{'Site1'='pvsserver01';'Site2'='pvsserver02'} Set the loadbalancing options for vDisk Win10, in Site1 to pvsserver01 and in Site2 to pvsserver02. Site1 has also pvsserver03 and Site2 pvsserver2 as PVS Site Server. .EXAMPLE Set-UDPvsDiskLoadblance -DiskName 'Win10','Win2012' -Server @{'Site1'='pvsserver01';'Site2'='pvsserver02'} Set the loadbalancing options for vDisk Win10 and Win2012, in Site1 to pvsserver01 and in Site2 to pvsserver02. Site1 has also pvsserver03 and Site2 pvsserver2 as PVS Site Server. .EXAMPLE Set-UDPvsDiskLoadblance -DiskName '*' -Server @{'Site1'='pvsserver01';'Site2'='pvsserver02'} Set the loadbalancing options for all vDisks, in Site1 to pvsserver01 and in Site2 to pvsserver02. Site1 has also pvsserver03 and Site2 pvsserver2 as PVS Site Server. .EXAMPLE Set-UDPvsDiskLoadblance -Server @{'Site1'='pvsserver01';'Site2'='pvsserver02'} Set the loadbalancing options for all vDisks, in Site1 to pvsserver01 and in Site2 to pvsserver02. Site1 has also pvsserver03 and Site2 pvsserver2 as PVS Site Server. .EXAMPLE Set-UDPvsDiskLoadblance -DiskName 'Win10' -Clear Set the loadbalancing options for vDisk Win10 to loadbalance. .EXAMPLE Set-UDPvsDiskLoadblance -DiskName 'Win10','Win2012' -Clear Set the loadbalancing options for vDisk Win10 and Win2012 to loadbalance. .EXAMPLE Set-UDPvsDiskLoadblance -DiskName '*' -Clear Set the loadbalancing options for all vDisks to loadbalance. .EXAMPLE Set-UDPvsDiskLoadblance -Clear Set the loadbalancing options for all vDisks to loadbalance. #> [CmdletBinding()] Param ( [Parameter( Mandatory = $False, Position = 0, ValueFromPipeline = $True )] [System.String[]] $DiskName = '*', [Parameter( Mandatory = $False, Position = 1, ValueFromPipeline = $True )] [System.Collections.Hashtable] $Server, [Parameter( Mandatory = $False, Position = 2, ValueFromPipeline = $True )] [switch] $Clear = $False ) foreach($Disk in $DiskName){ $Disks = Get-PvsDiskLocator -Fields Name,SiteName,ServerName | Where-Object {$_.Name -like $Disk} ForEach ($D in $Disks){ $Object = New-Object -TypeName psobject -Property @{ DiskName = $D.Name SiteName = $D.SiteName Servername = $D.ServerName } If ($Clear){ $D.ServerName = $Null } Else { $D.ServerName = $Server.($D.SiteName) } Set-PvsDiskLocator $D If (!$Clear){ $ServerToClearDevice = Get-PvsServer -Fields Name,SiteName | Where-Object {($_.SiteName -eq $D.SiteName) -and ($_.Name -ne $Server.($D.SiteName))} Invoke-PvsRebalanceDevices -ServerName $ServerToClearDevice.Name | Out-Null } $tmpD = Get-PvsDiskLocator -Fields Name,SiteName,ServerName | Where-Object {($_.Name -eq $D.Name) -and ($_.SiteName -eq $D.SiteName)} $Object | Add-Member -MemberType NoteProperty -Name 'NewServername' -Value $tmpD.ServerName Write-Output $Object } } If ($Clear){ $Servers = Get-UDPvsDeviceLoadblanceInfos | Sort-Object SiteName $Sites = $Servers.SiteName | Select -Unique ForEach ($Site in $Sites){ $Compare = $Servers | Where-Object {$_.SiteName -eq $Site} $max = ($Compare | measure-object -Property DeviceCount -maximum).maximum $ServerToRebalance = $Compare | ? { $_.DeviceCount -eq $max} ForEach ($S in $ServerToRebalance){ Invoke-PvsRebalanceDevices -ServerName $S.Name | Out-Null } } } } Function Get-UDPvsDeviceLoadblanceInfos { <# .SYNOPSIS Get information about the load from PVS Servers. .DESCRIPTION Get information about the device load from all PVS Server in any Site in the same Farm. .EXAMPLE Get-UDPvsDeviceLoadblanceInfos Get Informations about the loadbalancing. #> $Info = Get-PvsServerInfo |Select Name,SiteName,DeviceCount Write-Output $Info } if ((Get-PSSnapin "Citrix.PVS.SnapIn" -EA silentlycontinue) -eq $null) { try { Add-PSSnapin Citrix.PVS.SnapIn -ErrorAction Stop } catch { write-error "Error loading Citrix.PVS.SnapIn PowerShell snapin"; Return } } cls |