As a small follow-up to yesterday’s post about NFS shares with Openfiler in the following article I will show how to add a new datastore to an ESX server using the vMA and PowerCLI.
From the vMA shell we are going to use the command vicfg-nas. To clarify things a bit for teh newcomers, vicfg-nas and esxcfg-nas are the same command, in fact esxcfg-nas is no more than a link to the first.
The option to create a new datastore is -a and additionally the address/hostname of teh NFS servers, the share and a label for teh new datastore must be provided.
[vi-admin@vma ~][esx01.mlab.local]$ vicfg-nas -l No NAS datastore found [vi-admin@vma ~][esx01.mlab.local]$ vicfg-nas -a -o openfiler.mlab.local -s /mnt/vg_nfs/lv_nfs01/nfs_datastore1 nfs_datastore1 Connecting to NAS volume: nfs_datastore1 nfs_datastore1 created and connected. [vi-admin@vma ~][esx01.mlab.local]$
When the operation is done you can check the new datastore with vicfg-nas -l.
[vi-admin@vma ~][esx01.mlab.local]$ vicfg-nas -l nfs_datastore1 is /mnt/vg_nfs/lv_nfs01/nfs_datastore1 from openfiler.mlab.local mounted [vi-admin@vma ~][esx01.mlab.local]$
In the second part of the post we are going to use vSphere PowerCLI, which as you already know is a PowerShell snapin to manage vSphere/VI3 infrastructure. I will write more about PowerCLI in the since I’m very fond with it.
The cmdlet to create the new NFS datastore is New-Datastore and you must provide the ESX host, the NFS server, the path of the share and a name for the datastore. Then you can check that the new datastore has been properly added with Get-Datastore.
This post is mostly for self-reference but may be someone would find it useful. Last night I decided to change the IP address of one of the Openfiler instances in my homelab and instead of previously removing the NFS shares from the ESX servers I simply made the changes.
After a restart of the network services in the Openfiler server to commit the changes I found that the ESX servers saw the datastore as inactive.
First I tried to remove it from the vSphere Client and I received the following error message:
I quickly switched to an SSH session in the vMA to check the state of the datastore, it appeared as not mounted.
[vi-admin@vma /][esx01.mlab.local]$ esxcfg-nas -l nfs_datastore1 is /mnt/vg_nfs/lv_nfs01/nfs_datastore1 from openfiler.mlab.local not mounted [vi-admin@vma /][esx01.mlab.local]$
At this point I used esxcfg-nas command to remove the datastore.
[vi-admin@vma /][esx01.mlab.local]$ esxcfg-nas -d nfs_datastore1 NAS volume nfs_datastore1 deleted. [vi-admin@vma /][esx01.mlab.local]$ esxcfg-nas -l No NAS datastore found [vi-admin@vma /][esx01.mlab.local]$
Very easy, isn’t it? Oh by the way this just confirm one of my personal beliefs “Where there is shell, there is a way” ;-)
Even if you have access to the enterprise-class storage appliances, like the HP P4000 VSA or the EMC Celerra VSA, an Openfiler storage appliance can be a great asset to your homelab. Specially if you, like myself, run an “all virtual” homelab within VMware Workstation, since Openfiler is by far less resource hunger than its enterprise counterparts.
Simon Seagrave (@Kiwi_Si) from TechHead.co.uk wrote an excellent article explaining how to add iSCSI LUNs from an Openfiler instance to your ESX/ESXi servers, if iSCSI is your “thing” you should check it.
In this article I’ll explain how-to configure a NFS share in Openfiler and then add it as a datastore to your vSphere servers. I’ll take for granted that you already have an Openfiler server up and running.
1 – Enable NFS service
As always point your browser to https://<openfiler_address>:446, login and from the main screen go to the Services tab and enable the NFSv3 service as shown below.
2 – Setup network access
From the System tab add the network of the ESX servers as authorized. I added the whole network segment but you can also create network access rules per host in order to setup a more secure and granular access policy.
3 – Create the volumes
The next step is to create the volumes we are going to use as the base for the NFS shares. If like me you’re a Unix/Linux Geek it is for sure that you understand perfectly the PV -> VG -> LV concepts if not I strongly recommend you to check the TechHead article mentioned above where Simon explained it very well or if you want to go a little deeper with volumes in Unix/Linux my article about volume and filesystem basics in Linux and HP-UX.
First we need to create the physical volumes; go to the Volumes tab, enter the Block Devices section and edit the disk to be used for the volumes.
Create a partition and set the type to Physical Volume.
Once the Physical Volume is created go to the Volume Groups section and create a new VG and use for it the new PV.
Finally click on Add Volume. In this section you will have to choose the new VG that will contain the new volume, the size, name descrption and more important the Filesystem/Volume Type. There are three type:
The first is obviously intended for iSCSI volume and the other two for NFS, the criteria to follow here is the scalibility since esxt3 supports up to 8TB and XFS up to 10TB.
Click Create and the new volume will be created.
4 – Create the NFS share
Go to the Shares tab, there you will find the new volume as an available share.
Just to clarify concepts, this volume IS NOT the real NFS share. We are going to create a folder into the volume and share that folder through NFS to our ESX/ESXi servers.
Click into the volume name and in the pop-up enter the name of the folder and click Create folder.
Select the folder and in the pop-up click the Make Share button.
Finally we are going to configure the newly created share; select the share to enter its configuration area.
Edit the share data to your suit and select the Access Control Mode. Two modes are available:
- Public guest access – There is no user based authentication.
- Controlled access – The authentication is defined in the Accounts section.
Since this is only for my homelab I choose Public access.
Next select the share type, for our purposes case I obviously choose NFS and set the permissions as Read-Write.
You can also edit the NFS options and configure to suit your personal preferences and/or specifications.
Just a final tip for the non-Unix people, if you want to check the NFS share open a SSH session with the openfiler server and as root issue the command showmount -e. The output should look like this.
The Openfiler configuration is done, now we are going to create a new datastore in our ESX servers.
5 – Add the datastore to the ESX servers
Now that the share is created and configured it is time to add it to our ESX servers.
As usually from the vSphere Client go to Configuration -> Storage -> Add storage.
In the pop-up window choose Network File System.
Enter in the Server, Folder and Datastore Name label.
Finally check the data and click finish. If everything goes well after a few seconds the new datastore should appear.
And with this we are finished. If you see any mistake or have anything to add please comment :-)
Today I learned the hard way how important is to check everything at least twice.
I had to perform an OS patching on a two node NFS cluster, a couple of BL860C running HP-UX 11.31 with three packages, one for development, one for testing and the third for the production environment.
Everything was fine until I tried to run one of the packages on its failover node in order to patch its primary, the package didn’t start. The log of the package was populated with one error after another, of course I tried to identify the source of the error… nothing, I read the config files line by line… nothing. At that point I started to sweat and then just when a I was thinking to write my resignation letter I noticed it. Somehow an extra damn “equal” slipped into the hanfs.sh file and of course the cluster didn’t recognize the sharing options and refused to start the package.
In fact the downtime has not been more than a few minutes and fortunately for me not in the production package but the excuses aren’t valid, at least for me. I was so confident on my expertise that I made a newbie mistake, probably during a modification of the package after the creation of a new filesystem.
Have to be more careful in the future.