VMware PowerCLI

Configure VMware vSphere Cluster with Web Client or PowerCLI

In our post today we take a look at what is a VMware cluster? Also, we look at how to configure VMware vSphere Cluster with Web Client or PowerCLI.

As powerful as VMware ESXi is out of the box in a standalone single server format, we really don’t get all the benefits of running a hypervisor in a single server standalone configuration. The real power with VMware vSphere comes with standing up a VMware cluster. To do this we need VMware vCenter Server to unlock the cluster configuration and enable the cluster features that come with it. In this post we will take a look at how to configure a VMware cluster both from a Web Client perspective as well as using VMware PowerCLI. Let’s look at how to configureย VMware vSphere Cluster with Web Client orย PowerCLI.

Configure VMware vSphere Cluster with Web Client or PowerCLI

First of all, what is a VMware cluster?

What is a VMware Cluster?

A cluster in simple terms is a collection of ESXi hosts that work together. These individual hosts work together in the cluster to pool resources together so they perform as one unit. Without the cluster, we cannot unlock the true high availability and resource scheduling features that come with VMware vSphere in an enterprise cluster environment.

Web Client

First we will look at the process of creating a VMware cluster using the Web Client. ย While 6.5 still has ties to the Flash Web Client, hopefully this will change soon when VMware releases the full HTML5 client. ย For now, we have to stick with the flash based web client for now. ย The thing about the flash client is that even with all the performance improvements it is still a “steaming pile” when it comes to doing things quickly.

The first thing we need to do is create aย Datacenter. ย A Datacenterย is an aggregation of all the different types of objects needed to do work in virtual infrastructure: hosts, virtual machines, networks, and datastores. ย We need to create either a Datacenter or Folder to put our cluster in. ย Since a Datacenter holds all object types, this is our first step.

vmwclus01

Name the Datacenter.

vmwclus02

Next, we need to create aย Cluster. ย Theย cluster object is what will hold all the hosts that we want to join together in the cluster configuration.
vmwclus03

Once we choose theย New Cluster option by right clicking on our Datacenter, we have the options to Name the cluster, as well as setup DRS and vSphere HA. ย Distributed Resource Scheduler is what keeps the cluster resources balanced and new features in 6.5 even build more on on existing features. ย The vSphere HA feature uses a heartbeat mechanism to restart VM resources if they go down on a particular host.

vmwclus04

Adding Hosts

Now, we can start adding hosts to our cluster.

vmwclus05

This launches theย Add Hostย wizard. ย Here it is basically a next, next, finish operation. ย But, we have to do this for all hosts we add into the cluster.

vmwclus06

Enter user/pass information.

vmwclus07

Summary of the host and what VMs are in its inventory.

vmwclus08

Add a license or simply choose to operate in Evaluation mode.

vmwclus09

Make choices on Lockdown mode. ย This prevents users from logging directly into the host.

vmwclus10

Next we can choose what to doย on the resource side of things. ย We can choose to put all the host’s virtual machines in the cluster root resource pool or create a new one.

vmwclus11

Finally, we are ready to complete.

vmwclus12

So as you can see above, many screens and very labor intensive. ย Now, let’s take a look at how to make this process quick and easy! ย In steps PowerCLI!

PowerCLI

As labor intensive as the above is through the Web Client, we can take care of all of these actions with VMware PowerCLI which is VMware’s PowerShell environment to interact with vSphere. ย The below assumes we have already connected to our vCenter server with theย connect-viserver commandlet.

Below we declare a few variables related to getting our Datacenter and cluster created, and the hosts added. ย Using a simple text file with the ESXi host names, we feed that into the $esxhosts variable.

#Variables
$esxhosts= get-content c:toolshosts.txt
$hostcreds=get-credential
$DC='Testlab'
$cluster='cluster1'

#Create Datacenter
$folder = get-folder Datacenters
Write-Host "Creating Datacenter"
New-Datacenter -Location $folder -Name Testlab

#Create Cluster
Write-Host "Creating Cluster"
New-Cluster -Location $DC -Name cluster1 -DRSEnabled -HAEnabled -DrsAutomationlevel PartiallyAutomated

#Loop to add our hosts to the cluster
foreach ($esxhost in $esxhosts) {
    Add-VMHost -Name $esxhost -Credential $hostcreds -Location $cluster -Force:$True
    }

In a matter of seconds, we have performed the same operation that takes a couple of minutes in the Web Client. ย PowerCLI makes life so much easier than dealing with the Web Client in its flash form.

Thoughts

When we configure VMware vSphere Cluster with Web Client or PowerCLI we have many options available to us. ย The Web Client is slow and cumbersome but does provide comfort for many who are still most comfortable with a point and click type interface. ย PowerCLI is hands down a better, quicker, more efficient way to get things done in the vSphere environment. ย The simple script above shows that to be true. ย So dust off your PowerShell skills and get to using PowerCLI with your VMware environment.

Subscribe to VirtualizationHowto via Email ๐Ÿ””

Enter your email address to subscribe to this blog and receive notifications of new posts by email.



Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com, and a 7-time VMware vExpert, with over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, He has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family. Also, he goes through the effort of testing and troubleshooting issues, so you don't have to.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.