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 5. Managing Storage

To build a virtual environment using VMware solutions, we start with the installation and then we configure the network in the setup. What follows next is the configuration of storage. In the previous chapters, we talked about installing ESXi hosts and then managing networking through PowerCLI. Logically, next we should configure storage in the environment. In this chapter, we are going to talk about managing different aspects of storage in the vSphere environment using PowerCLI. Before we start discussing types of storage and how we can manage them through PowerCLI, there are three basic tasks that we should be able to perform from the command line:

  • Refreshing the storage

  • Rescanning all HBA

  • Rescanning all datastores

The first one will refresh the existing storage in the environment. As the name suggests, the second will rescan all the HBAs; this particular option is very helpful if you are going to work with SAN storage. The third one will rescan all the available...

Managing datastores


Before we go ahead and start a discussion on how we can add different types of storage to an ESXi host, we will discuss a few basic tasks, such as copy and move operations on datastores. In the following example, we have the cmdlets that we can use to generally achieve the tasks:

  • Copy-DatastoreItem

  • Get-Datastore

  • Move-Datastore

  • New-Datastore

  • Remove-Datastore

  • Set-Datastore

The first cmdlet Copy-DatastoreItem lets you copy data from a local machine disk to a remote datastore:

PS C:\> Copy-DatastoreItem vmstore:\Datacenter\vsanDatastore\Test-VM\* C:\VMFolder\Test-VM\ -Force

This will copy the files related to Test-VM to a local folder in the local system.

As the name suggests, the Get-Datastore cmdlet provides a list of datastores in the systems:

PS C:\> Get-Datastore

Name                               FreeSpaceGB      CapacityGB
----                               -----------      ----------
datastore1                              11.628          12.500
datastore1...

Configuring Fibre Channel storage


To add Fibre Channel (FC) storage, we first get a list of LUNs added to the host. To get a list, we can use the Get-ScsiLun cmdlet. The format is as follows:

PS C:\> Get-ScsiLun -VmHost Esxi1.lab.com | Select CanonicalName
CanonicalName
-------------
naa.60060e801660c500000160c500000107
naa.60060e801660c500000160c500000108
naa.60060e801660c500000160c500000109

Once we get a list of the attached LUNs and identify the particular LUN that we want to add to the host, we create a new datastore using the New-Datastore cmdlet:

PS C:\> New-Datastore -Name SAN-1 -VMHost Esxi1.lab.com -Path naa.60060e801660c500000160c500000109 -Vmfs

This will create a new VMFS datastore with the name SAN-1. If we rescan all the HBAs, then it will be visible to other hosts as well.

Configuring iSCSI storage


In this section, we will configure iSCSI storage for the ESXi server. There can be primarily two types of iSCSI adapters:

  • Software iSCSI adapter: A software iSCSI adapter is a VMware code built into the VMkernel. It allows the host to connect to the iSCSI storage device through standard network adapters. The software iSCSI adapter handles iSCSI processing while communicating with the network adapter. With the software iSCSI adapter, we don't need any specialized hardware adapter.

  • Hardware iSCSI adapter: A hardware iSCSI adapter is a third-party adapter that offloads iSCSI and network processing from the host. Hardware iSCSI adapters are divided into different categories:

    • Dependent hardware iSCSI adapter: This type of adapter can be a card that presents a standard network adapter and iSCSI offload functionality for the same port. The iSCSI offload functionality depends on the host's network configuration to obtain the IP, MAC, and other parameters used for iSCSI...

Configuring NFS storage


We can add NFS storage by again using the New-Datastore cmdlet. Now, we will use the parameter –Nfs:

We can see that the NFS share has been added successfully to all the ESXi hosts. To check this, we can see the listing of the available datastores in the following screenshot:

Configuring virtual SAN


In order to configure virtual SAN, certain prerequisites need to be met. For example, we need a SSD in the server and a VMkernel portgroup needs to be configured, which will require a VSAN network. Let's first check the portgroups available in the server:

Then, check whether VSAN traffic is enabled in any of the portgroups. We will do this using the Get-VMHostNetworkAdapter cmdlet. Note the Where {…} check; here, I am checking each object for the existence of VsanTraffic:

PS C:\> Get-VMHostNetworkAdapter –VMHost ESXi1.lab.com –VMKernel | Where {$_.VsanTrafficEnabled –eq $true}

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

As you can see from the preceding example, VSAN traffic is not enabled in any of the existing portgroups. So, we will first create a portgroup VSAN in the distributed switch. Remember you need to import the VMware.VimAutomation.Vds module first, as we are going to work with a distributed switch:

PS C:\> New-VDPortgroup...

Using datastore clusters


Since we have configured the different types of datastores, let's configure the datastore cluster. We can use following cmdlets to manage different aspects of a datastore cluster:

  • Get-DatastoreCluster

  • New-DatastoreCluster

  • Remove-DatastoreCluster

  • Set-DatastoreCluster

Let's start by checking whether we already have a datastore cluster configured or not:

PS C:\> Get-DatastoreCluster
PS C:\>

We can see that there is no DatastoreCluster configured in the environment. So let's first create DatastoreCluster. As you can see in the following screenshot, we have created a datastore cluster named iSCSI-Cluster in Datacenter:

We can again check whether a datastore is present in the environment or not. As you can see in the following screenshot, a DatastoreCluster has been created:

But as you can see from the preceding example, no datastore has been added to the cluster and the storage DRS automation level has not been set. So let's check how we can set those parameters...

Using Raw Device Mapping


Though Raw Device Mapping (RDM) disks are added to a VM, we will cover this topic here as we are discussing storage-related topics here. A RDM is a pointer mapping file, which is kept in a VMFS datastore that acts as a proxy for a raw physical storage device. By using RDM, a virtual machine can directly access the raw physical device. Typically, we use RDM disks when we need to access raw disks—for example, configuring an OS cluster inside a guest OS, configuring database clusters, and so on. To add a device as a RDM disk to a VM, let's first get a list of devices available to a host. We do this using a list of SCSI devices available per host using the Get-SCSILun cmdlet:

PS C:\> Get-ScsiLun -VmHost ESXi1.lab.com | Select ConsoleDeviceName | Sort ConsoleDeviceName

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

From the device list shown in the preceding screenshot, we will take /vmfs/devices/disks/t10.FreeBSD_iSCSI_Disk______000c2905f550005_________________...

Managing storage using storage policy-based management


Storage policy-based management is the foundation for new software-defined storage. In VSAN environment, control is not at the storage end; it is at the VM end. All the policies are applied on a per VM basis and decide different aspects of the storage for the VM.

The cmdlets available under this category can be subdivided into different categories, as discussed in the following sections.

Cmdlets related to policy rules

The cmdlets related to policy rules are used to set the Rule or Ruleset:

  • New-SpbmRule

  • New-SpbmRuleSet

Cmdlets related to storage policy

The cmdlets related to storage policy are used to define different aspects of storage policy:

  • New-SpbmStoragePolicy

  • Remove-SpbmStoragePolicy

  • Set-SpbmStoragePolicy

  • Get-SpbmStoragePolicy

Cmdlets related to Spbm capabilities and compatible storage

The cmdlets related to Spbm capabilities and compatible storage are used to gather information about Spbm capabilities and the capabilities of the...

Applying VMFS resignaturing


Since we are talking about managing storage in vSphere environments in this chapter, I felt we should cover one extra topic here. One of the common tasks in vSphere is VMFS resignature. First, let's try to find out what a VMFS resignaturing task is.

By default, ESXi mounts all the datastores that are visible to the host. Each datastore has a unique UUID that is stored in the datastore superblock. Also, the unique LUN ID is store in the VMFS metadata. When a LUN is replicated, all the information is copied block by block and we get an identical LUN. If the original datastore had an UUID as X, the copied LUN also has an UUID as X.

Consider the case when you want to mount the replicated LUN; ESXi will see a duplicate LUN and will not mount the LUN automatically.

To mount the replicated LUN, we can either force-mount the copy in case we are sure the original is not in use, or we can resignature the copy so that it will have another UUID.

Though there are other ways of...

Configuring vFLASH using PowerCLI Extensions


PowerCLI Extensions is a VMware fling that provides extra cmdlets to manage the Virtual Flash in an ESXi host. To get the fling and install it, follow the procedure mentioned in this link: https://labs.vmware.com/flings/powercli-extensions. The cmdlets provided in this module are as follows:

We can configure virtual flash in an ESXi hosts using the following cmdlets:

  • Get-VMHostVFlashConfiguration

  • Set-VMHostVFlashConfiguration

The following cmdlets can be used to configure vFlash Cache for a particular hard disk:

  • Get-HardDiskVFlashConfiguration

  • Set-HardDiskVFlashConfiguration

The last three cmdlets are the ones related to instant cloning of the VMs:

  • Enable-InstantCloneVM

  • Get-InstantCloneVM

  • New-InstantCloneVM

A very detailed and interesting blog regarding instant cloning was written by Brian Graf, and you can find it at https://blogs.vmware.com/PowerCLI/2015/08/using-vmware-instant-clone-via-powercli-extensions-fling.html.

As mentioned previously...

Summary


In this chapter, we talked about configuring and managing storage in a vSphere environment. So far, we have covered the configuration of the physical aspects of an ESXi host. If you have followed till this point, then you have a physical host with ESXi installed in it. Also, networking and storage in the host are configured.

In the next chapter, we are going to talk about the last aspect of building a vSphere environment, that is, the logical constructs of the vSphere setup. In the next chapter, we will talk about configuring the datacenter, cluster, HA, DRS, 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 ₹800/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