Migration of ESXi Hosts with Running VM’s to New VCenter Server

Below procedure is a standard known procedure and can be scripted as well. The core sequence would be same but differs with the environment.

Assumption: –

  1. Create of Folders and permissions on the folders already Completed.
  2. DRS-Rules if existed are copied/noted.
  3. Storage-IO settings/DRS clusters if existed noted.
  4. EVC settings verified
  5. Exported Existing DV switch to new vCenter Server or created new DV-Switch.
  6. Ping Loss for VM’s is expected when moving from DV to Standard or from standard to DV-Switch.

Procedure:-

  1. Disable DRS and note the existing Data store Cluster’s for the ESXi Cluster in scope.
  2. Create the Cluster in Target VCenter server (Make sure EVC setting is verified).
  3. Run a script (or) Manually create standard switch and port groups that are currently in use within the Cluster.
  4. Verify both NIC’s are Active and remove VMNIC1 from the DV Switch.(Assuming we have Two VMnics per DV Switch)
  5. Add the removed vmnic1 to the standard switch created in Step 3
  6. Do the same for remaining Hosts within the cluster. (We can do all hosts at once or few hosts depending on criticality and resilience).
  7. Now go to DV Switchà Migrate Virtual Machine Networkà Select the Distributed Port VLANà Sort by Host and Migrate the Network for VM’s that are part of the Hosts which had each of the NICs in standard and DV. Click Finish to migrate the Network. This is the time to test the Ping Loss of the VM’s and verify everything is going as expected(Use Pinginfo to bulk Ping).
  8. Do the same for rest of the VLAN’s within the cluster.
  9. Run the below script to make sure all the VM’s are on Standard at this step.(Ex:-   Get-vmhost hostname1,hostname2 | get-vm  | Get-VirtualPortGroup)
  10. Once the above is verified, Go to DV switchà Virtual adapter and Migrateà Move the VMk0-MGMt and VMK1-VMotion to standard by created PortGroup Names “Mgmt” and “VMotion” with their VLAN ID’s.
  11. Now once both kernel ports are moved to standard and confirmed, Disconnect the ESXi host from the source vCenter server and add it back in the new target vCenter server.
  12. Now do the same for Remaining host’s from point 9 to 11.
  13. Once added in new target vCenter Server, add the new DV switch without checking any NICs.
  14. Go to DV Switch and add the physical NIC adapter vmnic0 in the DVuplink-1
  15. Do the same for rest of the Hosts
  16. Now got to DV Switchà Migrate Virtual Machine Networkà Select the Standard VLAN and migrate to Distributed Port Group VLAN for the VM’s in the two/all Hosts.
  17. Run the below script to make sure all the VM’s are on distributed at this step. (Ex:-   Get-vmhost hostname1,hostname2 | get-vm  | Get-VirtualPortGroup)
  18. Once the above is verified, Go to DV switchà Add virtual adapterà import existing and point the vmk0 and vmk1 to correct VLAN ID’s .
  19. After VMkernel verification, remove the vmnic1 in standard switch and add it back to DVswitch uplink2.
  20. Do the steps 17 and 18 on remaining host’s.
  21. Remove standard switch from the host’s.
  22. Enable HA/DRS.
  23. Now configure the Data store Cluster’s in new vCenter server as noted earlier
  24. Run the script to move VM’s to Folders if any.
  25. Once all Hosts successfully migrated, Patch the ESXi Hosts to the validated Build/Baselines  from Vum.

 

Script’s:- 

a) Export Current Dvport group info to Excel

Get-VdSwitch -Name dvswitch-test | Get-VDPortgroup | select @{N='PortGroupname';E={$_.name}}, @{N='VLAN';E={$_.ExtensionData.Config.DefaultPortConfig.Vlan.vlanid}} | export-csv "c:\temp\standardswitch-ports.csv

 
b) Create Standard Switch and Port group’s on the Hosts

$sswitch = Import-Csv "C:\temp\standardswitch-ports.csv"

$vmhost = get-cluster "Cluster-Name" | get-vmhost

Get-VMHost $vmhost | New-VirtualSwitch -Name vSwitch0 -Numports 120
ForEach($line in $sswitch) {

echo $line

Get-VMHost $vmhost | Get-VirtualSwitch -Name "vSwitch0" | New-VirtualPortGroup -Name $line.PortGroupName -VLanId $line.VLAN

}