To run the VMware Postgres Vacuum task manually:
- Log in to the VMware vCenter Server Appliance as root using SSH or the console.
- Run this command to stop the vCenter Server service:
service vmware-vpxd stop
- Run this command to obtain the embedded vCenter Server database password:
cat /etc/vmware-vpx/embedded_db.cfg | grep PASSWORD
- Run this command to check the available database storage space:
df -h
Note: The embedded database is stored at /storage/db
- Reclaim space by running this vacuum command:
sudo -u postgres /opt/vmware/vpostgres/current/bin/vacuumdb -a -e -v -f -U postgres > /tmp/vacuumdb.log
Note: By default, there are 5 databases: postgres, template0, template1, VCDB and ssodb. You are prompted for a password for each database in the cluster. Provide the password obtained in Step 3.
- Check the database storage space and verify space usage decrease by running this command:
df -h
If the vacuum operation is unable to complete due to lack of space errors:
- Add temporary storage. For more information, see Adding additional temporary storage space to vCenter Server Appliance for VMware Postgres maintenance (2056449).
- Stop the VMware Postgres service by running this command:
service vmware-vpostgres stop
- Copy the database files to new disk mount by running this command:
cp -ar /storage/db/vpostgres /storage/db1/vpostgres
- Run this command to start the database from the new location:
sudo -u postgres /opt/vmware/vpostgres/current/bin/pg_ctl -D /storage/db1/vpostgres start
- Run this command to verify that the service has started and is running from the correct location:
sudo -u postgres /opt/vmware/vpostgres/current/bin/pg_ctl -D /storage/db1/vpostgres status
- Reclaim space by running this vacuum command:
sudo -u postgres /opt/vmware/vpostgres/current/bin/vacuumdb -a -e -v -f -U postgres > /tmp/vacuumdb.log
- Check the database storage space and verify decrease in space usage by running this command:
df -h
Note: The new location of the database is /storage/db1.
- Run this command to stop the database from the new location:
sudo -u postgres /opt/vmware/vpostgres/1.0/bin/pg_ctl -D /storage/db1/vpostgres stop
- Note: Snapshot of the vCenter server and a Full backup of the Current state needed before we proceed further.
Run this command to remove the original database directory:
Important: It is strongly recommended that you have a backup of this directory and its contents before removing this directory, as rm -rf is a file/data deletion command.
rm -rf /storage/db/vpostgres
- Copy the new directory to the original location by running this command:
cp -ar /storage/db1/vpostgres /storage/db/vpostgres
- Run this command to start the VMware Postgres service:
service vmware-vpostgres start
Note: To remove the temporary disk mount, shutdown the vCenter Server Appliance. Remove the temporary disk as necessary using edit settings in the vSphere Web Client and restart the vCenter Server Appliance.
- Run this command to verify the space usage decrease:
df -h
Note: The database is located at /storage/db.
- Start the vCenter Server service by running this command:
service vmware-vpxd start