{"id":443,"date":"2016-05-02T10:00:54","date_gmt":"2016-05-02T14:00:54","guid":{"rendered":"https:\/\/ithinkvirtual.com\/?p=443"},"modified":"2018-02-10T10:06:31","modified_gmt":"2018-02-10T15:06:31","slug":"creating-a-single-node-vsan","status":"publish","type":"post","link":"https:\/\/ithinkvirtual.com\/2016\/05\/02\/creating-a-single-node-vsan\/","title":{"rendered":"Creating a Single-Node VSAN"},"content":{"rendered":"
Creating a Single-Node VSAN<\/strong><\/p>\r\n \u00a0<\/p>\r\n Many of us homelab enthusiasts tend to build “whitebox” systems from spare PC parts and a few internal hard drives for local storage that we’ve either ordered or had laying around in order install ESXi and run a single-node lab environment. \u00a0VMware Virtual SAN (VSAN) enables the ability to build a local SAN environment utilizing the local hard drives in the host. \u00a0The only downside\/caveat is that you need a minimum of (3) ESXi hosts in a cluster to enable and configure VSAN. \u00a0Bummer!<\/strong><\/em> \u00a0<\/p>\r\n Well, thanks to some very smart people in the community, there is a way to create a VSAN on your single-node host! \u00a0<\/p>\r\n Keep in mind that this is not supported by VMware and is recommended for testing purposes only and should not be done in a production environment\u00a0so use\u00a0at your own risk.<\/p>\r\n I will mention that this topic has been covered by other bloggers\u00a0(one of my favorites,\u00a0William Lam<\/a>, and a few others…) in the community but for my own knowledge and sharing, I decided to write this post detailing how I configured this in my environment.<\/p>\r\n Below, I will show you how to configure a hybrid and an all-flash VSAN on your ESXi host. \u00a0Again, I remind you that running a single-node VSAN is not supported by VMware and you run the risk losing all your data in the event of a\u00a0disaster scenario (system crash, etc.) \u00a0Please be sure to\u00a0understand the risks when\u00a0deciding to use this in your own home lab.<\/p>\r\n Prerequisites:<\/strong><\/p>\r\n For simplicity’s sake, I will be using a VCSA and ESXi VM deployed in VMware Workstation 12.1.1 Pro on Windows 10 for this demonstration.<\/p>\r\n <\/a> <\/a><\/p>\r\n Be sure that you have connected your ESXi host to your vCenter Server and have added it to a cluster, you do not<\/strong><\/em> need to enable VSAN on the cluster yet. \u00a0Add an additional vmk to your vSwitch for VSAN traffic. \u00a0Also ensure you have started the SSH service on the ESXi host.<\/p>\r\n Open an SSH session to your ESXi Host. \u00a0If you’ve added a vmk for VSAN but have not enabled it for VSAN traffic yet, enter the following command.<\/p>\r\n (Where “N” is the number of your vmk port – ie: vmk1)<\/p>\r\n In my environment, I already created a VSAN vmk and enabled it for VSAN traffic so I was able to skip the command above.<\/p>\r\n <\/a><\/p>\r\n Using the vSphere Web Client or C# client, verify the hard drive that you want to use for your VSAN datastore. \u00a0I will be using these drives, the 30GB will be my cache disk and the 120GB will be the capacity disk.<\/p>\r\n <\/a> <\/a><\/p>\r\n Back in your SSH session, enter the following command to determine and confirm the eligibility of the disks intended for use to create your VSAN.<\/p>\r\n <\/a><\/p>\r\n Next, enter the following command to get the current default VSAN policy.<\/p>\r\n <\/a><\/p>\r\n We will need to change the current policy by running the following commands.<\/p>\r\n <\/a><\/p>\r\n Run this command again to confirm that the policy has been changed.<\/p>\r\n <\/a><\/p>\r\n Run the following command to create a new VSAN cluster<\/p>\r\n <\/a><\/p>\r\n Now, since my disks are all SSD, I am creating an All-Flash VSAN configuration. \u00a0I need to run the following command to tag the capacity SSD as the data disk. \u00a0The “-d” represents the “capacity disk” and you need to specify the identifier of the disk to tag. \u00a0You can simply copy the identifier number directly from the ESXi hosts storage devices section in Web Client\/C# Client, or from the SSH session where we ran the “vdq -q” command. \u00a0<\/p>\r\n Note<\/strong><\/em> – If you are deploying a Hybrid VSAN, this command is not needed so you can skip to the next command to add the “cache & capacity” disks to your VSAN.<\/p>\r\n <\/a><\/p>\r\n If you’d like to confirm that the disk has been tagged for “capacityFlash” simply run the “vdq -q” command again and check the disk.<\/p>\r\n <\/a><\/p>\r\n Next, run the following command to add both your disks (cache & capacity) to your VSAN storage volume. \u00a0The “-s” represents the SSD “cache disk”, and the “-d” represents the “capacity disk”. \u00a0Be sure to enter the correct identifier number for the respective disks.<\/p>\r\n <\/a><\/p>\r\n \u00a0Run the following command to show the VSAN cluster info.<\/p>\r\n <\/a><\/p>\r\n Run the following command to list the VSAN storage<\/p>\r\n <\/a><\/p>\r\n Congratulations, if everything has been followed correctly, you should now have created a single-node VSAN datastore!<\/p>\r\n <\/a> <\/a><\/p>\r\n But we are not quite finished just yet. \u00a0Even though I can see the VSAN datastore, I still want to officially enable VSAN on the cluster in vCenter. \u00a0Do the following…<\/p>\r\n <\/a> <\/a> <\/a><\/p>\r\n In my environment, I have an extra disk in my host, but I do not want to claim this as part of my VSAN. \u00a0So, from the drop-down menu, I selected “Do not claim” and hit Next then Finish.\u00a0<\/p>\r\n <\/a> <\/a><\/p>\r\n Now I can see that VSAN is “Turned On” and can see the disks that are associated with the Disk Group.<\/p>\r\n <\/a> <\/a><\/p>\r\n But, there’s still a bit more to be done for me to be able to provision VMs on this datastore. \u00a0I need to edit the VSAN VM Storage Policy. \u00a0Personally, I prefer to leave the default policies intact and instead create a new policy for my single-node datastore. \u00a0I will show both editings of the default policy, for those who do not want to bother with creating a new policy, as well as creating a new policy. \u00a0First, let’s check the VASA storage provider and ensure it has been synchronized so that we can edit\/create our VSAN Storage policy.<\/p>\r\n <\/a> <\/a><\/p>\r\n <\/p>\r\n Editing Virtual SAN Default Storage Policy<\/strong><\/p>\r\n <\/a><\/p>\r\n Here we need to simply change:<\/p>\r\n <\/a><\/p>\r\n <\/p>\r\n Creating a new Virtual SAN Storage Policy<\/strong><\/p>\r\n <\/a><\/p>\r\n Give it a Name and a Description then hit Next<\/strong>. \u00a0<\/p>\r\n <\/a><\/p>\r\n Select VSAN from the “Rules based on data services” drop-down, then add all the rules from the drop-down and configure the same settings mentioned above, then hit Next<\/strong> and Finish<\/strong>.<\/p>\r\n <\/a> <\/a><\/p>\r\n And, there you have it! \u00a0A fully functional Single-Node VSAN to provision VMs on. \u00a0You still have to add a VSAN license, but that will not be covered here as you should already be familiar with the licensing process.<\/p>\r\n <\/a><\/p>\r\n <\/p>\r\n The Finishing touches<\/strong><\/p>\r\n The following optimizations commands are optional but highly recommended for better performance and stability in your VSAN environment.<\/p>\r\n Since this is a homelab, the disks I used may not be on the official VMware HCL and can potentially impact the performance of the lab environment. \u00a0Corman Hogan wrote a great blog<\/a> and included a tip on how to disable VSAN device monitoring. \u00a0Open an SSH session to your host again and run the following command.<\/p>\r\n To confirm that the command was successful, run the following command. \u00a0It should return a value of “0” as the default value is “1”.<\/p>\r\n <\/a><\/p>\r\n Cormac Hogan also wrote another great post<\/a> about the new “Sparse VM Swap Object”. \u00a0ESXi 6.0 Update 2 (aka 6.2) brings a new setting in VSAN 6.2 which allows VSAN to provision a VM swap object as thin instead of thick, where thick has historically been the default. \u00a0So if you’d like to disable thick provisioning and use thin, run the following command.<\/p>\r\n To confirm, run the following command. \u00a0It should return a value of “1” as the default value is “0”.<\/p>\r\n <\/a><\/p>\r\n And last, but definitely not least, if you intend on running any Nested ESXi VMs on your newly created VSAN, be sure to run the following command to prevent any errors when trying to create SCSI disks for your ESXi VM. \u00a0This will enable an advanced ESXi setting that will “fake” SCSI reservations. \u00a0William Lam has a nice post about this here<\/a>.<\/p>\r\n And to confirm it took, run the following command. \u00a0It should return a value of “1” as the default value is “0”.<\/p>\r\n <\/a><\/p>\r\n That’s all folks! \u00a0I hope that you’ve found this post to be of use to you and I hope you come back for more content. \u00a0Feel free to comment, share, and subscribe!<\/p>\r\n Giving credit where it is due, shout out to William Lam<\/a> and Cormac Hogan<\/a>!<\/p>\r\n <\/p>\r\n -virtualex-<\/p>\r\n\t
esxcli vsan network ipv4 add -i vmkN<\/pre>\r\n
vdq -q<\/pre>\r\n
esxcli vsan policy getdefault<\/pre>\r\n
esxcli vsan policy setdefault -c cluster -p \"((\\\"hostFailuresToTolerate\\\" i0) (\\\"forceProvisioning\\\" i1) (\\\"stripeWidth\\\" i1))\"\r\nesxcli vsan policy setdefault -c vdisk -p \"((\\\"hostFailuresToTolerate\\\" i0) (\\\"forceProvisioning\\\" i1) (\\\"stripeWidth\\\" i1))\"\r\nesxcli vsan policy setdefault -c vmnamespace -p \"((\\\"hostFailuresToTolerate\\\" i0) (\\\"forceProvisioning\\\" i1) (\\\"stripeWidth\\\" i1))\"\r\nesxcli vsan policy setdefault -c vmswap -p \"((\\\"hostFailuresToTolerate\\\" i0) (\\\"forceProvisioning\\\" i1) (\\\"stripeWidth\\\" i1))\"<\/span><\/pre>\r\n
esxcli vsan policy getdefault<\/pre>\r\n
esxcli vsan cluster new<\/pre>\r\n
esxcli vsan storage tag add -d <disk identifier> -t capacityFlash<\/pre>\r\n
esxcli vsan storage add -s <disk identifier>\u00a0-d <disk identifier><\/pre>\r\n
esxcli vsan cluster get<\/pre>\r\n
esxcli vsan storage list<\/pre>\r\n
\r\n\t
\r\n\t
esxcli system settings advanced set -o \/LSOM\/VSANDeviceMonitoring -i 0<\/pre>\r\n
esxcfg-advcfg -g \/LSOM\/VSANDeviceMonitoring<\/pre>\r\n
esxcli system settings advanced set -o \/VSAN\/SwapThickProvisionDisabled -i 1<\/pre>\r\n
esxcfg-advcfg -g \/VSAN\/SwapThickProvisionDisabled<\/pre>\r\n
esxcli system settings advanced set -o \/VSAN\/FakeSCSIReservations -i 1<\/pre>\r\n
esxcfg-advcfg -g \/VSAN\/FakeSCSIReservations<\/pre>\r\n