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:
select ID from VPX_ENTITY where name ='10.66.4.211';
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:
delete from vpx_ds_assignment where entity_id in (select id from vpx_vm where host_id = 2445);
b. Remove all the network assignments virtual machines that exist on this ESXi host with the statement:
delete from vpx_nw_assignment where entity_id in (select id from vpx_vm where host_id = 2445);
c. List the virtual machines in the virtual machine table which exist on this ESX\ESXi host with the statement:
select id from vpx_vm where host_id = 2445;
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:
delete from vpx_vm where host_id = 2445;
e. Delete virtual machines which exist on this ESXi host from the entity table with the statement:
delete from vpx_entity where id in (26149,26215,26217,26219,95343);
f. Delete the DVS entries associated with the ESX\ESXi host with the statement:
delete from vpx_dvhost where host_id = 2445; delete from vpx_dvport_membership where host_id = 2445; delete from vpx_dvs_blob where host_id = 2445;
g. Delete the ESXi host from the host table with the statement:
delete from vpx_host where id = 2445;
h. Remove all relations to this ESX host from the entity table with the statement (Actually in my case only this step was necessary):
delete from vpx_entity where parent_id = 2445; delete from vpx_entity where id = 2445;
4. Start the VMware vCenter Server service on the vCenter Server to pick up the database changes.
Latest posts by Dusan Tekeljak (see all)
- VM Latency Sensitivity set to High still fails with no (proper) warning - June 27, 2024
- ESXi 6.7 U1 fixes: APD and VMCP is not triggered even when no paths can service I/Os - November 30, 2018
- Update manager error: hosts could not enter maintenance mode - November 19, 2018
Pingback: TheVirtualist.org runs for Top vBlog 2015 - The Virtualist
Just missing to remove the local datastore from the entity if required.
thanks, makes sense also I’m not sure how it is with vSphere 6 and possible VSAN records