Using resource pools

The virtual machines in a vSphere cluster share the resources of the ESXi hosts in the cluster. Resource pools are a way to divide the resources of the cluster into different pools. Virtual machines in a resource pool share the resources of their resource pool. This can be useful to always give a group of virtual machines the resources they need or to limit the number of resources for a group of virtual machines.

Each cluster has a root resource pool named Resources. The resource pools you create are children of the Resources root resource pool or other resource pools in the cluster.

Resource pools and virtual machines have settings that will be explained in the following table:

Setting

Description

Shares

A relative importance against sibling resource pools or virtual machines. Shares can have a level (Custom, High, Low, or Normal) or an amount.

Limit

The maximum allowed resources.

Reservation

The minimum available resources.

Expandable reservation (resource pool only)

If a resource pool has an expandable reservation, it can use resources of the parent resource pool, if the parent resource pool has unreserved resources.

You already saw the Move-VM cmdlet that can be used to move virtual machines into resource pools in Chapter 5 , Managing Virtual Machines with PowerCLI .

Creating resource pools

You can use the New-ResourePool cmdlet to create a resource pool. The syntax of the New-ResourcePool cmdlet is as follows:

New-ResourcePool -Location <VIContainer> -Name <String> 
    [-CpuExpandableReservation [<Boolean>]] [-CpuLimitMhz <Int64>]
    [-CpuReservationMhz <Int64>] [-CpuSharesLevel <SharesLevel>]
    [-MemExpandableReservation [<Boolean>]] [-MemLimitMB <Int64>]
    [-MemLimitGB <Decimal>] [-MemReservationMB <Int64>] [-MemReservationGB
    <Decimal>] [-MemSharesLevel <SharesLevel>] [-NumCpuShares <Int32>]
    [-NumMemShares <Int32>] [-Server <VIServer[]>] [-WhatIf]
    [-Confirm] [<CommonParameters>]

The -Location and -Name parameters are required. The value of the -Location parameter can be a resource pool, cluster, or host.

In the following example, a new resource pool named ResourcePool2 will be created for Cluster01. Because the parameter list is quite long, splatting is used to make the code more readable:

PowerCLI C:> $Parameters = @{
>> Location = (Get-Cluster -Name Cluster01)
>> Name = 'ResourcePool2'
>> CpuExpandableReservation = $true
>> CpuReservationMhz = 500
>> CpuSharesLevel = 'normal'
>> MemExpandableReservation = $true
>> MemReservationMB = 512
>> MemSharesLevel = 'high'
>> }
>> New-ResourcePool @Parameters


    Name          CpuShares CpuReser  CpuLimit MemShares MemReser MemLi
              Level     vationMHz MHz      Level     vationGB mitGB
----          --------- --------- -------- --------- -------- ------
ResourcePool2 Normal    500       -1       High      0.500    -1.000

Retrieving resource pools

To retrieve resource pools, you can use the Get-ResourcePool cmdlet. The syntax of the Get-ResourcePool cmdlet is as follows. The first parameter set is the default:

Get-ResourcePool [[-Name] <String[]>] [-Location <VIContainer[]>]
    [-Server <VIServer[]>] [-Tag <Tag[]>] [-NoRecursion]
    [<CommonParameters>]

The second parameter set to retrieve resource pools by child virtual machine:

Get-ResourcePool [[-Name] <String[]>] -VM <VirtualMachine[]>
    [-Server <VIServer[]>] [-Tag <Tag[]>] [<CommonParameters>]

The third parameter set is to retrieve resource pools by ID:

Get-ResourcePool -Id <String[]> [-Server <VIServer[]>]
    [<CommonParameters>]

The fourth parameter set is to retrieve resource pools by a related object:

Get-ResourcePool -RelatedObject
    <ResourcePoolRelatedObjectBase[]> [<CommonParameters>]

The -VM, -Id, and -RelatedObject parameters are required.

If you don't specify parameters, all of the resource pools in your environment will be retrieved. You can use the different parameters to filter the resource pools. In the following example, you will retrieve all of the resource pools of Cluster01:

PowerCLI C:> Get-Cluster -Name Cluster01 | Get-ResourcePool


    Name          CpuShares CpuReser  CpuLimit MemShares MemReser MemLi
              Level     vationMHz MHz      Level     vationGB mitGB
----          --------- --------- -------- --------- -------- ------
Resources     Normal    6560      6560     Normal    0.753    0.753
ResourcePool2 Normal    500       -1       High      0.500    -1.000

Modifying resource pools

The Set-ResourcePool cmdlet can be used to modify the settings of a resource pool. The syntax of this cmdlet is as follows:

Set-ResourcePool [-ResourcePool] <ResourcePool[]> [-Name <String>]
    [-CpuExpandableReservation [<Boolean>]] [-CpuLimitMhz <Int64>]
    [-CpuReservationMhz <Int64>] [-CpuSharesLevel <SharesLevel>]
    [-MemExpandableReservation [<Boolean>]] [-MemLimitMB <Int64>]
    [-MemLimitGB <Decimal>] [-MemReservationMB <Int64>] 
    [-MemReservationGB <Decimal>] [-MemSharesLevel <SharesLevel>]
    [-NumCpuShares <Int32>] [-NumMemShares <Int32>] [-Server <VIServer[]>]
    [-WhatIf] [-Confirm] [<CommonParameters>]

The -ResourcePool parameter is the only required parameter.

You cannot specify a new location for a resource pool using the Set-ResourcePool cmdlet, but the rest of the parameters of the Set-ResourcePool cmdlet are the same as for the New-ResourcePool cmdlet.

In the following example, the ResourcePool2 memory limit and CPU limit will be modified:

PowerCLI C:> Set-ResourcePool -ResourcePool Resourcepool2
    -MemLimitGB 4 -CpuLimitMhz 6000


    Name          CpuShares CpuReser  CpuLimit MemShares MemReser MemLi
              Level     vationMHz MHz      Level     vationGB mitGB
----          --------- --------- -------- --------- -------- ------
ResourcePool2 Normal    500       6000     High      0.500    4.000

Moving resource pools

To move a resource pool to a new location, you can use the Move-ResourcePool cmdlet, which has the following syntax:

Move-ResourcePool [-ResourcePool] <ResourcePool[]> [-Destination]
    <VIContainer> [-Server <VIServer[]>] [-WhatIf] [-Confirm]
    [<CommonParameters>]

The -ResourcePool and -Destination parameters are required.

In the following example, a new resource pool named ResourcePool1 is created in Cluster01:

PowerCLI C:> New-ResourcePool -Name ResourcePool1 -Location
    (Get-Cluster -Name Cluster01)


    Name          CpuShares CpuReser  CpuLimit MemShares MemReser MemLi
              Level     vationMHz MHz      Level     vationGB mitGB
----          --------- --------- -------- --------- -------- ------
ResourcePool1 Normal    0         -1       Normal    0.000    -1.000

The existing resource pool ResourcePool2 is relocated and made a child of the ResourcePool1 resource pool, using the following command:

PowerCLI C:> Move-ResourcePool -ResourcePool ResourcePool2
    -Destination (Get-ResourcePool -Name ResourcePool1)


    Name          CpuShares CpuReser  CpuLimit MemShares MemReser MemLi
              Level     vationMHz MHz      Level     vationGB mitGB
----          --------- --------- -------- --------- -------- ------
ResourcePool2 Normal    500       6000     High      0.500    4.000

If you want to see the hierarchy of the resource pools, you can look at the Parent property of the resource pools:

PowerCLI C:> Get-ResourcePool -Location (Get-Cluster -Name
    Cluster01) | Select-Object -Property Name,Parent


    Name                  Parent
----                  ------
Resources             Cluster01
ResourcePool1         Resources
ResourcePool2         ResourcePool1

In the output of the preceding example, you can see that the Resources resource pool is a child of the Cluster01 cluster, the ResourcePool1 resource pool is a child of the Resources resource pool, and the ResourcePool2 resource pool is a child of the ResourcePool1 resource pool.

Configuring resource allocation between virtual machines

You can also specify shares, limits, and reservations for virtual machines. You can use the Get-VMResourceConfiguration cmdlet to retrieve the current resource configuration of virtual machines. The syntax of the Get-VMResourceConfiguration cmdlet is as follows:

Get-VMResourceConfiguration [-Server <VIServer[]>]
    [-VM] <VirtualMachine[]> [<CommonParameters>]

The -VM parameter is required.

In the following example, the resource configuration of virtual machine VM1 is retrieved and piped to the Format-List -Property * command to list all the property values. The output of the example is in the following screenshot:

Configuring resource allocation between virtual machines

The Set-VMResourceConfiguration cmdlet can be used to modify the resource configuration of a virtual machine. The syntax of the Set-VMResourceConfiguration is as follows:

Set-VMResourceConfiguration [-Configuration]
    <VMResourceConfiguration[]>
    [-HtCoreSharing <HTCoreSharing>] [-CpuAffinity <CpuAffinity>]
    [-CpuAffinityList <Int32[]>] [-CpuReservationMhz <Int64>]
    [-CpuLimitMhz <Int64>] [-CpuSharesLevel <SharesLevel>]
    [-NumCpuShares <Int32>] [-MemReservationMB <Int64>]
    [-MemReservationGB <Decimal>] [-MemLimitMB <Int64>] 
    [-MemLimitGB <Decimal>] [-MemSharesLevel <SharesLevel>]
    [-NumMemShares <Int32>] [-Disk <HardDisk[]>] [-NumDiskShares <Int32>]
    [-DiskSharesLevel <SharesLevel>] [-DiskLimitIOPerSecond <Int64>]
    [-WhatIf] [-Confirm] [<CommonParameters>]

The -Configuration parameter is the only required parameter. Most of the parameters are similar to the parameters of the Set-ResourcePool cmdlet. New parameters are -Disk, -NumDiskShares, -DiskSharesLevel, and -DiskLimitIOPerSecond. These parameters allow you to set a disk I/O limit, disk shares, and a disk shares level per disk.

In the following example, the CPU and memory shares level of virtual machine VM1 are set to High:

PowerCLI C:> Get-VMResourceConfiguration -VM VM1 |
>> Set-VMResourceConfiguration -CpuSharesLevel High
    -MemSharesLevel High


    VM    NumCpuShares    CpuSharesLevel  NumMemShares    MemSharesLevel
--    ------------    --------------  ------------    --------------
VM1   2000            High            5120            High

Removing resource pools

The Remove-ResourcePool cmdlet will remove a resource pool for you. This cmdlet has the following syntax:

Remove-ResourcePool [-ResourcePool] <ResourcePool[]>
    [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

The -ResourcePool parameter is required.

In the following example, the resource pool named ResourcePool1 is removed:

PowerCLI C:> Remove-ResourcePool -ResourcePool
    ResourcePool1 -Confirm:$false

The preceding command does not return any output.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.30.232