Symptoms:
VMware vCenter Server 8.x
VMware vCenter Server 7.x
VMware vCenter Server 6.x
A virtual machine was directly removed from the ESXi when the VC was down.
Important: Ensure that a fresh backup or offline snapshot of the vCenter Server Appliance has been created. If the vCenter Server is part of a Linked Mode replication group, backups/offline snapshots need to be created for every member of the Linked Mode group.
To manually remove a virtual machine from the vCenter Server database:
service-control --stop vmware-vpxd
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres
select * from vpx_entity where id = '<id_from_url>';
VCDB=# select * from vpx_entity where id = '0000';
id | name | type_id | parent_id
------+----------+---------+-----------
xxxx | vm-0000 | 0 | yyyy
delete from VPX_COMPUTE_RESOURCE_DAS_VM where VM_ID=0000;
delete from VPX_COMPUTE_RESOURCE_DRS_VM where VM_ID=0000;
delete from VPX_GUEST_DISK where VM_ID=0000;
delete from VPX_VIRTUAL_DEVICE where ID=0000;
delete from VPX_VM_CONFIG_INFO where ID=0000;
delete from VPX_VM_DS_SPACE where VM_ID=0000;
delete from VPX_VM_FILE_LAYOUT_EX where VM_ID=0000;
delete from VPX_VM_FLE_DISK_LAYOUT where VM_ID=0000;
delete from VPX_VM_FLE_FILE_INFO where VM_ID=0000;
delete from VPX_VM_FLE_SNAPSHOT_LAYOUT where VM_ID=0000;
delete from VPX_VM_STATIC_OVERHEAD_MAP where VM_ID=0000;
delete from VPX_VM where ID=0000;
delete from VPX_ENTITY where ID=0000;
delete from VPX_GUEST_DISK where VM_ID=0000;
delete from VPX_VM_VIRTUAL_DEVICE where ID=0000;
delete from VPX_VM_CONFIG_INFO where ID=0000;
delete from VPX_VM_DS_SPACE where VM_ID=0000;
delete from VPX_VM_FILE_LAYOUT_EX where VM_ID=0000;
delete from VPX_VM_FLE_DISK_LAYOUT where VM_ID=0000;
delete from VPX_VM_FLE_FILE_INFO where VM_ID=0000;
delete from VPX_VM_FLE_SNAPSHOT_LAYOUT where VM_ID=0000;
delete from VPX_VM where ID=0000;
delete from VPX_ENTITY where ID=0000;
delete from VPX_COMPUTE_RESOURCE_DAS_VM where VM_ID=0000;
delete from VPX_COMPUTE_RESOURCE_DRS_VM where VM_ID=0000;
delete from VPX_COMPUTE_RESOURCE_ORC_VM where VM_ID=0000;
delete from VPX_GUEST_DISK where VM_ID=0000;
delete from VPX_VM_VIRTUAL_DEVICE where ID=0000;
delete from VPX_VM_DS_SPACE where VM_ID=0000;
delete from VPX_NON_ORM_VM_CONFIG_INFO where ID=0000;
delete from VPX_NORM_VM_FLE_FILE_INFO where VM_ID=0000;
delete from VPX_VDEVICE_BACKING_REL where VM_ID=0000;
delete from VPX_VIRTUAL_DISK_IOFILTERS where VM_ID=0000;
delete from VPX_VM_STATIC_OVERHEAD_MAP where VM_ID=0000;
delete from VPX_VM_TEXT where VM_ID=0000;
delete from VPX_VM where ID=0000;
delete from VPX_ENTITY where ID=0000;
delete from VPX_COMPUTE_RESOURCE_DAS_VM where VM_ID=0000;
delete from VPX_COMPUTE_RESOURCE_DRS_VM where VM_ID=0000;
delete from VPX_COMPUTE_RESOURCE_ORC_VM where VM_ID=0000;
delete from VPX_VM_SGXINFO where VM_ID=0000;
delete from VPX_GUEST_DISK where VM_ID=0000;
delete from VPX_VM_VIRTUAL_DEVICE where ID=0000;
delete from VPX_VM_DS_SPACE where VM_ID=0000;
delete from VPX_NON_ORM_VM_CONFIG_INFO where ID=0000;
delete from VPX_NORM_VM_FLE_FILE_INFO where VM_ID=0000;
delete from VPX_VDEVICE_BACKING_REL where VM_ID=0000;
delete from VPX_VIRTUAL_DISK_IOFILTERS where VM_ID=0000;
delete from VPX_VM_STATIC_OVERHEAD_MAP where VM_ID=0000;
delete from VPX_VM_TEXT where VM_ID=0000;
delete from VPX_VM where ID=0000;
delete from VPX_ENTITY where ID=0000;
delete from VPX_DVPORT where connectee='vm-0000';
delete from VPX_COMPUTE_RESOURCE_DAS_VM where VM_ID=0000;
delete from VPX_COMPUTE_RESOURCE_DRS_VM where VM_ID=0000;
delete from VPX_COMPUTE_RESOURCE_ORC_VM where VM_ID=0000;
delete from VPX_VM_SGXINFO where VM_ID=0000;
delete from VPX_GUEST_DISK where VM_ID=0000;
delete from VPX_VM_VIRTUAL_DEVICE where ID=0000;
delete from VPX_VM_DS_SPACE where VM_ID=0000;
delete from VPX_NON_ORM_VM_CONFIG_INFO where ID=0000;
delete from VPX_NORM_VM_FLE_FILE_INFO where VM_ID=0000;
delete from VPX_VDEVICE_BACKING_REL where VM_ID=0000;
delete from VPX_VIRTUAL_DISK_IOFILTERS where VM_ID=0000;
delete from VPX_VM_STATIC_OVERHEAD_MAP where VM_ID=0000;
delete from VPX_VM_TEXT where VM_ID=0000;
delete from VPX_VM where ID=0000;
delete from VPX_ENTITY where ID=0000;
delete from VPX_DVPORT where connectee='vm-0000';
service-control --start vmware-vpxd