Compartir a través de


Escalado de un nivel de equipo (Script)

 

Se aplica a: System Center 2012 R2 Virtual Machine Manager, System Center 2012 - Virtual Machine Manager

Después de haber implementado un servicio en VMM, puede escalar horizontalmente un servicio mediante la adición de una máquina virtual a un nivel de equipo. Define si un nivel de equipo puede escalarse estableciendo la InstanceMaximumCount parámetro para una plantilla de nivel de equipo.

Declinación de responsabilidades

La siguiente secuencia de comandos comprueba si son capaces de escalar horizontalmente un asegurándose de que la adición de una máquina virtual no superará el número máximo de máquina para el nivel. La secuencia de comandos, a continuación, se escala el servicio mediante la adición de una máquina virtual a un nivel de equipo.

  
# 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  
  

Véase también

Escala en un nivel de equipo (Script)