Manually remove ESXi host from vCenter database

Some time ago, after I tried to remove ESXi host from vCenter it was still appearing in vSphere client with alert and I couldn’t remove it again. Someone would say it is just cosmetic issue, but for example storage service was failing from initializing because of it too. VMware support provided me with manual how to do manual cleanup directly in database, as it wasn’t publicly available at the time of my issue. I would like to share sequence with you (I performed this procedure in vCenter 5.5, however according to VMware it should work from 2.5):

Warning: Sequence is provided as is and without any guarantee and should be used only as last resort if all attempts to remove host failed, although I’ve got the sequence from VMware support it is not official, and you can seriously damage your database. I strongly recommend you to contact VMware support in case of similar issues. Make sure you have latest backup of you vCenter database.

1. Stop the VMware VirtualCenter service on the vCenter Server. 2. Identify the ESX host ID in the vCenter database with the command:

Note: ESXi host being removed is 10.66.4.211 was previously added under IP not DNS name. This name  returned a host ID of 2445 when the select statement above was executed.

3. Execute these SQL statements to remove the ESX\ESXi host from the vCenter database.

Note: There are constraint definitions defined in the database therefore following SQL statements must be executed in the order.

a. Remove all the datastore assignments for virtual machines which exist on this ESXi host with the statement:

b. Remove all the network assignments virtual machines that exist on this ESXi host with the statement:

c. List the virtual machines in the virtual machine table which exist on this ESX\ESXi host with the statement:

Make a note of any virtual machine IDs returned. In this example, the values returned are 26149, 26215, 26217, 26219, 95343.

d. Delete virtual machines which exist on this ESXi from the virtual machine table with the statement:

e. Delete virtual machines which exist on this ESXi host from the entity table with the statement:

f. Delete the DVS entries associated with the ESX\ESXi host with the statement:

g. Delete the ESXi host from the host table with the statement:

h. Remove all relations to this ESX host from the entity table with the statement (Actually in my case only this step was necessary):

4. Start the VMware vCenter Server service on the vCenter Server to pick up the database changes.

The following two tabs change content below.
Dusan has over 6 years experience in Virtualization field. Currently working as Senior VMware plarform Architect at one of the biggest retail bank in Slovakia. He has background in closely related technologies including server operating systems, networking and storage. Used to be a member of VMware Center of Excellence at IBM, co-author of several Redpapers. His main scope of work consists from designing and performance optimization of business critical virtualized solutions on vSphere, including, but not limited to Oracle WebLogic, MSSQL and others. He holds several IT industry leading certifications like VCAP-DCD, VCAP-DCA, MCITP and the others. Honored with #vExpert2015 and 2016 awards by VMware for his contribution to the community. Opinions are my own!

About Dusan Tekeljak

Dusan has over 6 years experience in Virtualization field. Currently working as Senior VMware plarform Architect at one of the biggest retail bank in Slovakia. He has background in closely related technologies including server operating systems, networking and storage. Used to be a member of VMware Center of Excellence at IBM, co-author of several Redpapers. His main scope of work consists from designing and performance optimization of business critical virtualized solutions on vSphere, including, but not limited to Oracle WebLogic, MSSQL and others. He holds several IT industry leading certifications like VCAP-DCD, VCAP-DCA, MCITP and the others. Honored with #vExpert2015 and 2016 awards by VMware for his contribution to the community. Opinions are my own!
Bookmark the permalink.

3 Comments

  1. Pingback: TheVirtualist.org runs for Top vBlog 2015 - The Virtualist

  2. Just missing to remove the local datastore from the entity if required.

Leave a Reply