It seems it becomes sort of tradition for me to apologize delay updates every time I start a new post. The truth is it does happen in recent posts. –_-b
I am currently focus on VCAP-DCA exam and so does that help me to excuse myself little bit? :p
Anyway, welcome to read my post and I will continue to update with my best effort. Today, we are going to talk about migrate ESX3.5 to vSphere with Powercli.
Let me introduce environment first.
The old environment:
We have 7 ESX 3.5 hosts with 100 VMs running on it. It is using SAN base as datastore. 1 physical server is running vCenter 2.5 on it.
All ESXs will upgrade to ESXi 4.1U1. vCenter will upgrade to latest version as well. It uses same SAN datastore so that’s a plus in this migration.
Following is a diagram which give you some brief idea about how I do my migration. It’s little bit big picture, pls be patient when it loads.
Using Powercli to help you
First of all, Powercli is powerful tool. But I have to mention that sometimes, it’s just much easier to use GUI interface which utilize internal cmelet and scripts to do jobs. However, there are some steps Powercli can fully utilize resource and make job quicker and efficient.
I’m going to describe the “Second week” work from above diagram with powercli power.
Of course, you need to download powercli and install first. You can find out the powercli from vmware website. or here
if you want, you can download Vmware Update Manager Powercli snap-in as well from here.
After you install powercli, you need to run it.
You may encounter this error when you run it. Regardless 32bit or 64bit version.
All what you need to do is run command as following:
then, close the powercli and rerun it again.
To do those jobs, you will find following scripts coming very handy.
Those are very good scripts although they are not watch-free scripts. It means it does require some modification or you have manually interfere when it stuck at some place time by time.
What we need to do
Following steps are what we try to do in this week.
1. 20 VMs need to migrate to new vCenter.
Well, there are 20 test vms currently running on the old hosts. Since they are sharing the same datastore(both new environment and old environment), we can just shutdown and register them on new vCenter.
1.1 connect to vCenter
Note: You do can connect to host but we are working on vCenter since VMs are crossing multiple hosts.
1.2 created a new folder so I can operate VMs at same time.
You need to make sure that folder is “blue” folder not yellow folder
In this example, I found there a blue templates folder. so I will create migration folder beneath it.
New-Folder -Name migration -Location templates
1.3 Move all test VMs to this folder
Move-VM -VM yourvmname -Destination migration
You need replace yourvmname with each VM you want to move. If VM has long name, you can use yourvmname* to get rid of rest name part.
Use following command to check all vms in the “migration” folder or not
get-vm -Location migration
1.4 Create old_vmtools folder in the new vCenter
You do same thing as above and create a new folder in the vCenter called “old_vmtools” to accept those VMs.
1.5 stop all test vms
You need stop VMs from old vcenter so you can import them into new vCenter
You will love these with powercli
get-vm -Location migration|Shutdown-VMGuest
You can use stop-vm but that will turn VM off immediately.
1.6 Import vmx into new vCenter
You can do this step with script, but it’s too much trouble. It’s easier to just manually do it on new vCenter via GUI interface. When you import them, pls make sure you import them to “old_vmtools” folder.
1.7 Install VMtools
You must install VMTOOLS before you upgrade vm hardware level.
get-vm –location old_vmtools|start-vm
Here is intersection. You either use script upgrade-vhardware_vm which will install vmtools and upgrade vm hardware or you can manually install Vmtools first. Then, you use script to upgrade Vm hardware.
For safe reason, I did the second idea.
You can just click folder name on vCenter, and choose “Virtual Machine” tab on the right side window. Use “Shift” key to select all vms, and right click to choose
It will upgrade all VMs vmtools automatically. Wait for 30 mins and come back.
You may notice some of VMs failed on upgrade.
You need to open those VM console and go to VM->install Vmtools on the manual. It will automatically load Vmtools installation iso on the vm cd-rom.
go to cmd and go do cd-rom and run
This will manually remove old-vmtools. Then, you will install it again.
1.8 upgrade vm hardware
After make sure all VMs got new vmtools, then you can safely use script to upgrade vm hardware.
All what you need to do is to download script. Change extension name from docx to ps1. Copy this script to the server where powercli runs.
In the powercli, you just need to type name of script and run.
This script asks you which vCenter and folder where VMs sit. Answer those questions, the script will stop VMs one by one, check vmhardware version. Upgrade version if it is old. And restart vm.
Note: sometimes, shutdown vm takes too long before script try to convert vm hardware version. so it will stuck. You need manually upgrade hardware version and manually start vm.
1.9 remove old vms from old vCenter
at old vCenter
get-vm –location migration | remove-vm
2.0 move vms to test folder
at new vCenter
get-vm –location old_vmtools|move-vm –destination test_folder
Here it is. It’s pretty easy and simple to do the job with powercli.
Please leave comments as usual. Thanks for reading.