Per-requisites:
- To check the database storage space, run this command:
du -h /var/lib/vrmsdb --max--depth=0
- To check the storage usage, run this command
df /var/lib/vrmsdb
- To check the failure of autovacuum, run the command
/usr/bin/pgrep -f autovacuum
If the autovacuum command returns PID, then further investigation is required. However, if no PID is returned follow the resolution steps given below.
To resolve the issue, run the following steps;
- Add a new hard disk to the VR appliance with the vCenter.
- Log in to the VR appliance as the root user.
- Find the newly added disk and format it and mount it.
- List all the disks
fdisk -l|grep '^Disk'
- Format the disk, let's assume the disk is /dev/sdc.
mkfs.ext3 /dev/sdc
- Mount the disk, let's mount it to the /transition directory.
mkdir /transition
mount /dev/sdc /transition
- Change the owner of the directory to vrmsdb.
chown vrmsdb:vrmsdb /transition
- Log in to the psql cli and alter the tablespace for database vrmsdb.
/opt/vmware/vpostgres/current/bin/psql postgres -U vrmsdb
- Execute below commands in the cli
- Create a new table space on the new disk(named with transition)
CREATE TABLESPACE transition LOCATION '/transition';
- Disable the connection to the database
UPDATE pg_database SET datallowconn = false WHERE datname = 'vrmsdb';
- Terminate all the connections to the database.
SELECT pg_terminate_backend(pid) FROM pg_stat_activity
WHERE datname = 'vrmsdb' AND pid <> pg_backend_pid();
- Change the database tablespace.
ALTER DATABASE vrmsdb SET TABLESPACE transition;
- Enable the connection to the database
UPDATE pg_database SET datallowconn = true WHERE datname = 'vrmsdb';
- Exit the cli
\q
- Manually execute the vacuumdb.
/opt/vmware/vpostgres/current/bin/vacuumdb -a -e -v -f -U vrmsdb > /tmp/vacuumdb.log
- Reindex the db.
/opt/vmware/vpostgres/current/bin/reindexdb -a -U vrmsdb > /tmp/reindexdb.log"
- Log in to the psql cli and restore the tablespace for database vrmsdb.
/opt/vmware/vpostgres/current/bin/psql postgres -U vrmsdb
- Execute below commands in the cli
- Disable the connection to the database.
UPDATE pg_database SET datallowconn = false WHERE datname = 'vrmsdb';
- Terminate all the connections to the database.
SELECT pg_terminate_backend(pid) FROM pg_stat_activity
WHERE datname = 'vrmsdb' AND pid <> pg_backend_pid();
- Change the table space of vrmsdb back to the default ALTER DATABASE vrmsdb SET TABLESPACE pg_default;
- Enable the connection to the database
UPDATE pg_database SET datallowconn = true WHERE datname = 'vrmsdb';
- Drop the transition table space.
DROP TABLESPACE transition;
- Exit the cli.
- Check the database storage space and verify space usage decrease, run this command,
du -h /var/lib/vrmsdb --max--depth=0