For DR purposes I want to pre-register all my virtual machines with hosts in a DR site.
This way, when the storage fails across the vm's can just power on.
Does anyone have a method for registering machines without actually touching the storage.
Sadly my usual method vmware-cmd requires .
Thanks
Hmmm, difficult one, the only way I can think to do it is to create 'dummy' VMs from scratch on the DR host, and then edit the .vmx files with the correct paths for the storage so that when it fails over you don't need to make anhy changes to the VMs.
Cheers mate.
I think it's going to need some SDK action to get this one fixed.
It must be doable though.
When I fail my storage between sites, I register on hosts in a different datacenter and VirtualCenter remembers this.
When I flip the storage back and forth between sites, any previously known vm's can be powered on after answering the UUID question.
What I now need is a slick way to pre-register each VM on the DR hosts as they are created in the primary site.
I should point out, the main reason I'm doing this is to organise the structure. I've already written a DR script which basically registers everything and powers up, but all VM's land in the 'discovered' pot.
How do other people handle this?
we are currently testing this and its all manual steps, would you mind sharing your script that registers and powers up the vms?
Sure, I'll stick it in an email.
The 2 basic commands for starting a vm & answering the UUI question are:
for a in `vmware-cmd -l`; do vmware-cmd $a start; done
for a in `vmware-cmd -l`; do echo "1" | vmware-cmd $a answer; done
When you power up a VM which has moved location it will ask if you what you wish to do with the unique identifier. You have 5 choices:
0) Create
1) Keep
2) Always Create
3) Always Keep
4) Cancel
My script selects option 1 to keep the UUID.
Message was edited by:
MR-T
How about scping the .vmx files over and registering them from those? The .vmx files don't have to be in the same place - just point to the same disks.
i.e. in sudo-code
vmlist=vmware-cmd -l
for vmx in vmlist
do
scp vmx to remote host
done
then on remote the remote host register the .vmx file. You won't be able to power them on until your storage fails over to the DR side but that's what you want.
Without some 'real' .vmx files I'm pretty sure the VMs will appear as 'orphaned' on the host even if you do get them to register.
Good call, I'm starting to like this.
I guess the only manual process from here is that I'd need to drag the objects around inside VC to get them into the correct containers.
Thanks Alex.
#!/bin/bash
\# Enable Disk Resignature of the LUNS
esxcfg-advcfg -s 1 /LVM/EnableResignature
service mgmt-vmware restart
\# Scan for new Luns
esxcfg-rescan vmhba0
esxcfg-rescan vmhba1
esxcfg-rescan vmhba2
\# Balance HBA
PREVIOUS="vmhba1"
echo "Starting HBA Balance....."
Execute new config
for LUN in $(esxcfg-vmhbadevs | tail +2 | awk '\{print $1}')
do
CURRENT=$(esxcfg-mpath -q --lun=$\{LUN} | grep FC | grep "preferred" | awk '\{print $4}' | awk -F ":" '\{print $1}')
if [\[ $\{CURRENT} = $\{PREVIOUS} ]]
then
NEW=$(esxcfg-mpath -q --lun=$\{LUN} | grep FC | grep -v "preferred" | awk '\{print $4}' | awk -F ":" '\{print $1}')
NEWPATH=$(esxcfg-mpath -q --lun=$\{LUN} | grep FC | grep -v "preferred" | awk '\{print $4}')
esxcfg-mpath --lun=$\{LUN} --path=$\{NEWPATH} --preferred
PREVIOUS=$\{NEW}
else
PREVIOUS=$\{CURRENT}
fi
done
echo
echo "****** NEW HBA CONFIG *****"
echo
for LUN in $(esxcfg-vmhbadevs | tail +2 | awk '\{print $1}')
do
esxcfg-mpath -q --lun=$\{LUN} | grep FC
echo
done
echo
echo "****** \"active\" flag will be moved after disk activity *****"
echo
echo "Finished HBA Balance....."
find /vmfs/volumes -name *.vmx | while read vm
do
echo $vm
esxcfg-advcfg -s 0 /LVM/EnableResignature
service mgmt-vmware restart
vmware-cmd -s register "$vm"
vmware-cmd "$vm" start
done
Maybe if you used vimsh to register the VM you could specify the target folder directly, although I'm not sure exactly how to do it at the moment.
I also notice using vimsh there's a 'createdummyvm' command in the vmsvc section - not sure what this does but might be worth investigating.
Check out pages 9 & 10 of this whitepaper.
http://www.xtravirt.com/index.php?option=com_remository&Itemid=75&func=startdown&id=4
For the UUID question what are people saying; Create or Keep, what are the affects / differences?
General rule is if you copy a VM - use "create", if you move a VM use "keep". It is the unique identifier of the VM so if you copy a VM and use the same UUID you could likely cause a conflict.