Manually deleting a cluster from the vCenter Server database
search cancel

Manually deleting a cluster from the vCenter Server database

book

Article ID: 322840

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

This article provides steps to manually delete a cluster from the vCenter Server database (VCDB).

Environment

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

Resolution

Note: It is highly recommended to take a working Backup of vCenter before making any changes to the postgres database.

          Please reach out to Broadcom Support in case you need any assistance to execute below steps.

 Make sure no ESXi hosts, VMs or any other objects are associated with the Cluster that you want to manually delete from VCDB.

 

1. Take vCenter server snapshot before proceeding with below steps. (Make sure to take powered off snapshot if vCenter servers are in ELM - Enhanced Linked Mode) 

2. Stop the vpxd and content library services on the vCenter Server appliance:

    # 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 using below 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';

        Result:

        VCDB=# SELECT * FROM VPX_ENTITY WHERE NAME='cluster-name';
         id  |       name       | type_id | parent_id
        -----+------------------+---------+-----------
         1#1 | 'cluster-name' |       3 |         4
        (1 row)

5. Execute these queries to remove the cluster entries from the vCenter database. For step 5a through 5b:


    5a.Execute the following queries to drop and re-add the constraints with the on delete parameters .Note: Do not change the values for PARENT_ID and id.Execute the same command as is.


        # 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;


    5b.Execute the following queries to drop and re-add the constraints with the on delete parameters:Note: Do not change the values for TYPE_ID and id.Execute the same command as is


        # 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=1#1;
        
        Result:
        VCDB=# Delete from vpx_entity where id=1#1;
        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 '%1#1%';
        
        Result:
        VCDB=# select * from VPX_STAT_ID where moid like '%1#1%';
         id  |    moid
        -----+-------------
         4#1 | domain-c##1
        (1 row)

        
    5e.Delete the cluster entry from the VPX_STAT_ID table
        # DELETE FROM VPX_STAT_ID WHERE id=4#1;
        
        Result:
        VCDB=# DELETE FROM VPX_STAT_ID WHERE id=4#1;
        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

 

Additional Information

Confirm that the tables VPX_ALARM_RUNTIME, VPX_ALARM_DISABLED_ACTIONS, and VPX_STAT_COUNTER are free of any data associated with the removed cluster.