Sunday, 13 January 2013

Updating / Modifying DVS Switch Configuration from vCenter DB

Yesterday, one of my ESXi hosts crashed (showing purple screen and not booting) and I was forced to rebuild it. This host was already added and used in DVS switch. After rebuilding it and adding it back to vCenter, I wasn't able to add the ESXi host back to DVS. The following was noticed:

1. From vSphere Client, navigate to Inventory > Hosts and Clusters > #Select ESXi host# > Configuration Tab > Networking > VSphere Distributed Switch. You won't see any DVS switch present. 
2. From vSphere Client, navigate to Inventory > Networking > #Select DVS Switch# > Hosts Tab. You will see the ESXi host is already attached to DVS switch.

I tried to remove the host from DVS but wasn't going through and throwing exception error.

This is due to the fact that vCenter DB is still having this host attached to DVS with uplinks attached to dvUplingPG. Therefore, the fix for this is to clear the tables in vCenter DB and re-add ESXi host to DVS switch.

1. Stop VMware VirtualCenter Service in vCenter Server
2. Connect to vCenter DB (I am using MSSQL DB)
3. Identify the IDs of the DVS Switch and ESXi Host in the DB using the following SQL queries.

select * from VPX_ENTITY where name='DVS_NAME';
select * from VPX_ENTITY where name='HOST_IP';
4. Run the following queries to clear related DB tables.

delete from vcenter.dbo.VPX_DVHOST  where DVS_ID=#DVS_ID# and HOST_ID=#HOST_ID#
delete from vcenter.dbo.VPX_DVPORT_MEMBERSHIP where HOST_ID=#HOST_ID# and DVS_ID=#DVS_ID#

5. Start VMware VirtualCenter Service.
6. Go back to ESXi Host > Configuration > Networking. Proxy error will popup. 

To understand this error, the HostProxySwitch is a software entity which represents the component of a DistributedVirtualSwitch on a particular host. What is happening is that after removing DVS and its components from vCenter DB, HostProxySwitch component for this particular host isn't able to find records in vCenter DB. You need to uninstall this component to completely remove DVS.

You need to select Remove hyperlink to uninstall it.
7. Re-Add ESXi Host back to DVS Switch

1 comment: