Migrating an ESXi Host with a Distributed Switch to different vCenter
This was written to explain complexities and provide guidance on migrating ESXi hosts to a new install of vCenter 6.7. VMware has an official response for versions 4.0 through 6.5, https://kb.vmware.com/s/article/1029498. However, I would like to break this down and show how it applies to 6.7 and how we can improve this process to reduce time to implement.
In order to accomplish this step, for the migration to 6.7, the Distributed Switch version on the source must be at 6.0.0 when it is exported. Any older version of the Distributed Switch must be upgraded. If any of the ESXi Hosts must be left on 5.5, then those ESXi Hosts must be disconnected from the Distributed Switch so it may be upgraded to 6.0.0. The following steps explain how this can be accomplished.
These steps require more effort than is lead on by these instructions. Besides migrating VMkernel ports for Management and vMotion, each Virtual Machine must also have its networking moved to a similarly created standard switch portgroup. There are some rather glaring caveats with this. Depending on the size and of the environment, limiting the number of portgroups and ports created to only the required per each individual host is a must, as to not exceed configuration maximums.
If the source is equal to the destination this is a non-issue and should be pre-configured as such. In our case we are not changing the cluster layout so the clusters are created prior to migration of the host.
The instructions have you do this after connecting the ESXi Host on the destination vCenter. I strongly recommend this be done as step 2 to avoid any misconfigurations or complications at this point.
Effectively in this step, each individual Virtual Machine network adapter is migrated back to the appropriate distributed switch portgroup.
By removing the steps to migrate to a standard switch, we can reduce the level of effort required even further by taking advantage of 6.7's enhanced distributed switch management features and the always present “In-Memory VM Configuration”. I’ll explain this further.
In this demonstration we have already exported and imported the distributed switch from a 6.0 environment to a fresh 6.7 installation. However if you are coming from a
1. Export the Distributed Switch
2. Import Distributed Switch
3. Document Virtual Machine Networking
4. Disconnect ESXi Host from Source vCenter
a. DO NOT REMOVE
b. The data persists on the source vCenter and can be queried for information should any step fail and can be restored should issues arise.
c. All running VM data and networking is persistent in memory and has no impact.
5. Connect ESXi Host on Destination vCenter
a. Attach to appropriate cluster compute resource
6. Add ESXi Host to Distributed Switch
a. Configure the Uplinks
b. Migrate VMKernel Ports
c. Migrate VM Network Adapters
i. This step in the web client can be skipped if, it will be accomplished via other means (I.E. PowerCLI), as the VM configuration persists in memory no impact is noticed.
ii. This is the most mistake prone step. Any incorrect configuration here may result in Virtual Machine outage. As there may be a large number of VM network adapters to configure I recommend skipping this and using PowerCLI for less risk.
PowerCLI Methodology
#Collect VM Networking Data in a variable (STEP 3)
$VMadapters = Get-VMHost <hostname> | Get-VM | Get-NetworkAdapter | select parent,name,networkname
#Export, just in case
$VMadapters | Export-Csv <Hostname.csv> -NoTypeInformation –UseCulture
#Disconnect Source ESXi Host from Source vCenter
Get-VMHost | Set-VMHost -State Disconnected –Confirm:$false
Disconnect-VIServer * -Confirm:$false
#In the Web Client connect the ESXi Host to the DVS (STEP 6, a. & b.) Skip VM Adapter configuration
#Connect to Destination vCenter
Connect-VIServer <Destination vCenter>
#Configure VM Adapters
$VMadapters | %{Get-VM $_.parent | Get-NetworkAdapter -Name $_.name | Set-NetworkAdapter -NetworkName $_.networkname -Confirm:$false}
After these configurations are complete the ESXi Host must be updated. During the migrations for maintenance mode there may be an issue with vMotion failing on a VM. This is a known issue and must be handled on a case by case basis.
To Resolve:
1. Power Down the VM
2. Remove the VM from Inventory
3. Register VM
4. Power On