Sunday, 1 May 2016

Migrate ESXi Host and VMs from vCenter 5.x to new vCenter 6.x

In this post we will see how to Migrate all VMs and ESXi Host from vCenter 5.x to vCenter 6.x.
You can use same steps to migrate VMs and ESXi host from any other old vCenter server to new vCenter.
Assuming that your existing vCenter, ESXi Host and all VMs are working fine.
To get started with the VM migration, first Deploy new vCenter on new Windows Server VM or Deploy VMware Virtual Appliance. Once your new vCenter become ready to use proceed further.
Step by Step ESXi migration -
  • Perform below Task in old vCenter
  1. Disable HA in ESXi Clusters.
  2. if you are using Standard Switch for ESXi, you don’t need any additional Step, proceed to task #4
  3. if you are using dvSwitch, then first you need to migrate VMs, Vmkernel PortGroup and ESXi host from dvSwitch to Standard switch. Once you have all VMs on standard switch, proceed to next step.
  4. Disconnect ESXi Host from vCenter.
  • Perform below Task in new vCenter
  1. Create ESXi Cluster, enable HA and DRS.
  2. Connect disconnected ESXi host to new vCenter
This was the manual way of migrating ESXi and VMs to new vCenter. If you have too many ESXi Host then PowerCLI is there to help you.

vCenter ESXI Host and VM Migration using PowerCLI Script
Change the values marked in Red.
Disconnect-VIServer * -Confirm:$false
#Change to multi-mode vCenter management
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false
$src_vCenter = "" $dst_vCenter = ""
Write-Host 'Please enter user name password to connect both vCenter'
$creds = Get-Credential
$esxi_pass = “esxi-password'
$cluster = "vLAB_Cluster"
$dst_datacenter = "vLAB_DC"
#Connect vCenter servers
Write-Host "connecting vCenters......."
sleep 5
connect-viserver -server $src_vCenter -credential $creds
connect-viserver -server $dst_vCenter -credential $creds -NotDefault:$false
Write-Host "disable HA on cluster"
#Disable HA on source vCenter Cluster
Get-Cluster $cluster -Server $src_vCenter  | Set-Cluster -HAEnabled:$false -Confirm:$false
Write-Host "Removing Hosts from source vCenter"
#Remove ESX hosts from old vcenter
$Myvmhosts = Get-Cluster $cluster -Server $src_vCenter | Get-VMHost
foreach ($vmhost in $Myvmhosts) {
Get-vmhost -Server $src_vCenter -Name $vmhost.Name | Set-VMHost -State "Disconnected" -Confirm:$false
Get-VMHost -server $src_vCenter -Name $vmhost.Name | Remove-VMHost -Confirm:$false
Write-Host "create Cluster on new vCenter"
#Create Cluster in New vCenter
New-Cluster -Name $cluster -Location ( Get-Datacenter $dst_datacenter) -Server $dst_vcenter -Confirm:$false
Write-Host "Add Hosts in new vCenter"
#add ESX hosts into new vcenter
foreach ($vmhost in $Myvmhosts) {
    Add-VMHost -Name $  -Location (Get-Cluster $cluster -server $dst_vCenter) -user root -Password $esxi_pass -Force
sleep 5
Write-Host "enabling HA and DRS on new Cluster"
#Turn on HA and DRS on
Set-Cluster -Server $dst_vCenter -Cluster $cluster -DrsEnabled:$true -HAEnabled:$true -Confirm:$false
Write-Host "disconnecting all vCenters"
Disconnect-VIServer * -Confirm:$false

Once you complete migraiton of all Host to new vCenter, you can upgrade all Host to ESXi 6.x using VMware Update Manager.
This is the way to Move Vms and ESXi host to new vCenter. However if your VMware infrastructure inventory  is huge, then you would like to retain the VMs folder Structure, Resource Pool Structure and Users vCenter permissions….etc in new vCenter.
See my detailed post about vCenter migration with VM folder, resource pool, user permissions – vCenter Migration VM Folder, Resource Pool. User permissions


No comments:

Post a Comment