This article provides steps to manually delete a cluster from the vCenter Server database.
VMware vCenter Server Appliance 6.0.x
VMware vCenter Server Appliance 6.7.x
VMware vCenter Server Appliance 6.5.x
NOTE: The preceding log excerpts are only examples. Date, time, and environmental variables may vary depending on your environment
1. Take a powered off snapshot of the vCenter server. This is to avoid any database corruption or any human error.
Note: It is highly recommended you take a physical backup of the vPostgreSQL or SQL databases as a precaution in case the vCenter has any issues on roll back.
Back up and restore vCenter Server Appliance/vCenter Server 6.x vPostgres database (2091961)
# service-control --stop vmware-vpxd
# service-control --stop vmware-content-library
3. Access the vCenter Server Postgres database
# /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres
4. Identify the Cluster ID in the vCenter database with this command: (cluster name must match the way its displayed on vCenter Server).
Replace 'cluster-name' with the name of the cluster you want to delete.
# SELECT * FROM VPX_ENTITY WHERE NAME='cluster-name';
Example: 'Test-DB-Clean-up'
Result:
VCDB=# SELECT * FROM VPX_ENTITY WHERE NAME='Test-DB-Clean-up';
id | name | type_id | parent_id
-----+------------------+---------+-----------
121 | Test-DB-Clean-up | 3 | 4
(1 row)
5. Execute these queries to remove the cluster entries from the vCenter database. For step 5a through 5b, run the queries as written and do not add specific IDs or parent IDs.
5a.Execute the following queries to drop and re-add the constraints with the on delete parameters :
# ALTER TABLE vpx_entity DROP CONSTRAINT fk_vpx_enti_ref_vpx_enti, ADD CONSTRAINT fk_vpx_enti_ref_vpx_enti FOREIGN KEY (PARENT_ID) REFERENCES vpx_entity (id) ON DELETE CASCADE;
Result: VCDB=# ALTER TABLE vpx_entity DROP CONSTRAINT fk_vpx_enti_ref_vpx_enti, ADD CONSTRAINT fk_vpx_enti_ref_vpx_enti FOREIGN KEY (PARENT_ID) REFERENCES vpx_entity (id) ON DELETE CASCADE;
ALTER TABLE
5b.Execute the following queries to drop and re-add the constraints with the on delete parameters:
# ALTER TABLE vpx_entity DROP CONSTRAINT FK_VPX_ENT_REF_VPX_ENT_TYPE, ADD CONSTRAINT FK_VPX_ENT_REF_VPX_ENT_TYPE FOREIGN KEY (TYPE_ID) REFERENCES VPX_OBJECT_TYPE (id) ON DELETE CASCADE;
Result:
VCDB=# ALTER TABLE vpx_entity DROP CONSTRAINT FK_VPX_ENT_REF_VPX_ENT_TYPE, ADD CONSTRAINT FK_VPX_ENT_REF_VPX_ENT_TYPE FOREIGN KEY (TYPE_ID) REFERENCES VPX_OBJECT_TYPE (id) ON DELETE CASCADE;
ALTER TABLE
5c.Delete the cluster entry from the entity table. (The ID is the ID from the results form step 4).:
# Delete from vpx_entity where id=121;
Result:
VCDB=# Delete from vpx_entity where id=121;
DELETE 1
5d.Validate and take note of the id value for the cluster wrt the moid (the ID is the same ID from step 4. You may get additional results because the %% looks for similarity we are only looking for the "domain-**" id). # select * from VPX_STAT_ID where moid like '%121%';
Result:
VCDB=# select * from VPX_STAT_ID where moid like '%121%';
id | moid
-----+-------------
401 | domain-c121
(1 row)
5e.Delete the cluster entry from the VPX_STAT_ID table # DELETE FROM VPX_STAT_ID WHERE id=401;
Result:
VCDB=# DELETE FROM VPX_STAT_ID WHERE id=401;
DELETE 1
5f.Exit VCDB
# \q
6. Start the vpxd and content library services on the vCenter Server
# service-control --start vmware-vpxd
# service-control --start vmware-content-library
NOTE: If you need assistance, please open a support ticket with Broadcom Support.
Confirm that the tables VPX_ALARM_RUNTIME, VPX_ALARM_DISABLED_ACTIONS, and VPX_STAT_COUNTER are free of any data associated with the cluster.