Warning: Theses steps should not be used on environments using vCloud Director.
Caution: Please consult a Broadcom Support Engineer before performing these steps
Note: These steps are for vCenter Server using a Microsoft SQL database or vPostgres.
ESXi 6.x and 7.x
To manually remove an ESXi 6.x and 7.x host from the vCenter Server database:
- Stop the vpxd service on the vCenter Server. For more information, see Stopping, starting, or restarting vCenter services (1003895) for Windows vCenter and
Stopping, Starting or Restarting VMware vCenter Server Appliance 6.x & above services (2109887) for vCenter Appliance
service-control --stop vmware-vpxd
-
Connect to the vCenter Server vPostgres database:
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres
- Identify the ESXi host ID in the vCenter database with this command:
select ID, parent_id from VPX_ENTITY where name ='<esxi host name>';
Note: For example, the ESXi host being removed is esx01.vmware.com. This host returns a host ID of 24699 when the preceding select statement is executed.
- Execute these SQL statements to remove the ESXi host from the vCenter database.
Note: The SQL statements must be executed in the order specified to ensure that any constraint definitions in the database are not violated.
- Remove all the datastore assignments for virtual machines which exist on this ESXi host with this statement:
delete from vpx_ds_assignment where entity_id in (select id from vpx_vm where host_id = 24699);
- Remove all the network assignments virtual machines that exist on this ESXi host with this statement:
delete from vpx_nw_assignment where entity_id in (select id from vpx_vm where host_id = 24699);
- 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 = 24699;
Note: Make a note of the virtual machine IDs returned.
- Remove the virtual machines from the previous step using Wolken | Manually removing a stale VM from the vCenter Server vpostgres database(311105)
- Delete the DVS entries associated with the ESXi host with this statement:
delete from vpx_dvhost where host_id = 24699;
delete from vpx_dvport_membership where host_id = 24699;
delete from vpx_dvs_blob where host_id = 24699;
- Delete the ESXi host from the host table with this statement:
delete from vpx_host where id = 24699;
Notes:
- A cascade delete constraint definition (constraint FK_VPX_HOST_REFERENCE_VPX_HOST foreign key (HOST_ID) references VPX_HOST (ID) on delete cascade) is created on these tables. Corresponding entries with matching HOST_ID=24699 automatically get removed from these tables:
vpx_host_x
vpx_host_vm_config_option
vpx_compute_resource_dpm_host
vpx_host_cpu
vpx_host_node
vpx_host_node_cpu
vpx_host_pci_device
- A cascade delete constraint definition (constraint FK_VPX_CPU_THREAD_REF_HOST_CPU foreign key (HOST_ID, CPU_INDEX) references VPX_HOST_CPU (HOST_ID, CPU_INDEX) on delete cascade) is created on these tables. Corresponding entries with matching HOST_ID=24699 automatically get removed from these tables:
vpx_host_cpu_thread
vpx_host_cpu_cpuid_feature
- Delete the ESXi host from the entity table with this statement:
delete from vpx_entity where id = 24699;
- Remove all relations to this ESXi host from the entity table with this statement:
delete from vpx_entity where parent_id = 24699;
delete from vpx_entity where id = 24699;
- Start the vpxd service on the vCenter Server to pick up the database changes. For more information, see Stopping, starting, or restarting vCenter services (1003895) for Windows vCenter and Stopping, Starting or Restarting VMware vCenter Server Appliance 6.x & above services (2109887) for vCenter Appliance.
In case the ESXi Host is as standalone host (not part of a cluster), additional steps needs to be taken to avoid any invalid situation where a standalone compute resource is left without a host.
To remove standalone ESXi Host from vCenter Database:
- Apply same first two steps ( stop vpxd and identify the ESXi Host ID)
- In the Execute SQL statement step, please apply the below two extra steps:
- Check for orphaned compute resources with this statement:
SELECT id, name FROM vpx_entity WHERE type_id = 2 and id not in (SELECT a.id FROM vpx_entity as A LEFT JOIN vpx_entity as B ON A.id = B.parent_id where a.type_id=2 and b.type_id=1 GROUP BY A.id);
Example:
"SELECT * FROM vpx_entity WHERE type_id = 2 and id not in (SELECT a.id FROM vpx_entity as A LEFT JOIN vpx_entity as B ON A.id = B.parent_id where a.type_id=2 and b.type_id=1 GROUP BY A.id);"
id | name |
--------+--------------------------+---------+-----------
187911 | somename---------------- |
187913 | somename---------------- |
(2 rows)
- If some records are displayed, DELETE all zombies (XXX is the id of each compute resource from step 1):
DELETE FROM vpx_entity WHERE parent_id = XXX;
DELETE FROM vpx_entity WHERE id = XXX;
Example:
DELETE FROM vpx_entity WHERE parent_id = 187911;
DELETE FROM vpx_entity WHERE id = 187911;