Configure Hyper-V Server resource metering using Powershell
Configure Hyper-V Server resource metering using Powershell
In Windows Server 2012, Hyper-V includes a new resource metering technology that records and counts the load usage of virtual machines. Hyper-V allows you to measure the usage of CPU and memory resources. Windows Server 2012 provides two methods to obtain historical data about the usage of Virtual Machine resources: hyper-V cmdlet in Windows PowerShell and APIs added in the virtualized WMI provider. Hyper-V hosting vendor needs to enable resource metering technology:
1. Create a virtual machine for the customer, and then enable the resource metering function for the virtual machine once. In a multi-tenant environment, the provider enables metering for each resource pool. Then Hyper-V can track the resource usage of each virtual machine until the virtual machine is deleted.
2. query resource usage data at the end of each accounting cycle. If necessary, you can use this data to charge the customer.
3. Reset the statistical data at the end of each collection cycle. Hyper-V will re-calculate the resource usage with a new collection cycle.
Hyper-V in Windows Server 2012 allows providers to build a multi-tenant environment in which virtual machines can be provided to multiple customers in a more isolated and secure manner. Because a customer may need multiple virtual machines, Windows Server 2012 greatly simplifies this task by using the Hyper-V feature of the resource pool. A resource pool is a logical container that aggregates resources of all virtual machines belonging to the same customer and performs single-point queries on the total resource usage of the customer. The resource metering function can be used for all Hyper-V Operations. Moving virtual machines (such as using real-time migration, offline migration, or storage migration) between Hyper-V hosts does not affect the collected data.
The Hyper-V cmdlet in Windows PowerShell and the new API in the virtualized WMI provider. These tools can obtain the following resource indicators for virtual machines within a specific period of time:
1. Average CPU usage, measured in megahertz within a certain period of time.
2. Average physical memory usage, measured in megabytes.
3. Minimum memory usage (minimum physical memory ).
4. Maximum memory usage (maximum amount of physical memory ).
5. Maximum disk space allocated to virtual machines.
6. The total incoming network traffic of the virtual network adapter is measured in MB.
7. The total outgoing network traffic of the virtual network adapter is measured in MB.
In the following experiment, we will enable and configure Hyper-V Server resource metering through Windows PowerShell. The procedure is as follows:
Log on to the Hyper-V server and run Windows PowerShell as an administrator:
1. Use the following statement to enable the Hyper-V Server resource metering function:
Enable-VMResourceMetering-VMName *
2. If you want to enable resource metering for individual Hyper-V virtual machines, you can use:
Enable-VMResourceMetering-VMName MDT
3. Run the "Measure-VM" command to obtain detailed resource information of the virtual machine:
Measure-VM-VMName MDT
4. Use the following command to obtain