After removing an ESXi host from VCDB, the vpxd service fails to start or crashes.
search cancel

After removing an ESXi host from VCDB, the vpxd service fails to start or crashes.

book

Article ID: 387412

calendar_today

Updated On:

Products

VMware vCenter Server VMware vCenter Server 7.0 VMware vCenter Server 8.0

Issue/Introduction

Removing the ESXi host from the vCenter GUI, the task is executed but the ESXi host is not removed from the inventory. No errors are observed.

As an alternative approach, while attempting to remove the ESXi host from the VCDB, multiple entries of the host are identified. After removing all associated entries, the vpxd service fails to start or crashes due to a mismatch in the host’s parent IDs.

Environment

VMware vCenter Server 6.x
VMware vCenter Server 7.x
VMware vCenter Server 8.x

Cause

The vpx_entity table contains multiple entries for a single ESXi host, with each entry associated with a distinct Parent ID. This mismatch causes the VPXD service to fail when trying to remove an ESXi host from the VCDB.

Resolution

Note: Before proceeding with the steps below, create a snapshot of the vCenter Server.

Standalone vCenter Server:
 Take a non-memory snapshot. 

Linked Mode vCenter Servers: 
1. Power off all vCenter VMs in Linked Mode.
2. Take snapshots of each VM.
3. Power on the vCenter VMs. 

Steps to resolve the Parent ID mismatch for an ESXi host before removing it from the VCDB:

1. Stop the vpxd service on the vCenter Server.
    service-control --stop vmware-vpxd
 
2. Connect to the vCenter Server vPostgres database:
    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres
 
3. Identify the ESXi host ID in the vCenter database with this command:
    select * from vpx_entity where name='esxi host name';
 
For example, the ESXi Host being removed is example.example.com. This host returns the below output when the select statement is executed.
id   |            name    | type_id | parent_id
-------+-----------------------------+---------+-----------
64194 | example.example.com  |       2 |     58154
64193 | example.example.com  |       1 |     64194
 
4. To identify which of the 2 host entries is the correct entry from the vpx_host table: 
     select id,dns_name from vpx_host where dns_name='example.example.com';
 
5. Identify the correct Parent ID in the vCenter database with this command:
    select * from vpx_entity where id='58154';
 
Note: The Parent ID refers to the entity (e.g., Cluster, Datacenter, Folder) under which the host is associated. Based on the UI logs, the host resides under the "ESXi Folder" folder. Verify the correct Parent ID by checking both entries.
 
For Example:
  id   |      name      | type_id | parent_id
-------+----------------+---------+-----------
 58154 | ESXi Folder    |       6 |       668
 
 
6.  List the virtual machines in the virtual machine table which exist on this ESXi host with this statement:
     select id from vpx_vm where host_id = 58154;
 
7. Remove the virtual machines from the previous step using article: Manually removing a stale VM from the vCenter Server vpostgres database  
 
8. The vpx_entity table's constraint prevents updating the Parent ID. You need to drop this constraint before you can change the Parent ID to the correct one.
    ALTER TABLE vpx_entity DROP CONSTRAINT fk_vpx_enti_ref_vpx_enti;
 
9. Set the correct Parent ID for the host:
    update vpx_entity set parent_id=58154 where id=64193;
 
10. After updating, verify that both entries for the host now have the same, correct Parent ID:
      select * from vpx_entity where name='esxi host name';
 
Example Output:
id   |            name    | type_id | parent_id
-------+-----------------------------+---------+-----------
64194 | example.example.com  |       2 |     58154
64193 | example.example.com  |       1 |     58154
 
 
12. After the ESXi Host is removed from VCDB, add the constraint back to vpx_entity table:
       ALTER TABLE vpx_entity ADD CONSTRAINT fk_vpx_enti_ref_vpx_enti FOREIGN KEY (parent_id) REFERENCES vpx_entity(id);
 
13. Start the vpxd service on the vCenter Server:
      service-control --start vmware-vpxd