Tuesday, November 10, 2020

VMware: /storage/seat disk 100% full on vCenter Server Appliance 6.x/7.x

If this problem occurs, it is recommended that you run a script to clean up the Postgres database tables, or even better run it monthly using the "cron" scheduler.

Following are the steps to configure vCenter Server:

1. Connect to your vCenter via SSH or complete all steps from the KVM console.

2. Create a script to clean up the database:

vim /root/cleanup.sql 

and add the following text:

DO
$$
DECLARE
    rec   record;
BEGIN
   FOR rec IN
      SELECT *
      FROM   pg_tables
      WHERE tablename ~ '^vpx_event_[0-9].*'
      ORDER  BY tablename
   LOOP
      EXECUTE 'TRUNCATE TABLE '
       || quote_ident(rec.schemaname) || '.'
       || quote_ident(rec.tablename) || ' CASCADE';
   END LOOP;
END$$;

DO
$$
DECLARE
    rec   record;
BEGIN
   FOR rec IN
      SELECT *
      FROM   pg_tables
      WHERE tablename ~ '^vpx_event_arg_[0-9].*'
      ORDER  BY tablename
   LOOP
      EXECUTE 'TRUNCATE TABLE '
        || quote_ident(rec.schemaname) || '.'
        || quote_ident(rec.tablename) || ' CASCADE';
   END LOOP;
END$$;

3. Create a script to run monthly cleanup:

vim /etc/cron.monthly/dbcleanup

and add the following text:

#!/bin/bash
/opt/vmware/vpostgres/current/bin/psql -d VCDB postgres -f /root/cleanup.sql -h /var/run/vpostgres

4. Change the permissions so that "cron" can run your procedure correctly:

chmod 700 /etc/cron.monthly/dbcleanup

5. If necessary, initiate the cleanup by executing the script manual:

/etc/cron.monthly/dbcleanup 

Also make sure that the "root" user does not have an expired password. It is best to connect to the vCenter on port 5480 with a web browser and set the "Password expires" setting to "No".

No comments:

Post a Comment