I am Dale Hayter, a Microsoft and VMware certified Technical Consultant.

My blog has been built up over the years from my experience of working on an IT helpdesk and also from being out on-site.

Shrink VMware Virtual Center Appliance Database

I had an incident this week where a sites VMware Virtual Center Appliance database reached 16GB in size. When it got to this size the VC became unresponsive and we couldn’t log in.

To resolve the issue you need to SSH to the VC. Then stop loads of running services using the commands below :-

service vmware-sps stop
service vmware-inventoryservice stop
service vmware-netdumper stop
service vmware-logbrowser stop
service vmware-rbd-watchdog stop
service vsphere-client stop
service vmware-sso stop
service vmware-vpxd stop

Then we need to connect to the postgres database.

su - postgres
/opt/vmware/vpostgres/1.0/bin/psql -d VCDB vc
\c VCDB

Then we can see how big the database is using the command below :-

SELECT pg_size_pretty(pg_database_size('VCDB'));

To make the database smaller we are going to get rid of the events history. We can do this using the command.

truncate table VPX_EVENT CASCADE;

Now Log off from database with

\q

Now reboot the VM and you should all be good. You can check the size again of the database by using the commands in the order below :-

su - postgres
/opt/vmware/vpostgres/1.0/bin/psql -d VCDB vc
\c VCDB
SELECT pg_size_pretty(pg_database_size('VCDB'));

Mine went from 16GB to just under 8GB.