You encounter a situation where:
1. The vCenter vmx file is either deleted or missing.
2. The vmware.log of the vCenter VM is missing too.
4. The vCenter server is still accessible from UI, VAMI and command line.
VMware vCenter Server
VMware vSphere ESXi
Please note that this procedure is only applicable to vCenter Appliance VM. Also, since the VC is still up and running, do not make any changes to the VM via Edit settings as the VM shall look for its vmx file to implement those and failure to detect the same can cause the VM to go down immediately.
To re-create the vmx file, please follow the below steps.
1. Make a note of the affected vCenter server's version.
2. Make a copy of the vmx file of another vCenter server on the same version.
3. Using Notepad/Notepad++ or vi editor (in case you're using the esxcli of the Host where the vCenter server VM sits), modify the following properties of the copied vmx file to replicate the vmx of the affected vCenter Server.
A. SCSI disk mapping- map the same to the base disk in case the vCenter server was running on the same. Else if the vCenter VM was running on snapshots, map it to the snapshot disk. For example,
If the VM was running on the base disk, the mapping would look like below
scsix:x.deviceType = "scsi-hardDisk"
scsix:x.fileName = "<VM-Name>.vmdk"
If the VM was running on the snapshot disk, the mapping would look like below
scsix:x.deviceType = "scsi-hardDisk"
scsix:x.fileName = "<VM-Name-00000Y>.vmdk" (where Y is the latest snapshot VM was running on).
Ensure that the mapping is correct for all the disks that belong to the vCenter VM.
B. uuid.bios, vc.uuid and uuid.location- to obtain the same, run the below VCDB query after navigating inside vPostgres.
select uuid_bios,uuid_instance from vpx_vm where file_name like '%vcsa%'; (where vcsa is the name of the vCenter VM)
Replace the values of uuid.bios and vc.uuid in your vmx with the values you obtain. The uuid.location will be the same as uuid.bios.
C. nvram - rename it as <VM-Name>.nvram
D. numvcpus and memSize - replace the values to reflect the current config of the affected vCenter VM.
E. displayName - Rename this to reflect the name of your vCenter VM.
F. sched.swap.derivedName = Rename this to reflect the name of your vCenter VM's vswp file which can be found inside the VM folder in the concerned Datastore.
G. migrate.hostlog = Rename this to reflect the name of your vCenter VM's vswp file which can be found inside the VM folder in the concerned Datastore. The format would be "./<vCenter VM swap file prefix including the alphanumeric identifier>.hlog
4. Now save the vmx file and copy it to the affected vCenter VMs' folder inside the Datastore.
5. Restart the vCenter server. The vCenter server should come up with the new vmx file.
Please note that this procedure is only applicable to vCenter Appliance VM. For other VMs', please use the instructions in the below kb articles to recreate a vmx file.
Recreating a lost or deleted vmx file- https://knowledge.broadcom.com/external/article/341647/recreating-a-lost-or-deleted-vmx-file.html
Rebuilding the virtual machine's .vmx file from vmware.log- https://knowledge.broadcom.com/external/article/316605/rebuilding-the-virtual-machines-vmx-file.html