Showing posts with label ESX. Show all posts
Showing posts with label ESX. Show all posts

Monday, 16 April 2012

Add new disk to VMware linux guest without rebooting

I've been helping out jimmy with performance testing of the pmsapp and I was trying to rebuild the array for testing of RAID 5 performance when I found this little beauty to obviate the need for a reboot after adding a hard drive to an guest (VM) in linux.

In essence, once the disk has been added to the guest, run this:
echo "- - -" > /sys/class/scsi_host/host#/scan
substitute # with the appropriate number.

You can check that it has been successfully added to the system with: 
fdisk -l | grep MB

Tuesday, 6 March 2012

Using NFS for ESX/ESXi

Last week I attended a VMware training course and this week I was trying to set up a nfs datastore but I was making no headway, it always failed to mount from vSphere:
Create NFSTest datastore 172.10.121.213
Error during the configuration of the host : NFS Error: Unable to Mount filesystem: Unable to connect to
NFS server
I then remembered the training course. ESX only supports NFS 3, so I mounted the NFS share from a linux box using nfs 3:
mount <host>:/shareddir /localdir -o nfsvers=3
This worked fine from linux but not from ESX.

Network connectivity existed, i.e. I could ping and telnet on port 2049 to the NFS server, yet ESX stubbornly refused to mount the NFS share.

After doing a little bit of reading, I learnt that I was using the wrong ping command, I should have used vmkping instead, which dutifully failed to reach the NFS server.

It turns out that VMKernel needs to be able to connect to the NFS server and due to network segmentation (VLANs) the ESX hosts could not reach the NFS server from the existing VMKernel connections. So I added another VMKernel connection and I was able to mount the share with this following command:
esxcfg-nas -a nfstest -o nfsserver -s /shareddir
Although this was on a ESX 4 host, this command exists on ESXi 5.0 too.

Sunday, 4 March 2012

Rescan NICs in CentOS 6.2

Our virtualization environment runs on ESX 4 and Vcenter 4, which means that it is not possible to customize 64bit Linux distros or at least Red Hat distros, following cloning. This is annoying as CentOS does not seem to be able to pick up the new NICs in a clone, even after the ifcfg files have been edited to amend the new MAC addresses.

It turns out there is a very easy solution to this problem:

rm -f /etc/udev/rules.d/70-persistent-net.rules; init 6

This will delete the file containing NIC information and rescan after a reboot.

Do note that the second time I tried this, it created new NIC names, i.e. eth4,eth5 and eth6 for my multiple nic clone.

If you encounter this issue, you could edit the file /etc/udev/rules.d/70-persistent-net.rules or rename the ifcfg files, either should work.

Hopefully, we will move to ESXi 5 soon.

Friday, 16 December 2011

Disable NIC in ESX VM using PowerCLI

I was trying to understand how CRLs work in IIS 6.0, see my previous two posts here and here and I was trying to prevent communication between the CA server and the application server. I was having to go into vSphere and modify the settings of the NICs (disconnecting them), which got tiring pretty soon. So, I thought I would try to do it from the ESX console and after a bit of digging I found that it should be doable with the vmware-cmd command, like this:
vmware-cmd myCAserver..vmx disconnectdevice ethernet0
Alas, this was the result:
Traceback (most recent call last):
  File "/usr/bin/vmware-cmd", line 88, in ?
    main()
  File "/usr/bin/vmware-cmd", line 63, in main
    operationName, result = CommandProcessor.Process(host, args)
  File "/usr/lib/vmware/vmware-cmd/CommandProcessor.py", line 11, in Process
    result = operation.DoIt(*processedArgs)
  File "/usr/lib/vmware/vmware-cmd/operations/DeviceOps.py", line 152, in DoIt
    device.SetConnected(False)
AttributeError: 'NoneType' object has no attribute 'SetConnected'
After a extra bit of googleing which failed to come up with a decent answer, I gave up and decided to give PowerCLI a try.

I launched PowerCLI from the start menu and connected to the VI server with:
Connect-VIServer viservername
Once Connected to the vcentre server I got both VMs and stored them in a variable with the following commands:
$CA = Get-VM –Name “myCAServer”
$app = Get-VM –Name “myAppServer”
I checked that this has grabbed the VM that I wanted by simply typing:
$CA
which returns:
Name                 PowerState Num CPUs Memory (MB)
----                 ---------- -------- -----------
myCAServer           PoweredOn  1        1024           
Since both Guests have only one NIC, I got the nic details and stored in a variable for use later:
$CAnic = Get-NetworkAdapter $CA
$appnic = Get-NetworkAdapter $app
Now I can use Set-NetworkAdapter to switch them on or off at will. To turn off the CA Server’s NIC:
$CAnic = Set-NetworkAdapter –NetworkAdapter $CAnic –confirm:$false –connected:$false
And then back on:
$CAnic = Set-NetworkAdapter –NetworkAdapter $CAnic –confirm:$false –connected:$true
I can now check the status with:
$CAnic.ConnectionState
which returns:
         AllowGuestControl                  Connected            StartConnected
         -----------------                  ---------            --------------
                      True                      False                      True
Remember that command completion works pretty well, so you could just type $CAnic. And then keep pressing TAB. Similarly, if you are unsure about the switches for a cmdlet, just type - and then TAB through the options.

It is also possible to pipe commands so that you don't need to use several variables, e.g.
$CAnic = Get-VM -Name "myCAServer" | Get-NetworkAdapter | Set-NetworkAdapter -Connected:$false -confirm:$false
I still use a variable, so that I can easily check the status of the NIC, but it's not necessary, I could have simply used:
 Get-VM -Name "myCAServer" | Get-NetworkAdapter | Set-NetworkAdapter -Connected:$false -confirm:$false
I find that using variables is easier for a beginner such as myself. At any rate, I'm glad I've given PowerCLI a go as it is really good.

Monday, 5 December 2011

Active-Active MS SQL Server Failover Cluster using ESX 4.0 - part 1

Microsoft SQL Server does not support scale out deployments, which means that scaling out has to be built-in into the design of the application. The simplest way of doing this is by splitting data across two or more databases and running an active-active cluster. This is a series of posts that will show you how to do deploy such a system.  I will then use the active-active cluster to deploy two separate organizations of Microsoft Dynamics CRM 2011.

VMware has a pretty good document detailing how to create the necessary Guests (VMs) to run a successful Microsoft failover cluster here. In my opinion, there is no point in running a failover cluster from the same host, you could argue that there is no point in looking for database performance in ESX but that's a different point. At any rate, I am using a set up that allows the guests to be on different hosts and these are the pre-requisites for the hosts:
  • Two physical network adapters dedicated to the MSCS cluster and to the public and private networks.
  • One physical network adapter dedicated to the service console (ESX hosts) or the VMkernel (ESXi hosts).
  • Fibre Channel (FC) SAN. Shared storage must be on an FC SAN.
  • RDM in physical compatibility (pass-through) or virtual compatibility (non-pass-through) mode. VMware recommends physical compatibility mode. The cluster cannot use virtual disks for shared storage. Failover clustering with Windows Server 2008 is not supported with virtual compatibility mode (nonpass-through) RDMs
If you have all that, then let's move on, otherwise you could have a look at VMWare's document and follow the single host section.

I created three volumes (LUNs) in our SAN array, two for Data (one for each resource group, more on this later) and another one for the Quorum disk. The quorum disk can be small, in production (Win2k3) we run with 0.5 GB, but here I gave it 1 GB and 20 GB for the Data disks.

I tried to save time and simply cloned an already existing Guest with Windows 2008 R2 installed but it turns out that this is not a very good idea, have a look at this post. In essence, the network cards get the same Guid and this creates problems. I got around this by adding a couple of extra NICs to the second Guest, but there must be a more elegant way of doing this. I'll have to investigate.

Anyway, at this point you should have: three LUNs in your SAN array that are accessible to your Hosts, two Guests with at least two NICs and a hard drive for the OS.

Before you start, you need to ensure that the LUNs you created in the SAN array are available to the Hosts, you can do this in vSphere or through the console. (Not sure how to do it in the console, so I’ll have to investigate that as well).

In vSphere, from Home -> Inventory -> Datastores, Right Click on the Datacentre containing your Hosts -> Select Rescan for Datastores…-> Click OK.
1.1 vSphere Datastores View.
You can check that the scan has successfully found the new LUNs by trying to add a new store. Right Click on you datacentre -> Add Datastore -> Select your Host -> Select Disk/LUN -> You should now see your LUNs, see figure 1.2.
1.2 Example LUN.
Do Not Add the LUN here, just click cancel, this is a simple test to check that the LUNs are visible to the Hosts.

Note that from the console, you can just check the output of: fdisk -l

You are finally ready to start. In vSphere from Home -> Inventory -> VMs and Templates, Right Click on Node 1 (win2k8a in my example) and select Edit Settings:
1.3 Node1 (win2k8a) original settings.
  1.  Click Add.
  2. Select Hard Disk.
  3. Select Raw Mappings Device.
  4. Select the first LUN you want to use.
  5. Select Store with Virtual Machine.
  6. Select Physical Compatibility.
  7. Set Virtual Device Node to SCSI (1:0).
  8. Click Finish.
In step 6 I’ve selected Physical Compatibility, because I’m not fussed about taking snapshots as I’m running this as a test, this might not be your case, so you might want to set it to Virtual Compatibility, your call.

In Step 7, it is important that you select a different controller from the controller where your OS disk is. Normally, setting to SCSI (1:0) should be ok. If done correctly a new controller would have been added by ESX.

Repeat steps 1 to 8 for the other two LUNs. Note that you’ll need to use different virtual device nodes in step 7, e.g. 1:1 & 1:2.

Ensure that you set the SCSI controller 1 SCSI Bus Sharing to Physical, as per figure 1.4.
1.4 Second Controller SCSI Bus Sharing settings.
Let’s now move to the second node. Right Click Node 2 (win2k8b in my example) and select Edit Settings:
  1. Click Add.
  2. Select Hard Disk.
  3. Select Use an existing virtual disk.
  4. Browse to the datastore holding node 1 and in the directory for node 1, select the first LUN disk.
  5. Set Virtual Device Node to SCSCI (1:0).
  6. Click Finish.
In step 4, you should add the disks in the same order, so that they map onto each other. Not sure if this is needed, but it makes, kind of, sense.

In Step 5, it is important that you select a different controller from the controller where your OS disk is. Normally, setting to SCSI (1:0) should be ok. If done correctly a new controller would have been added by ESX.

Ensure that you set the SCSI controller 1  SCSI Bus Sharing to Physical, see figure 1.4.

This pretty much concludes the ESX setup and part one of this series. In the next post, I'll cover how to install failover clustering.