Script for VMware HA Feature without VirtualCenter

Thursday, October 22, 2009 by BBTUNA

So, who wants free VMware High Availability? That’s the title of a post created by Leo Raikhman on his Leo’s Ramblings blog. In this post, Leo has published the steps and scripting necessary to simulate VMware’s VI3 High Availability (HA) feature. Leo’s script works without VirtualCenter (VC), so VMware customer’s who have not implemented VC can manually create “HA -like” awareness between 2 ESX hosts. If one of the ESX servers goes offline then the virtual machines (VMs) are auto restarted on the other host. Of course, the VMs must be created on shared storage for this to work.

Before considering this script as a replacement understand the major differences between VirtualCenter HA and Leo’s HA:

  • Leo’s script only works between 2 ESX hosts while VC HA can be configured with up to 32 ESX hosts as of VI 3.5 (actually using 32 host HA clusters is another topic, but it can be done)
  • Leo’s script needs the ESX Service Console as written. It would need to be ported for the RCLI to work with ESXi. VC HA works with both ESX and ESXi
  • VC provides a visual status for the health of your HA cluster via the VI Client
  • VC HA provides HA fail over capacity for more than 1 ESX host at a time

I’ve held this post in my drafts because I wanted to try this configuration myself, but alas, I have never gotten around to it. For those that can benefit from VC -less HA and give this script a test, let me (and Leo) know your results.

Leo’s post says:


“First of all lets talk about the basics of what HA actually does: if your ESX server doesn’t respond to a heartbeat for 14 seconds, the other host registers all machines and starts them up. “

Here’s the process from Leo’s Ramblings with the scripts, commands and instructions:

Create a list of the VMs on each host and copy to the other host

But there’s a few other tricks. How do you generate that other_host file? Here’s how. On each host run the following command:

vmware-cmd -l | sed ’s/\ /\\ /g’ > /root/other_host

What you’ve done is just dumped all registered machines on each host to the /root directory.

Now, scp each /root/other_host file to the other ESX server’s /etc directory.

In each /etc/other_host file, re-organize the VM order if you want them to start up differently and delete VMs that you don’t want to start up.

Create the HA script and make it executable

#!/bin/bash
if ! ping -c 14 10.8.0.1 > /dev/null; then
for $i in `cat /etc/other_host` ; do vmware-cmd -s register $i && vmware-cmd $i start ; done
fi
sleep 16
if ! ping -c 14 10.8.0.1 > /dev/null; then
for $i in `cat /etc/other_host` ; do vmware-cmd -s register $i && vmware-cmd $i start ; done
fi

Then I made it executable:

chmod a+x /usr/bin/esx_ha.sh

Here’s what the script does:

If for 14 pings, an ESX server with Service Console IP 10.8.0.1 does not reply, then, browse the contents of the file /etc/other_host, register every listed machine there on the current host (10.8.0.2) an start them up, one by one. Then it sleeps for 16 seconds, and executes the same thing again.

Seems easy enough.

Create a cron entry to start auto HA

Now we need to create a cron entry as root by running crontab -e as the root user. The screen that opens works like vi, input the following text:

MAILTO=”youremail@yourcomapny.com
* * * * * /usr/bin/esx_ha.sh

This means, that on the minute, every minute of the day, the script (which runs twice a minute) will execute and provide HA for you.

Posted in | 0 Comments »

Get a MAC address remotely

by BBTUNA
Ever been in a situation where you need to get a MAC address but don't really feel like logging into the server, wait for it to present your profile, and then open up a command prompt and finally type "ipconfig /all". Here is a trick I learned on how to do this remotely without all that of course the server and you must be online otherwise the long way it is.

1. Open up a command prompt and type
- getmac /s [servername or IP] /u [domain\username]
2. You will be prompted to enter the password for [domain\username]
3. Once you do that you will be presented with the MAC address/es.
Posted in | 0 Comments »

Regenerate SSL Certificate for ESX 3.5

Tuesday, October 20, 2009 by BBTUNA
Ever had to rename a ESX 3.5 host? You've done all the proper procedures of renaming network, hosts files, and changing your rc.conf file but now your storage doesn't recognize your new host. You've checked everything and then we you go to sign in you find out that your ssl certificate still has the old name and won't connect with the SAN array. I've recently run into that problem and here is how I fixed it.

1. Backup your ssl file to be safe.
- cp -r /etc/vmware/ssl /etc/vmware/ssl.bckp
2. After checking that the backup was indeed created, delete the rui.* files
- cd /etc/vmware/ssl
- rm rui.crt
- rm rui.key
3. Now restart hostd and ESX will regenerate the SSL cert and key using your new name.
- service mgmt-vmware restart
4. Easiest way to test if it worked is to use IE and go to https://"yourhost" and view the certificate. You should now see the new name in your issued to and issued by section of the cert.

Thats it. Any comments or question please post. Thanks.
Posted in | 0 Comments »

Failed to install the VirtualCenter Agent Service

by BBTUNA

A number of customers have been reporting the message: “Failed to install the VirtualCenter Agent Service“, when trying to connect an ESX host to virtual center, often after upgrading to ESX 3.0.2 and VC 2.0.2. In all the cases I have come across these reason seems to be that /tmp/vmware-root does not exist. This directory has to exist for the agent install process. To remedy this you can-

  1. Login to ESX Server via ssh client as root user
  2. cd /tmp
  3. mkdir vmware-root
  4. Try re-connecting the host to Virtual Center

Apparently there is a cron job that is removing this directory whenever it runs.Here is another method:

  1. Disable HA. Otherwise, the virtual machines might be forcibly powered down by step 2.
  2. At the service console, issue
    service mgmt-vmware restart
  3. At the service console, issue
    service vmware-vpxa restart
  4. Reconnect the virtual machines to VirtualCenter.
  5. Attempt to re-enable HA within VirtualCenter. If this doesn’t work, this means that vpxa did not install properly.
  6. At the service console, issue
    rpm -qa | grep vpxa
  7. At the service console, issue “rpm -e” on the rpm file that displayed in the previous command.
    rpm -e
  8. Reconnect the virtual machines in the usual manner within VirtualCenter.
  9. Re-enable HA.
Posted in | 0 Comments »

Vmotion is Disabled after upgrade

by BBTUNA

Here is a quick fix for those experiencing a problem using VMotion after upgrading from ESX Server 2.5 to ESX Server 3.5

In some cases after this upgrade is done VMotion is disabled and warm migrations are not possible. The solution is to re-enable VMotion on the host.

Re-enable VMotion on the host:

  1. Select the host in VI Client and navigate to the Networking section of its Configuration tab.
  2. Click the Properties link for the switch associated with the VMkernel port.
  3. In the switch Properties dialog box, select the appropriate network label and click Edit.
  4. Select the VMotion Enabled checkbox and click OK.
Posted in | 0 Comments »

How to root an Android G1 phone

Wednesday, October 14, 2009 by BBTUNA

First off, I take no credit for this guide, this is straight from the xda-developers forums, which is an excellent place to learn about HTC phone hacking. So let’s get started. Make sure you backup anything important on your phone as this will erase everything. There are several apps in the Market that will backup apps, SMS, and other data for you. So don’t complain if you’ve lost your data. Your contacts and email should still synch with Google once you reinstall the new OS.

If you have US-RC30/UK-RC8 or higher, you will first need to downgrade your phone to a previous version. (Skip these steps otherwise)

  1. Format your phone’s SD card to FAT32 mode:
    • Hook your phone up to your computer using a USB cable and then wait for the notification to show up in your title bar of your phone.
    • Click the notification, and then click “Mount”.
    • A new removable disk should show up on your computer. Right click it and select Format, and select FAT32 as the file system type.
  2. Download and unzip the RC29 or RC7 image file. Copy the DREAMIMG.nbh file to the SD card. (RC29 for US, RC7 is for UK)
  3. Turn the device power off.
  4. Hold Camera button, and press Power button to entry bootloader mode. You should see a gray/white screen with instructions to flash your phone with the update on your SD card. If you don’t see that, make sure you followed the instructions properly.
  5. As per the on-screen instructions, press the Power button to start upgrade procedure.DO NOT DO ANYTHING TO INTERRUPT THIS PROCESS.
  6. After it is finished, perform the restart your phone.

Once you are running RC29 firmware:

  1. Download recovery.img and copy it to your SD card (see the previous instructions on how to copy from your computer to your Phone’s SD card).
  2. Download the Hard SPL and copy the zip file to the SD card.
  3. All files must be on the root of your SD card.
  4. Restart your phone. Wait for your phone to start up fully and show the home screen.
  5. After your phone starts up, hit the enter key twice, type “telnetd” and press enter. (Yes, it will start up a contact search, don’t worry. Just type it.)
  6. Download an Android “Telnet” application from the Market and connect to localhost.
  7. If you connect successfully, you will have a root prompt “#”.
  8. Type the following into Telnet (these commands will give you root access easier in the future):
    • mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
    • cd sdcard
    • flash_image recovery recovery.img
    • cat recovery.img > /system/recovery.img

Now you have root!
Now that you have root, you will want to apply “Hard SPL” to your phone. HardSPL is what will allow you to apply flash images from other regions (like UK on US phones, and vice versa), create full backups of your phone, install the latest build from the Android source, and usually resurrect your phone if it is “bricked”. You have already downloaded the file to your SD card, so now you can apply it.

  1. Power off your phone.
  2. Start up in recovery mode by holding home and pressing power.
  3. You will now enter recovery mode. You should see an exclamation.
  4. If you do not see a menu on screen, press Alt-L to show the menu.
  5. Press Alt-S to apply the update from the SD card.
  6. After the update is complete, hold Home and press Back to restart.

And now, the last step! You are still running an old version of Android, but you want to upgrade to the latest and greatest update! You can do this, and not lose root by downloading modified versions of the updates.

Download one of the latest ROMs to install, I recommend JF1.5:

JesusFreke 1,51

Haykuro Builds

The Dude’s Cupcake 1.2 Full
The Dude’s Cupcake 1.1a Lite (No 3rdparty/dev apps/Manup Blue Theme)

You will also want to apply the latest radio update from HTC. Install the same way as the system image:

HTC Downloads Page

To install the latest build (instructions from Haykuro):

1. Gain root (follow the various threads available on the forums to accomplish this).
2. Download the latest build above.
3. Copy to your sdcard as update.zip
4. Power off your phone.
5. Hold the Home button, and power on the device. (This should send you into recovery mode).
6. Press ALT+B to create a nandroid backup (if you wish to fall back without losing any data later, if you do go back to RC33 [or any other firmware 1.0 update] you will need to reflash your radio, users have reported problems using the new radio on the old firmwares.)
7. Press ALT+W, then ALT+S.
8. wait for it to finish, then home+back.

There you have it. I hope I gave proper credit and backlinks to the awesome people that make this possible. Now you can brag about your new Cupcake and also do all the cool stuff with root, like install full Linux distros, tether your phone, and install apps on the SD card.

Posted in | 0 Comments »

How to get guest VMs MAC addresses

by BBTUNA

I noticed an IP conflict today on a windows box hosted on the ESXi. In the events viewer under system I checked the MAC address of the system trying to hijack my IP address. I wanted to find a quick way and check if this mac address is in my existing ESXi Virtual Machines or it’s outside somewhere..
I wanted to find a quick and dirty way to check this since there is number of machines on the ESXi host.
Here is what I did…

I opened VMWare VI-TOOLKIT. After I connected I decided to try some commands that I regularly use such as get-vm and get-vmguest. After I found nothing interesting I checked out the CI Toolkit Cmdlets Reference Document.

And there it was… the perfect command for what I wanted..

Get-NetworkAdapter … Wooohoo!

[VI Toolkit] C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> Get-NetworkAdapter -vm (get-vm *)|select MacAddress

MacAddress
———-
07:0c:29:11:61:6a
07:0c:29:6a:4a:db
07:0c:29:a4:ae:6f
07:0c:29:0c:c7:4c
07:0c:29:d5:8c:4f
07:0c:29:27:4d:84
07:0c:29:7c:e9:23
07:0c:29:52:52:aa
07:0c:29:eb:e3:e6
07:0c:29:17:66:50
07:0c:29:21:09:70
07:0c:29:81:89:3d
07:0c:29:0e:d6:ce
07:50:56:3f:51:02
07:0c:29:ad:60:61
07:0c:29:40:84:06
07:0c:29:40:84:10
07:0c:29:ce:89:9c
07:50:56:3f:51:01
00:1b:29:a0:ff:fe
00:1b:29:e2:ea:d5
00:1b:29:e2:ea:df
00:1b:29:e2:ea:e9
00:1b:29:07:f1:f9
00:1b:29:07:f1:03
00:1b:29:e8:8b:dd
00:1b:29:e8:8b:e7
00:1b:29:e8:8b:f1
00:50:56:3f:51:03
00:1b:29:ba:4c:b9
00:1b:29:84:2b:62
00:1b:29:2c:9d:6c
00:1b:29:7d:98:0e
00:1b:29:6a:1a:a5
00:1b:29:5a:82:cf
00:1b:29:26:23:bf
00:1b:29:df:87:1c

The MAC I was looking for was not here but this is a proof that none of the machines in my control is attempting the hijacking.

Posted in | 0 Comments »

About Me

Blog Archive