Поделиться через


Горизонтальное масштабирование уровня компьютера (скрипт)

 

Применимо к: System Center 2012 R2 Virtual Machine Manager, System Center 2012 - Virtual Machine Manager

После развертывания службы в VMM, можно масштабировать службу путем добавления виртуальной машины уровня компьютера. Определить, является ли уровень компьютера можно расширить, установив InstanceMaximumCount параметр для шаблона уровня компьютера.

Отказ от ответственности

Следующий скрипт проверяет, есть ли возможность масштабирования уровня, гарантируя, что добавление виртуальной машины не может превышать число максимального уровня. Затем сценарий масштабирует работу службы, добавив виртуальной машины уровня компьютера.

  
# Description:      This script scales out a service by adding a virtual machine  
#                   to a computer tier.  
  
# Get the service and the computer tier.  
$Service = Get-SCService -Name "Service01"  
$Tier = Get-SCComputerTier -Service $Service | where {$_.Name -eq "Web Tier"}  
  
# Ensure that you are able to scale out the tier.  
If ($Tier.VMs.count -eq $Tier.InstanceMaximumCount) {throw "You have reached the instance maximum for this tier."}  
  
# Create a virtual machine configuration for the computer tier.  
$VMConfig = New-SCVMConfiguration -ComputerTier $Tier -Name "NewServiceVM01" -Description "New virtual machine configuration for tier"  
  
# Get the best host on which to deploy the virtual machine.  
$VMHosts = Get-SCVMHost  
$HostRatings = @(Get-SCVMHostRating -VMHost $VMHosts -VMConfiguration $VMConfig | where {$_.Rating -gt 0} | sort -Property Rating -Descending)  
If ($HostRating.Count -eq 0) {throw "No hosts meet the placement requirements."}  
$VMHost = $HostRatings[0].vmhost  
  
# Set the host on the virtual machine configuration.  
Set-SCVMConfiguration -VMConfiguration $VMConfig -VMHost $VMHost  
Update-SCVMConfiguration -VMConfiguration $VMConfig  
  
# Create a virtual machine for the service.  
$VM = New-SCVirtualMachine -Name "NewServiceVM01" -VMConfigurationScaleOut $VMConfig  
  

См. также

Масштабирование на уровне компьютера (сценарий)