Showing posts with label XenServer. Show all posts
Showing posts with label XenServer. Show all posts

Saturday, February 14, 2015

New Script: XenServer VM Memory Management Bash Script


Once virtual desktops are deployed, you typically don't need to adjust the resources often for those VMs unless resource utilization has grown due to additions or some other reason. This happened recently with a customer. Their desktops needed a bit more RAM and there was some additional RAM added to the XenServer hosts. They requested my help and wanted to know the quickest and least impact method for adjusting the RAM allocation for each virtual desktop. Right away I thought of three ways of accomplishing this:

  1. Manually perform this feat.
  2. Update the template VM and re-deploy hundreds of desktops. Better than manually updating the RAM allocation, but still takes too much effort and time.
  3. Script it.

Obviously I chose door number 3 above. This was a quick script, but I built some logic into it as well as added logging. With this menu driven script, you can:

  • List all VMs in a XenServer pool with a specified static max setting.
  • Update memory on all VMs within a XenServer pool with a specified static max to a newly specified amount.
  • Preview the changes before making them.
After writing the script, I chose to run the script after-hours, as this script will only change memory on VMs that are shutdown. I ran the script and updated several hundred VMs in just a few minutes.


You can read more about this script and download it here.

This post was written in reference to the following platforms and versions:

  • XenServer 6.2


Sunday, February 8, 2015

Citrix Summit 2015: Day 2

Day 2 (really day 3) started with the tech talks keynote. This key note is NDA, so I cannot go into detail. But, suffice to say there will be a good number of announcements most likely during Synergy later this year. But one thing I am excited to look into, is Workspace Cloud.

I attended self-paced labs for a good chunk of the day, which gives great hands-on experience to many Citrix technologies.  But starting in the afternoon, I attended a session about vGPU and XenServer presented by David Cottingham. It is nice to see XenServer getting some love. I am really happy about the 64bit architecture, as this will allow for further compatibility with hardware manufacturers (Fusion-io). This session went into detail about the 6.5 release of XenServer. Below are some of the new features / information about this release:
  • 64-Bit control domain. The control domain (dom0) used to be 32bit, not anymore!
  • In memory read cache. This feature allows you to store your golden images in RAM, significantly improving performance.
  • Storage. Live LUN expansion! Support for tapdisk3.
  • Network. Updated Open vSwitch 2.1.3. Improved vNIC performance.
  • vGPU. Now 96 GRID vGPU sessions per host.
  • XenServer split into two editions: Standard and Enterprise.
The last session of the day, I attended was another great presentation by Daniel Feller. Extremely fast paced because so much great information crammed into a small segment of time. Daniel went into various tests the Citrix team performed on various hypervisors with the resulting performance outcomes. The three hypervisors tested were Microsoft, VMWare, and of course Citrix. One of the best stats was that of the RAM Cache with Disk Overflow. In a nut shell, you can get down from an average of 15 IOPS per Windows 7 user to .1 IOPS. All this while not using expensive an SAN, or using local expensive SSDs or some other complex configuration or expensive 3rd party hardware addition. All you need is RAM plus some disk.


The day closes out with the partner closing keynote. Another great day! But, there is more to be had...PARTY!!! Well the partner appreciation party. This time we got bused to the Las Vegas Speedway. Plenty of great food and entertainment. You could strap in and take a ride around the oval with a professional driver, take a drifting ride, or get in the driver seat yourself with go-karts. I was able to get in the drifting car and that was a insane! Well played Citrix.

With the close of Summit, there are a few things to take away:
  • Citrix is definitely focused on consumer (a.k.a the user) experience.
  • With Framehawk integration, it is a no brainer when choosing between Citrix and VMWare.
  • Linux is not a limiting factor anymore when looking into desktop virtualization.
  • A mouse for iPad!
  • Easier migrations from Legacy Citrix products.
If you are on legacy Citrix products, thinking about VDI, or wanting to load balance / accelerate network traffic, contact a Citrix partner and ask for a demo. This year is a great year to get started.

Wednesday, January 21, 2015

Citrix Summit 2015: Day 1

As day 1 (really day 2) started and I realized it takes me 30 minutes to get from my hotel to Summit and working off bad in room coffee, I ponder my hotel choice for the event. Oh well, a quick grab of actual coffee (not hotel room coffee).... and on to the Vision Keynote! So this if the official kick off of Summit, even though it really started yesterday. Great attendance, great vibe, and a great staff as we walk into the main room. The lights dim and the information starts flowing. 

OK, there was some great presentations, but you want to see a summary, not read me ramble on about software defined stuff or whatever. But, I do have to say that Citrix has the "consumer" experience first, and this is of course not a new idea. But, this has been forgotten by many. Not that the consumer comes first, but the experience of the consumer must come first. 

One other idea that Mark Templeton introduced was the software defined workspace. What makes up the software defined workspace idea is agility, manageability, and predicting what users want before they know. 

Below is a quick list of the announcements during this keynote:
  • XenServer 6.5 - What I have been excited about during the beta testing of XenServer 6.5 is a 64bit dom0!
  • XenApp online migration tool - There are some powershell scripts to help migrate from XenApp 6.5 to 7.6, but this migration tool will make it that much easier.
  • Citrix Receiver X1 - A nice new clean interface, that can be branded, and other features like application ratings and bundles (sounds like folders). You can see the new receiver here.
  • Citrix XenMobile 10 - For more information, click here.
  • Session recording (a.k.a. Smart Auditor) - Its funny how Citrix had some great features back in the day, then depreciated them, now bringing them back. I do give Citrix great credit in listening to customers and partners, and bringing them back. Again, they are focusing on the experience and this is very apparent.
  • WorkspacePod - A complete Citrix certified integrated solution from the hardware to deliver workspaces.
  • CloudBridge Virtual WAN - More information to come.
  • Linux virtual desktops and apps - I am very excited about this. Now, I don't get very many requests for Linux virtual desktops, but I am a huge Linux fan and this makes me very happy!
  • Framehawk integration - Where do I start? Framehawk helps with packet loss (yes I am over simplifying this). But to what extent? There was a demo with up to 10% loss over a WIFI connection with the user experience seeming to be unaffected except for the computer without using Framehawk. Nice, OK. Then they bumped up the packet loss to 50%! The computer not using Framehawk was unusable, but the computer using Framehawk was working just fine. Very, very, very impressed!
  • Citrix X1 Mouse - Finally a mouse for iPad users!

After the keynote, off I went to partake of the many offerings of Citrix Summit 2015. First on the agenda was an instructor led lab about using the NetScaler 10.5 NITRO API. Now, I'm not really a developer, even though I have and currently working on some custom solutions. This was the first time I was introduced to this method and using REST interfaces. It was very interesting learning how to manipulate NetScaler outside the CLI and GUI. For more information, click here.

I finished out the day working on some more labs, like WAN optimization using CloudBridge. For more information, click here.

Next I will be posting a summary of the final day of Citrix Summit 2015 minus the NDA stuff.

Sunday, March 23, 2014

Updated: XenServer Virtual Machine Error on Boot "The VDI is not available"

Last year, I had wrote about this issue in regards to particular case I was working on, which you can find here. I am updating the troubleshooting methods and techniques not based on a specific scenario. Hopefully this makes it more useful to others.

When trying to boot a VM (virtual machine) residing on XenServer, you may get the error "The VDI is not available". This error can present itself for different reasons, but there are 2 common reasons why this happens:

  • The VDI (virtual disk image) is missing.
  • The VDI is locked to a host where the VM was running.
1. Get basic startup error information - To help narrow down the cause of the issue, we need more information. We can do this by trying to start the VM from the CLI (command line interface). To start the VM from the CLI run the following command either through the console of the XenServer host or through a SSH session to the XenServer host:

xe vm-start vm='VM name' on='XenServer host name'

2. Get detailed startup error information - To get more detailed information about this error, review the log file. You can do this from the CLI by running the following command:

less /var/log/SMlog

3. Verify if the XAPI database thinks the VM is still running and if the VDI is locked - For more information, you can see if the XAPI database thinks the VM is still running. This can happen if a host goes down with the VM running on it and the XAPI database isn't updated accordingly. To view the power state of the VM, run the following command:

xe vm-list name-label='VM name'

To find out if the VDI is locked open in the XAPI database, run the following command:

xe vdi-list params=all uuid='VM uuid'

If the VDI is locked you will see something similar to sm-config (MRO): host_OpaqueRef:6685cde1-9f08-f16b-aecc-c4e13df9c772: RW. The OpaqueRef line is a host reference, so the uuid will be different for you.

4. If the VM is not running and the VDI is not locked - If the VM is not running and the VDI is not locked, one possibility is the VDI has been removed. You will need to verify the VDI location and files. The other possibility is if the LUN where the VDI resides is having issues. If you are not running StorageLink, you can try to create a VM using that same storage repository (SR) to verify if there are any issues. If you are using StorageLink, run the following to help determine the name of the LUN on the SAN:

xe vdi-param-list uuid='VM uuid'

Look for the line that starts with location (RO):. Look for the following number on your SAN for the LUN names, it may not be the whole number showing, but you will be able to perform a partial match with the number and also size of the LUN. For example, XenServer shows 6233ac13-1a4c-49a9-8041-1b2b9c16b579, and the SAN shows 6233ac131a4c49a980411b2 for the LUN name. Once you locate the LUN on the SAN verify if there are any issues on the SAN.



5. If the power state is running, but you know the VM is powered down - If the power state is running and the VM is powered down, try resetting the power state on the VM. First on each host that is still up, run the following command to verify the VM is not running on one of them:

list_domains | grep 'VM uuid'

If a result is returned, then the VM is running on that host. When you are sure that the VM is not running on a live host, run the following command to reset the power state:

xe vm-reset-powerstate uuid='VM uuid' --force

6. Power state is not running, VDI is accessible, but VDI is locked - If the VDI is locked and the VM is verified off, you can reset the lock on the VDI. To do this, you will need to forget the VDI. To start you will need the UUID of the VDI:

xe vdi-list name-label='VDI name'


Once you get the UUID of the VDI you want to forget, run the following command:

xe vdi-forget uuid='VDI uuid'

After the command finishes, re-scan the SR and locate the VDI. Once the VDI has been located, re-attach it to the VM and try to start the VM.

If you are running XenServer 6.1, you can run the resetvdis.py script which will perform the reset operation for you. For previous versions of XenServer, the script exists, but all VMs on the SR that you run the script against must be shut down. To run the script in a XenServer 6.1 environment (always double check to make sure if the VM is running somewhere else using the command list_domains | grep 'VM uuid' on each host):

/opt/xensource/sm/resetvdis.py single 'VDI uuid'

Hopefully the above steps will help you if you run into this particular error. If you have any comments, questions, or criticisms, please leave them below.

This post was written in reference to the following platforms and versions:

  • XenServer 5.6 - 6.2

Saturday, February 22, 2014

Updated XenServer Bash Script

Originally I had written a script to eject all ISOs from every VM that has an ISO attached as well as insert an ISO into every VM in a XenServer pool. The purpose was to assist in attaching a boot ISO to Provisioning Services (PVS) Target Devices, or removing the ISO image from all VMs in a pool. You can find the original script here. I have updated the script to provide more functionality, namely to assist in transitioning away from PVS boot ISOs to network boot using TFTP, and back again if you need to roll back for any reason. Below are the features of the updated script:

  • List VMs with an ISO attached in a XenServer pool.
  • List VMs with no ISO attached in a XenServer pool.
  • Eject all ISOs and set the VMs to network boot in XenServer pool. Only VMs with ISOs will be affected.
  • Insert an ISO and set the VMs to boot from ISO in a XenServer pool. Only VMs with no ISO will be affected.
  • Eject all ISOs from all VMs in a XenServer pool.
  • Insert an ISO to all VMs in a XenServer pool. Only VMs with no ISO will be affected.

Normally, to transition from ISO boot to network TFTP boot, you need to remove the boot ISO and then set the boot order on the VM to network. Instead of thousands of clicks for hundreds of desktops, this script automates this task. It will search all VMs with ISOs attached, eject the ISO, and switch the boot device to network. Warning, this script does this for every VM in the pool that has an ISO attached. So, if you have some VMs that you don't want this to run against, make sure to remove any ISO attached to them. If for some reason, a VM does get altered, its an easy fix through XenCenter GUI to set the correct boot device and attach an ISO if so desired. As part of any migration, a roll back plan is always necessary, and this script delivers. If for some reason you need to roll back to a boot ISO, this script will set the boot device to the ISO as well as insert a named ISO into every VM that does not have an ISO attached. Again, please be cautious if you have other VMs that you don't want to alter by adding an ISO to them or change them back after the script finishes.

During a XenServer upgrade, the upgrade process likes all ISOs to be ejected from all VMs in the XenServer pool. If you only have a few servers, going to each one in XenCenter is not a big deal. But, what if you have a lot of VMs that you need to eject the ISO from ahead of time? This script automates the process, so you don't have to go to each VM and figure out if there is an ISO attached and eject if found. I recently used this as part of a XenServer 5.6 FP1 to 6.2 upgrade which worked flawlessly.

To run the script:

  1. Upload the script to a XenServer host using WinSCP (or some other method) to /usr/local/bin (or whatever other location you want).
  2. From the XenServer CLI type the following to allow execution of the script:
    1. chmod +x xenserver.sh
  3. From the XenServer CLI type the following to run the script:
    1. ./xenserver.sh
  4. Once the script executes, you will see the following menu:


To navigate, just type the number of the option you want and press enter. The only input required is the name of the ISO dependent on the option you choose.

Download the script here.

This post was written in reference to the following platforms and versions:

  • XenServer 5.6 FP1 - 6.2 SP1.





Sunday, September 1, 2013

XenServer Virtual Machine Error on Boot "The VDI is not available"

3/23/14 - This post has been updated and you can found the updated version here.

Recently, a fellow engineer was working on an Exchange environment late one evening for a client. While he was working on the Exchange server (all virtual machines running on XenServer), the machine froze and he had to force a restart. He attempted to boot the machine but received the error:

"The VDI is not availabe"

After some initial troubleshooting by the engineer, I received a call from him seeking assistance. After continually narrowing down and isolating the problematic VDI (Virtual disk image) I was able to resolve the issue. Below are the steps I took to narrow down and ultimately resolve this issue:

  1. First I checked for a possible issue with the ISO repository, I verified that there were no ISOs attached to the VM.
  2. I then reviewed the log /var/log/SMlog  on the XenServer host that is trying to boot the VM to see if there were any other underlying issues.
  3. In reviewing the log, I saw error 46, which correlates to the error message "the VDI is not available".
  4. I now need to determine the UUID of the SR that holds the VDI for further troubleshooting:
    1. You can get the SR UUID from XenCenter by clicking on the SR and navigating to the General tab.
    2. Or, you can use the CLI with the command:
      1. xe sr-list name-label=[name of the SR]
  5. Now we need to find the UUID of the VDI(s):
    1. From the CLI run the following command:
      1. xe vm-disk-list name-label=[name of VM]
  6. Once you get the UUID of the VDI(s) we need to verify if the VDI is stuck open:
    1. From the CLI run the following command:
      1. xe vdi-param-list uuid=[UUID of the VDI]
    2. Look for the line that starts with "sm-config (MRO):"
    3. If that line has "RW" in it and the VM is turned off, then the pool has placed a lock on the VDI, not allowing anyone else to use it. In my case the VDI was not locked, but in case it is for you, all you need to do is the following:
      1. You can reboot the XenServer host or try the following:
      2. From the CLI run the following command:
        1. xe vdi-forget uuid=[UUID of the VDI]
      3. Run a SR scan, you can either do it from the CLI or from XenCenter:
        1. CLI:
          1. xe sr-scan uuid=[UUID of the SR]
        2. GUI:
          1. Click on the SR with the troublesome VDI.
          2. Navigate to the Storage tab.
          3. Click the Rescan button.
      4. Now you might be able to start the VM. Again, I did not go through the above procedure since the VDI did not have a lock on it.
  7. If the VDI is not stuck open and you are not using Storage Link, check yourSAN to make sure there are no issues with the LUN.
  8. If you are using StorageLink, to find the LUN:
    1. From the CLI:
      1. xe vdi-param-list uuid=[UUID of the VDI]
    2. Look for the line that starts with location (RO):
    3. Look for this number in your SAN, the whole number will probably not be showing, but you can match most all of the numbers. Also, to help narrow down which LUNs you are looking at, sort by LUN size according to the VDI size.
      1. For example, XenServer shows: 6233ac13-1a4c-49a9-8041-1b2b9c16b579
      2. The SAN shows for the LUN name: 6233ac131a4c49a980411b2b
      3. Notice how the SAN LUN name only shows the first 24 characters of the UUID
  9. The issue this time around for me ended up being a SAN issue. The LUN was set to thin provisioning and had reached its max threshold, and the SAN set the LUN to offline, thereby creating the issue in XenServer.

Monday, August 19, 2013

How to Update The Provisioning Services (PVS) Agent or Hypervisor Tools The Easy Way

Either you are updating the Provisioning Services (PVS) client on a target device or you are updating the hypervisor tools, there are a few methods to choose from.  One of the quickest and least error prone (in my opinion) methods to perform this is by using the VHD attach method.  This method works with XenServer, Hyper-V, and VMware.  I have also used this method using PVS 5.6 and 6.1.  Instead of reverse imaging, or keeping a master VM to re-image from, all you need is the latest merged VHD.  I say merged because you will need to perform a merge (versions + base) into a single VHD if using PVS 6.1. Below are the steps to perform this in a XenServer or VMware environment.  Hyper-V is almost self-explanatory, as you can boot to the VHD without much effort.

VMware

I have used this method to migrate PVS images from VMware 4.x to 5.x, updating the VMware tools and hardware versions as well as applying PVS agent hotfixes.  This method is a bit more involved than using Hyper-V or XenServer, but it works well.
  1. Merge all versions and the base image into one VHD from within PVS.
  2. Download and install WinImage.  There is a 30 day trial for WinImage, which should be fine to complete this process.
  3. Using WinImage, convert the VHD file to VMDK.
  4. Copy the VMDK file to the VMware datastore.
  5. Create a new VM using the VMDK you just copied.
  6. Log in with the local administrator account (you may have to rejoin the domain).
  7. Uninstall the PVS agent and reboot.
  8. Install any VMware tools updates or VMware hardware version updates.
  9. Install the PVS agent.
  10. At this point you can either copy the VMDK image and use WinImage to convert the image back to VHD, or use the PVS agent wizard.

XenServer


Using XenServer is a bit quicker than using VMware as you don't have to perform any VHD conversions.

  1. Create a NFS share on the PVS server:
    1. Windows 2003:
      1. Using WinSCP, copy the following files from XenServer to the desktop:
        1. /etc/passwd
        2. /etc/group
      2. Install NFS on Windows:
        1. Launch the Add/Remove Windows Components Wizard in the Control Panel
        2. Select the following:
          1. Other Network File and Print Services | Microsoft Services for NFS
          2. Other Network File and Print Services | Microsoft Services for NFS | User name mapping
      3. Configure NFS:
        1. Open Microsoft Services for NFS.
        2. Right-click "User name mapping" and click "Properties".
        3. Select "Use password and group files".
        4. Browse to the passwd file you downloaded to your desktop for the password file.
        5. Browse to the group file you downloaded to your desktop for the group file.
        6. Click "OK".
        7. Right-click "User maps" and click "Create map".
        8. Verify the domain and select an administrator account.
        9. For the Unix user specify "root".
        10. Click "Add".
      4. Create a NFS share:
        1. Create a new directory.
        2. Right-click the new directory and select "NFS Sharing" tab.
        3. Select "Share this folder".
        4. Check "Allow anonymous access".
        5. Click "Permissions".
        6. Check "Allow root access".
        7. Set the "Type of access:" to "Read-Write".
        8. Click "OK".
        9. Click "OK".
    2. Windows 2008:
      1. Install the file role service "Services for Network File System".
      2. Create a NFS share:
        1. Create a directory.
        2. Right-click the directory and select "NFS Sharing" tab.
        3. Enable sharing and specify a name.
        4. Click "Manage NFS Sharing".
        5. Click "Permissions".
        6. Set "Type of access" to "Read-Write"
        7. Check "Allow root access".
        8. Click "OK".
        9. Click "OK".
        10. Click "OK".
  2. Create a new SR in XenServer and point to the NFS share you created earlier.  Remember, the NFS share is case sensitive.
  3. Create a new VM in XenServer with the same specifications as the existing target devices.  Choose the new NFS SR to hold the vDisk for this VM.  Do not start this VM automatically.
  4. Within PVS, set the image you want to update to private mode.
  5. Copy or cut the VHD to the NFS share directory.  You should see another VHD in the NFS share directory with the UUID of that VHD.
  6. Rename the VHD you just copied into the NFS share directory with the same name of the VHD that was created when you created the VM within XenServer.
  7. Boot the VM within XenServer.
  8. Uninstall the PVS agent.
  9. Restart the VM and update any hypervisor tools.
  10. Install the new PVS agent.
  11. Shutdown the VM and cut or copy the VHD back to the PVS store and rename it appropriately back to the original name.
  12. Boot to the image using one of your target devices to make sure all is working and then close the image as you normally do.

Wednesday, January 2, 2013

Eject / Insert an ISO to All Guest VMs in a Resource Pool at Once


3/28/14 - This post and script has been updated and you can find it here.

In a XenDesktop / XenServer (5.6 - 6.1) environment, there are a couple ways to boot virtual desktops using Provisioning Services.  I usually setup a load balanced TFTP virtual server on NetScaler and load balance between multiple Provisioning Servers.  I have written a post on configuring load balanced TFTP via NetScaler here.  But, I do run across some environments where they are using boot to ISOs for all their virtual desktops.  This works fine, but what happens if the virtual desktops loose the ISO mapping because of an issue with the ISO store.  This isn't a big deal if you are only dealing with a few virtual desktops, you just re-add the ISO through XenCenter.  But, what if you have hundreds or more of virtual desktops?  Without an automated way of either ejecting or inserting ISOs you will waste probably hours and end up with some really sore wrists.

I wrote a bash script to handle this type of situation.  The script is menu driven for ease of use.  The following are the features of the script:

  • Able to list all VMs in a resource pool with an ISO attached.  This does not include the name of the ISO, just the name of the VM.
  • Able to list all VMs in a resource pool without an ISO attached.
  • Able to eject an ISO from every VM in the resource pool.
  • Able to insert an ISO to every VM in the resource pool.
To be able to run the script, please do the following:

  1. After you download the script, upload the script to the XenServer host.  I recommend uploading the script to  /usr/local/bin.  To upload the script you can use WINSCP.
  2. Once the script is uploaded, you will need to enable the script to execute.  From either the console or a Putty session, type the following:
    1. cd /usr/local/bin
    2. chmod +x iso.sh
  3. To run the script, from either the console or a Putty session, type the following:
    1. ./iso.sh
Once the script executes, you will see the following menu:

To navigate, just type the number of the option you want and press enter.  The only other input required is when you want to insert an ISO.  This option will insert the ISO to every VM in the resource pool that does not have an ISO currently attached, so be careful.  To insert an ISO, perform the following:

  1. Type 4 and press enter.
  2. Enter the file name of the ISO you want to insert.  This must be the full ISO name, like xs-tools.iso.  This ISO must also be present in your ISO repository.  If you mistype the file name or the ISO does not exist in your ISO repository, you will see the error "Error: CD not found".
This is a basic automation script, but also has a lot of potential for added functionality.  Let me know if you have any questions or comments.


Download script here

This post was written in reference to the following platforms and versions:
  • XenServer 5.6, 6.02, and 6.1

Monday, July 30, 2012

VM Does Not Respond to Restart or Shutdown Commands


In XenServer, not too often you may have a VM that is not responsive to shutdown or restart commands through XenCenter and most likely has the yellow icon on it indicating that it is in process of doing something.  You may have even tried to restart the host, but the host is waiting for the VMs to shutdown but they won't so you cannot restart the host except by pulling the plug in which you do not want to do.  Below are some steps to try and resolve the issue starting from easy to last resorts.

  1. SSH or go to the console of the host that houses the troubled VM and perform the xe-toolstack-restart command.  If this does not fix your issue go to step 2.
  2. The next possible culprit may be a stuck task.  Perform the following commands to cycle through any tasks that may be keeping the VM stuck:
    1. To list all tasks:  xe task-list
    2. To cancel a task: xe task-cancel uuid=[uuid of task found from the previous step]
  3. After canceling any problematic tasks, check to see if your VM is still unresponsive.  If still unresponsive, proceed to step 4.
  4. If you made it this far, then the problem most likely is that the dom-id for the VM in XenServer control domain is unresponsive and needs to be terminated:
    1. Find the UUID of the VM.  You can do this through XenCenter, the UUID is found on the General tab of the VM.
    2. Connect to the host that houses the VM through the console or SSH.
    3. Run the following command: cd /opt/xensource/debug
    4. Run the following command: list_domains | grep [UUID of the problematic VM]
    5. The output format is [Dom ID] | [VM UUID]  | [VM state]
    6. Run the following command: ./xenops destroy_domain -domid [Dom ID found in previous step]
    7. Run the following command: xe-toolstack-restart
    8. Give it a few seconds and go back to XenCenter, the VM should go to a shutdown state (again give it a few seconds to refresh)
  5. The last and not recommended method is to power-cycle your host.  You shouldn't have to do this step if you follow the above correctly (at least I haven't ever had to do this for a stuck VM).

Wednesday, June 27, 2012

Enable SSH Access on a Citrix License Appliance

A customer recently started to get not enough license errors while connecting to their XenDesktop environment.  The customer uses a Citrix License Appliance, hosted in their XenServer pool.  I verified they were out of licenses by going to the web interface of the license appliance.  I then went to the console of the license appliance and quickly verified there are users listed as having a license but do not exist anymore.  So, instead of trying to go through each user line by line through the console, I wanted to export that information so the client could review the list and then we could take the appropriate steps.  Trying to copy almost 500 users listed did not work.  So, instead I needed to enable SSH access so I could then copy the output file generated and send it off for review.  Below are the steps taken to enable SSH access on the Citrix License Appliance:

  1. Connect to the console of the Citrix License Appliance through XenCenter.
  2. Login with root access.
  3. Open the following file with a text editor like vi:  vi /etc/sysconfig/iptables
  4. Add the following line: -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
  5. Save the file and exit the text editor.
  6. Run the following command: service iptables restart
  7. To make the SSH service start every time you boot the appliance, run the following command: chkconfig sshd on
  8. To start the SSH service, run the following command: service sshd start
  9. To verify the license appliance is listening on port 22, run the following command: netstat -tulpn
After performing the above, you should be able to access your license appliance through SSH.  At this point, I ran the udadmin -list -a > liclist.txt command to save the list of users with licenses to a text file.  Then, I used WinSCP to copy that text file over to send to the client.

Tuesday, April 24, 2012

NICs Disappear in XenServer After Reboot or Hotfix Installation


During a XenServer reboot or hotfix installation when there are multiple XenServers in the pool, you may run into an issue where the NICs seem to disappear.  Also, if you try to run XE commands, you may get the error "The host is still booting".  In the cases I have seen this issue, the problem is what the problematic XenServer thinks is the pool master when in fact the pool master is a different host.  Below are the steps I went through to diagnose and resolve this issue:

  1. Go to the hosts command line interface (CLI).
  2. Type ifconfig and verify the underlying system sees the NICs and that they are up.
  3. Navigate to \var\log\xensource.log and review the log entries.  In my case, it was stating that it was trying to contact the pool master, but was not receiving a response.  I knew my pool master was up and functional as the other XenServer hosts did not have an issue.
  4. Navigate to \xensource\pool.conf and modify the IP address found inside the file to the current pool master IP.
  5. At the CLI, type xe-toolstack-restart.
Let me know if you have any questions or comments.

Tuesday, March 6, 2012

XenServer "This file could not be imported"

If you are trying to import a virtual appliance into an older version of XenServer you may receive the following error:

"Preparing to Import VM

This file could not be imported
Check your settings and try again."

This can be the case of a corrupted XVA file, or this may be a case of not being able to understand how new XVA's are packaged.  When I saw this error for the first time, the later was the issue for me.

In the case of the new XVA packaging style, lets take a closer look.  For example, lets start with the license virtual appliance for XenServer 5.6 (Citrix_License_Server_VPX1.01.xva).  If you open this file with a utility like 7zip, you will see a folder with sub-files and a xml file.  If you open the newer license server virtual appliance with 7zip (Citrix_License_Server_VPX_v11.10.0_Build_12002.xva), you will see another xva file.  Also, you may have noticed when you downloaded Citrix_License_Server_VPX1.01, it was compressed in a zip file, but when you downloaded Citrix_License_Server_VPX_v11.10.0_Build_12002, there was no zip file, it was just a xva file.

So, if you are receive the above error and you cannot upgrade your XenServer (I started seeing the newer type xva inside a xva starting with XenServer 6.0) to be able to handle this new packaging, all you need to do is open the downloaded xva file with a file compression client like 7zip and extract the xva file found inside.  Then use the extracted xva file to import into your XenServer environment.  I looked and have not found any Citrix articles on this yet, so if anyone finds a Citrix article referencing this issue please post in the comments below.  Or, if you have found a different cause for the above error, please post in the comment section below.


Monday, February 20, 2012

XenApp and High Availability (HA) / Disaster Recovery (DR)


Designing high availability (HA) and / or disaster recovery (DR) can be a daunting task.  There are many options and many components in which to consider.  Just a sampling of some of the questions you will have to consider:
  • How the failover will function?
  • What is the process for failover?
  • Why would you want a manual or automatic process?
  • What systems do you want to protect?
  • How will users gain access to their data?
This article does not try to cover all of the complexities of a DR design but it does address the recommended guidelines when considering XenApp in use with NetScaler to provide a highly available design.

Server Capacity Sizing

When designing a XenApp environment, many customers say they want it designed for X number of users.  But, what they need to keep in mind as well as the consultant is to make sure they have extra room to handle a server outage.  For instance, if one of the XenApp servers were to fail, those users will need to be distributed among the rest of the XenApp servers.  The design should be a N + 1 design as recommended by Citrix.  This design allows for a failure of 1 server and the rest of the servers will still be able to handle the user load without any performance degradation.

SQL

In most larger companies, SQL servers are protected through either clustering, mirroring, or replication.  But a lot of smaller companies forgo this option as it might seem too complex, or not necessary.  No matter what the company size is, protecting your databases is important.  But, this is easily solved, and not as complex as what some may think.  There are even 3rd party software vendors that try to make this as easy as possible, like Double-Take.  Also starting with SQL 2005, these methods are built into the product.  So in other words, there is no excuse, protect your SQL server.

Hypervisor

I'm not going to go into all the benefits of server virtualization, but in regards to XenApp, there are a few benefits I want to point out.  These benefits have a direct correlation with your HA / DR design.

First, HA.  With HA, you can configure your VM's to restart on another host, if the original housing host fails suddenly.  This will keep your XenApp farm with your desired number of servers up.  Yes, users will lose their connection if they were on the VM that lived on the host that failed.  But, with your N+1 design, they try to login right away and of course get redirected to a different live server.  This gives, the failed VM enough time to restart on a good host and ready to handle user traffic again without your intervention.  VMWare and XenServer do this very well.

Second, [Xen/V]motion.  If a hypervisor host is failing, meaning it hasn't failed yet, but its demise is imminent you can move your live running servers to another hypervisor host with no disruption to your users (yes, they may experience a brief "pause", but their sessions remain active and no data is lost).  Most all of hypervisors have this functionality, VMWare calls it VMotion and XenServer calls it XenMotion.  Whatever you call it, it works, and it works well.

Third, DR.  Most major hypervisor players offer some sort of DR feature in their product as well.  This allows the virtual machines (VMs) to be brought up at another separate physical location in the event of a catastrophic failure.  This would be considered a standby method.  This means, that the DR site is not active and needs to be brought online before any resources can be utilized.  I wouldn't say this is good for all servers, as some would benefit more from a service level DR, like with SQL mirroring and such.  I like using this on servers that have data that doesn't change much, so the likely hood of data loss is mitigated.  A hybrid approach is best used when considering this feature.  XenApp servers are a good fit for this as there is no data on them.

Access Gateway

Access Gateway (AG) allows for secure access to published resources and internal systems through either an ICA proxy or SSL VPN.  If you were to only have 1 AG, and it went down, then all external users would then be unable to access the internal systems.  Therefore, it is best to deploy them in a pair so you can load balance across them, and you can achieve load balancing across your AGs via NetScaler.  Even easier, you could run AG as a feature inside your NetScaler.

Web Interface / Cloud Gateway

No, I'm not discussing the difference between Web Interface (EOL 2015) and Cloud Gateway (Web Interfaces successor).  But, you need either or to allow users to gain access to their published resources.  You need to think of how many are needed to handle the user load, especially during peak times in the morning when users are getting in and starting their sessions.  But, no matter what, always have at least 2 (if you are having bad performance because you failed to properly size the number of front end servers needed, don't blame me).  Great you have 2, but how do you balance them?  Microsoft NLB?  No!  You use NetScaler to load balance the servers.  NetScaler is smart enough (as long as you configure it) to determine if a server down and traffic needs to be redirected to another server, or to just redistribute traffic.

Broker Service

What does the broker service do?  The broker service is what your Web Interface (WI) / Cloud Gateway (CG) uses to authenticate users when they login, enumerate published resources for a user, and direct users to an available XenApp server.  So, if that server were to go down, users wouldn't be able to do anything, not even login to the WI / CG.  Again, you want to properly size your environment for your user load, but also again, you don't want to have just 1 broker service.  Also, just like WI / CG, you use the abilities of NetScaler to load balance your brokers for performance and making sure they are online before sending requests.

Data

If you have a multiple site implementation of XenApp, then you have to contend with user data between them.  First, which I am hoping you have done already, is implemented some form of profile offloading from the XenApp servers.  This can be done through Citrix Profile Management, or through a 3rd party vendor like AppSense, or RES.  Then you have to make sure the data that the users are accessing is close to the XenApp farm.  In the case of multi-site XenApp implementations, you will need to do a couple things:

  1. Replicate user data between sites.  You can accomplish this through SAN replication, Microsoft DFSR, or some other 3rd party solution.
  2. Make sure you set the preferred XenApp site for your users so that they are closest to their data.

Global Server Load Balancing

Global Server Load Balancing (GSLB) is not part of XenApp, but it is part of NetScaler and it pairs very well with this discussion.  GLSB allows a single namespace to be load balanced or failover between physical sites.  So, if you had to failover to your DR site, you can do this at the URL level with GLSB and continue on down the line of bringing your services online.

In Conclusion

The combination of NetScaler, XenServer, and XenApp provide solid basis for a XenApp HA / DR solution.  This article went over at a high level of the components to think about when designing a XenApp HA / DR solution.  There are many other products that compliment this solution, but that is for another time.




Saturday, January 21, 2012

Not All XenServer 5.x Bonds Are Created Equal

Update!: This article was written while XenServer 5.6 was the latest and greatest.  This article does not include the updates for XenServer 6.x.

If you have just installed XenServer for the first time, or you have many XenServer installs under your belt you have obviously dealt with creating NIC bonds.  There are a few things to think about when creating NIC bonds:


  • Does this bond include management interfaces?
  • What type of traffic is this bond going to host?
  • Does this bond connect to your SAN over iSCSI?
Types of Bonds

There are 2 types of bonds, active-active and active-standby.  Active-active bonds is default when you create a bond (you can later change the bond type through the CLI).  Active-active bonds send traffic over both NIC's at the same type, so you gain better throughput (Note: VM's can only use 1 NIC at a time, even if they are in bond.  XenServer load balances traffic among all VM's that are using the bond every 10 seconds and adjusts accordingly).  

The other type of bond is active-standby.  This bond only has 1 active NIC at any given time, and uses the other NIC for fail-over scenarios.  This type of bond is great for HA as well, but does not give the same throughput like active-active bonds.

Mangement Interfaces and NIC Bonds, why care?

What are management interfaces?  Management interfaces are XenServer networks with an IP address assigned to them.  You setup the primary management interface when you first install XenServer, and you use this interface to connect via XenCenter.  You can create additional management interfaces as well, for instances, to connect to your SAN via iSCSI (which we will discuss later).  You can also create a management interface on a bond for high availability (HA), which is good, right?  Well, not always.  Management interfaces act in a active-standby mode on the bond.  So, network throughput is not load balanced across both NIC's, only 1 NIC is used at any given time.  This also forces all other traffic that goes over this bond to be active-standby.  So if you have a management interface network bond, only 1 NIC is being used at any given time no matter what traffic is passing through.  The reason why you would want to care, is if you also have your VM's use this bond for their traffic, thereby limiting their collective throughput.

So, a good idea would be to create a bond for your primary management interface and do not allow VM's to use this network bond.  This enables HA for your XenServers management connection.  You can then, create another bond (or bonds, depending on your requirements) to use for VM traffic, enabling redundant connections for your VM's as wells as better collective throughput.

Connecting to your SAN via iSCSI

As discussed before, a management interface is a XenServer network with an assigned IP address.  When you connect to your SAN via iSCSI (I am assuming this is over a different VLAN as it should) you need to assign an IP address, so you end up creating a management interface.  This may not be the optimal configuration as we have also discussed before, management interface network bonds use the active-standby bond mode, so only 1 NIC will be handling iSCSI traffic at any given time.  Obviously, you want to gain as much performance for your iSCSI traffic (there are methods in addition to gain better performance but are not in the scope of this document) but if you are only utilizing 1 NIC, that is not optimal.  What does Citrix recommend?  Whenever possible, Citrix recommends setting up multipathing.  With multipathing, you gain the throughput of additional NIC's as well as the redundancy of multiple NIC's.  That is great, but there is a gotcha.  Some SANs do not support multipathing, so your only other option for a redundant connection is to use a management interface network bond.

Hope this gives further insight into designing your XenServer networking!  Let me know if you have any comments or questions.

-Chris Keim


Thursday, December 29, 2011

Extremely Slow XenServer Performance

A week ago, I decided to ditch my dual boot lab at home and build a dedicated XenServer with more RAM (16GB to be precise, I was tired of being limited to 6GB and my wife hated it when our home computer was booted to XenServer). I bought the following components on a whim trip to Fry's:

16GB RAM
AMD Phenom II 960 Black Edition
MSI 880GM-E43
Western Digital Blue 300GB drive (already had this at home)
Western Digital Green 500GB drive (already had this at home)
ASUS DVD-ROM
The cheapest case I could find at Fry's which was a Cooler Master Elite 430 Black

I put together all the components, with no issues. I then installed XenServer 6, again with no issues. I then went to spin up my first VM, and I ran into issues. I let the VM install Windows 2008 R2 Enterprise for over 1 day and it still wasn't complete. At this point I was thinking is this a problem with XenServer 6 and my hardware or just my hardware? I then proceeded to troubleshoot over the next week, trying different settings, installing XenServer 5.6 SP2, etc.... I even manually set the DMA mode of my hard drives, which did help some as the Performance VM IO went from the 20's to the 40's, but performance was still unacceptable and still taking a day to install an OS. I then went through all my BIOS settings, and low and behold, I disabled AMD Cool and Quiet. Instant improvement was made. I should have known better, because I usually disable any power saving modes that the CPU might have like C States. Lesson learned again, disable any power saving modes that might be present on your hardware.

Tuesday, August 23, 2011

Initiator Error (02/01) and XenServer

I ran into an issue this past Sunday at a clients site. A newly built XenServer pool had been running just fine until the system had to be rebooted because of a physical move. When the XenServers came back online, they could not connect to their iSCSI targets. I tried disabling CHAP on the SAN, removing XenServers from the pool, you name it we tried it. Finally, I was able to get 1 server functional and moved all the VMs over to that server.

But, I still had a server that was not working and I did not know why. No matter what, I could not connect via iSCSI to the SAN. We had a CIFS share on the SAN and that server could connect just fine. After some digging, I finally found the issue. XenServer was set to use CHAP on discovery and for some reason my SAN did not like that and would refuse the connection giving me the error "Initiator error (02/01)". I checked this setting on the XenServer that was functional and sure enough, that XenServer was not set to use CHAP on discovery. So all I have to do now is disable CHAP during discovery, easy enough:

  1. SSH or use the console to log into the problematic XenServer
  2. Go to the local command shell of the problematic XenServer
  3. Navigate to the following director: /etc/iscsi/send_targets/[SAN IP, Port]
  4. Open the st_config file located underneath your target directory
  5. Add the following line: discovery.sendtargets.auth.authmethod = None
  6. Remove the following line: discovery.sendtargets.auth.username = [username]
  7. Remove the following line: discovery.sendtargets.auth.password = [password]
  8. Save the file
  9. Verify the problem has been resolved
  10. To make this change permanent, modify the following file with step # 5: /etc/iscsi/iscsid.conf
Let me know your comments, questions, or criticisms.

Monday, March 28, 2011

XenServer 5.6 FP1 and Windows 7 x64- Dualboot

I've been wanting a home lab for XenServer for quite some time. My major dilemma has been cheapness. I didn't want to spend $400 to build a cheap whitebox server. Also, I didn't need the lab on at all times. So this past Saturday afternoon, I decided to use a spare 500GB hard drive and setup dual booting on my existing Windows 7 x64 machine.

Hardware:
ASUS M4A785TD-M EVO
AMD Phenom II Black Edition
6GB RAM
Primary hard drive for Windows 7 x64
Secondary hard drive for XenServer 5.6 FP1

Software:
XenServer 5.6 FP1

Windows was already installed and happily loading just fine. So, I took the second hard drive and installed it in my machine. I then modified the hard drive order in BIOS to bring the new hard drive to the number 1 position. I went through a typical XenServer install and chose the new hard drive to store my VM's.

XenServer booted just fine. Well, almost just fine. The on board Realtek NIC was found by XenServer but for some reason the XenServer install kills the NIC. I had to unplug the power to the machine before my NIC would come back to life (I went through this scenario several times to verify these results and I'm still not sure why this is happening). The next hiccup, was that even though XenServer now can see the NIC and see that it is connected, there was no network traffic. I searched for a Linux driver for this NIC to no avail. I ended up ordering a DLINK NIC that is on the XenServer HCL from newegg.com for around $18. I should get the NIC sometime this week.

Now on to the fun stuff. I tried searching for someone who is dual booting between Windows 7 and XenServer and did not find much. I did some digging and found XenServer 5.6 FP1 uses extlinux as its bootloader. After doing some more research on chainloading (to pass control of the boot manager to a boot sector) I found the configuration that is able to boot Windows 7 from the XenServer extlinux bootloader. The configuration file is /boot/extlinux.conf, and you can see my modifications below:

default menu.c32
prompt 0
ontimeout windows
timeout 100

label windows
# Windows 7
kernel chain.c32
append hd1

The default menu.c32 loads a boot menu, so you can choose what OS to run. I set the timeout to 100 (10 seconds) and when that expires it uses the ontimeout section which then goes to the windows label. The label windows is what you will see in the boot menu. The kernel chain.c32 tells the boot loader that chainloading is going to be used. The line append h1 is where you specify the hard drive of where the Windows bootloader is.

It took some time to get it working. But, this is just one way to accomplish this fun weekend project. Others have used EasyBCD, which is a boot loader configuration tool for Windows instead of modifying extlinux, but where is the fun in that. Please leave your questions or comments below.

**Update**
Remember to backup your settings in extlinux.conf. When you upgrade XenServer, those settings will be overwritten.