Reader small image

You're reading from  Mastering PowerCLI

Product typeBook
Published inOct 2015
Reading LevelIntermediate
PublisherPackt
ISBN-139781785286858
Edition1st Edition
Languages
Right arrow
Author (1)
Sajal Debnath
Sajal Debnath
author image
Sajal Debnath

Sajal Debnath is a highly certified Cloud computing technocrat with more than 12 years of experience in virtualized data center design, Cloud computing, and BC/DR solutions. He is an EMCISA, VCAP-DCD/DCA, VCAP-CID/CIA, RHCE 4/5/6, RHCVA, Openstack, and ITIL certified person. He is presently associated with VMware Software India Pvt. Ltd. as a senior system engineer. Previously, he worked with France Telecom, Hewlett Packard, and many more in multiple roles. He is involved in prestigious Indian government projects, such as National Cloud, Digital Locker, and so on.
Read more about Sajal Debnath

Right arrow

Chapter 6. Managing Clusters and Other Constructs

In the last few chapters, we discussed the configuration of the physical aspects of a vSphere environment. For example, how to automate the installation of ESXi servers and configure networking and storage aspects of an ESXi host. In this chapter, we are going to talk about the logic aspects of a vSphere environment. In particular, we will discuss the following topics:

  • Configuring vCenter logical constructs

  • Configuring the Enhanced vMotion Compatibility (EVC) mode

  • Configuring High Availability (HA)

  • Using Dynamic Resource Scheduling (DRS)

  • Using the DRS affinity and anti-affinity rules

  • Managing resource pools

  • Managing alarms

To discuss and showcase these topics, we will take a freshly installed environment with just the ESXi hosts and vCenter installed. We will then build the constructs such as a datacenter, cluster, resource pool, and so on. Using PowerCLI, we will then check the other things that we can do related to this topic. So, let's first start...

Configuring vCenter logical constructs


In this section, we will discuss the different components, which are as follows:

  • A folder

  • A datacenter

  • A cluster

Folder

We are connected to a vCenter server with nothing configured in it. We will start with creating a folder. A folder is the most basic component of the logical constructs in a vCenter environment. We create folders to organize different constructs. We can use the following cmdlets to manage folders in an environment:

  • Get-Folder

  • Move-Folder

  • New-Folder

  • Remove-Folder

  • Set-Folder

First, we will create a folder under the root folder. To get the root folder, we can use the following cmdlet:

PS C:\> Get-Folder -NoRecursion

Name                           Type           
----                           ----           
Datacenters                    Datacenter  

Tip

Notice the –NoRecursion switch, by default the Get-Folder cmdlet is recursive in nature, it starts with the root folder, and shows the rest. Here, we want to see only the root folder...

Configuring the Enhanced vMotion Compatibility mode


The EVC mode is a feature that enables us to maximize the vMotion compatibility of hosts in a cluster. We can check the EVC mode at a cluster level and on a per-host basis. We can check the EVC mode on a cluster using the EVCMode property of a cluster.

For example, we can check the EVC mode for the cluster that we just created, using the following cmdlet:

PS C:\> Get-Cluster -Name "Lab Cluster" | Select -Property Name,EVCMode

Name        EVCMode
----        -------
Lab Cluster        

As seen in the preceding example, no EVC mode has been set on this cluster.

Next, let's check the maximum supported EVC mode on the ESXi hosts. To do this, we can check the MaxEVCMode property of the host:

PS C:\> Get-VMHost -Name Esxi1.lab.com | Select Name, MaxEVCMode

Name          MaxEVCMode       
----          ----------       
esxi1.lab.com intel-sandybridge

In the preceding example, the host supports the intel-sandybridge mode. We will set this...

Configuring High Availability


In this section, we will discuss how to configure HA in a cluster and the other advanced parameters related to HA.

As shown in the preceding examples, HA is not enabled for this cluster. To enable the cluster, we will again make use of the Set-Cluster cmdlet. In the following example, HA in the cluster has been enabled:

Next, we will enable the HAAdmissionControl property. Let's first check whether HAAdmissionControl is enabled or not:

PS C:\> Get-Cluster "Lab Cluster" | Select -Property HAEnabled,HAAdmissionControlEnabled

HAEnabled HAAdmissionControlEnabled
--------- -------------------------
     True                     False

To enable this property, we will use the Set-Cluster cmdlet. The process of enabling this parameter is shown in the following example:

Next, we will set HAFailoverLevel. To do this, we will set the HAFailoverLevel property of the cluster. In the following example, we have changed the failover level to 2 (the default value is 1):

In the...

Using Dynamic Resource Scheduling


In the preceding examples, for Lab Cluster, DRS is not enabled. So, first we will enable DRS for this cluster. In the following example, we have enabled DRS and the default automation level is FullyAutomated:

Next, we will change the automation level using the DrsAutomationLevel property. The valid values that we can use are as follows:

  • FullyAutomated

  • Manual

  • PartiallyAutomated

In this example, we will change the value to PartiallyAutomated:

We can use the Get-DrsRecommendation cmdlet to get the DRS recommendations for a cluster. For example, to get the DRS recommendation, we can run the following command:

PS C:\> Get-DrsRecommendation -Cluster 'Lab Cluster' -Refresh

This will refresh the cluster and show the recommendations, as shown in the following example:

Next, we will discuss the advanced settings of a DRS cluster.

Using the DRS affinity and anti-affinity rules


In this section, we will discuss the advanced settings of a cluster. We can use the following cmdlets for this section:

  • Get-DrsRule

  • New-DrsRule

  • Remove-DrsRule

  • Set-DrsRule

First, we will create a new anti-affinity rule with the two Test1 and Test2 VMs that we created for this purpose. We want to always keep them separate in such a way that they will not run on a single host at any point of time. For this, we will use the New-DrsRule cmdlet to create a rule. We will use the following command for this:

PS C:\> New-DrsRule –Cluster 'Lab Cluster' –Name `  antiAffinityTest1 -KeepTogether $false –VM Test1, Test2

The result of the preceding command is shown in the following screenshot:

Note the warning about the Cluster parameter. This warning is displayed to show you that this parameter is obsolete and should be avoided. We can check the details of the rule using the Get-DrsRule cmdlet.

We can change a rule using the Set-DrsRule cmdlet. In the...

Managing resource pools


Here, we will discuss how to create and manage resource pools in a vCenter environment. We can use the following cmdlets to manage resource pools:

  • Get-ResourcePool

  • Move-ResourcePool

  • New-ResourcePool

  • Remove-ResourcePool

  • Set-ResourcePool

As the name suggests, Get-ResourcePool provides you the details of the existing resource pools. Since we have enabled DRS in Lab Cluster, a default resource pool is already created (a root resource pool). The following are the details of this pool with default values:

Next, we will create a new resource pool named Mgmt with the following characteristics:

  • It will be created under the default Resources resource pool

  • The CpuExpandableReservation parameter is set to True

  • The CpuReservationMhz parameter is set to 500

  • The CpuSharesLevel parameter is set to High

  • The MemExpandableReservation parameter is set to True

  • The MemReservationGB parameter is set to 1

  • The MemSharesLevel parameter is set to High

In the following example, we have run the...

Managing alarms


To manage the different aspects of an alarm, we can use the following cmdlets:

  • Get-AlarmAction

  • New-AlarmAction

  • Remove-AlarmAction

  • Get-AlarmDefinition

  • Set-AlarmDefinition

  • Get-AlarmActionTrigger

  • New-AlarmActionTrigger

  • Remove-AlarmActionTrigger

There is no direct cmdlet available to create an alarm. We can create an alarm using the vSphere APIs, which we will cover in a later chapter. So, in this section, we will cover how to define and manage the different aspects of an existing alarm.

An alarm has main three parts: an alarm definition, alarm action, and alarm action trigger.

In the following screenshot, the definition is where you will define the name, description, type, and whether it is enabled or not:

We can use the Get-AlarmDefinition cmdlet to get the details regarding the definition of an existing alarm:

Next, we will make changes to the different points. We will use the Set-AlarmDefinition cmdlet for this. In the following example, we changed the name of an existing...

Summary


In this chapter, we covered how to configure and manage different logical aspects of a vCenter environment. We started by configuring constructs such as a datacenter, cluster, and so on. Next, we discussed how to manage EVC modes, HA, and DRS followed by a discussion on resource pools. At the end of the chapter, we discussed how to manage alarms.

In the next chapter, we will discuss how to create and manage virtual machines in a vSphere environment. We will cover how to modify settings in a virtual machine, run commands in a guest OS, configure fault tolerance, and so on.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering PowerCLI
Published in: Oct 2015Publisher: PacktISBN-13: 9781785286858
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Sajal Debnath

Sajal Debnath is a highly certified Cloud computing technocrat with more than 12 years of experience in virtualized data center design, Cloud computing, and BC/DR solutions. He is an EMCISA, VCAP-DCD/DCA, VCAP-CID/CIA, RHCE 4/5/6, RHCVA, Openstack, and ITIL certified person. He is presently associated with VMware Software India Pvt. Ltd. as a senior system engineer. Previously, he worked with France Telecom, Hewlett Packard, and many more in multiple roles. He is involved in prestigious Indian government projects, such as National Cloud, Digital Locker, and so on.
Read more about Sajal Debnath