In VMware vCenter Server 7.0 Update 3g (VMware Postgres 13.6.0) and above, the postgresql-*log in the folder /var/log/vmware/vpostgres/ might grow to a large size.
The file system in the /storage/log partition fills up.
The vCenter Server performance becomes noticeably slow and users experience latency when logging in.
Running the following command identifies postgresql.log as the largest file consuming space in the partition:
find /storage/log -type f -print0 | xargs -0 du -h | sort -rh | head -n 10
Attention: Before making any change, ensure that a fresh backup or snapshot of the vCenter Server Appliance is created. If the affected vCenter is a member of an Enhanced Linked Mode (ELM) replication setup, offline snapshots (in powered off state) are to be created for all of the ELM nodes.
If the vCenter has VCHA enabled, it should be disabled and turned off before making the below changes, followed by a fresh snapshot.
Step 1: Reclaim space on /storage/log filesystem
# cd /var/log/vmware/vpostgres
# cat /dev/null > postgresql.log# df -h /storage/log# cd /var/log/vmware/vpostgres
# find . -name "p*\.log*" -mtime +14 -type f -exec du -sh {} \; | sort -n# cd /var/log/vmware/vpostgres
# find . -name "p*log*" -mtime +14 -type f -exec rm -f {} \; # df -h /storage/logStep 2: Reduce the auto_explain output to prevent the issue from occurring again
There are two options to reduce the auto_explain output. Neither of them requires a restart of the vpostgres service:
auto_explain.log_min_duration parameter to a value higher than 10s.Option A - Increase the auto_explain.log_min_duration parameter to a value higher than 10s
# cp /storage/db/vpostgres/postgresql.conf /storage/db/vpostgres/postgresql.origauto_explain.log_min_duration parameter to a value higher than 10s:# vi /storage/db/vpostgres/postgresql.confauto_explain.log_min_duration = 10sauto_explain.log_min_duration = 30s:wq# grep auto_explain /storage/db/vpostgres/postgresql.confSample Output:
root@<vc_name> [ ~ ]# grep auto_explain /storage/db/vpostgres/postgresql.confsession_preload_libraries = 'auto_explain'auto_explain.log_min_duration = 30sauto_explain.log_analyze = trueauto_explain.log_timing = falseauto_explain.log_buffers = trueauto_explain.log_wal = trueauto_explain.log_triggers = trueauto_explain.log_nested_statements = true
# /opt/vmware/vpostgres/current/bin/psql -U postgres -d VCDB -c "select pg_reload_conf();"
Option B - Disable auto_explain logging in vpostgres
# cp /storage/db/vpostgres/postgresql.conf /storage/db/vpostgres/postgresql.orig# grep auto_explain /storage/db/vpostgres/postgresql.confSample output:
root@<vc_name> [ ~ ]# grep auto_explain /storage/db/vpostgres/postgresql.confsession_preload_libraries = 'auto_explain'auto_explain.log_min_duration = 30sauto_explain.log_analyze = trueauto_explain.log_timing = falseauto_explain.log_buffers = trueauto_explain.log_wal = trueauto_explain.log_triggers = trueauto_explain.log_nested_statements = true
# sed -i 's/^session_preload_libraries/#session_preload_libraries/' /storage/db/vpostgres/postgresql.conf
# sed -i 's/^auto_explain\./#auto_explain\./' /storage/db/vpostgres/postgresql.conf# grep auto_explain /storage/db/vpostgres/postgresql.confSample output:
root@<vc_name> [ ~ ]# grep auto_explain /storage/db/vpostgres/postgresql.conf#session_preload_libraries = 'auto_explain'#auto_explain.log_min_duration = 30s#auto_explain.log_analyze = true#auto_explain.log_timing = false#auto_explain.log_buffers = true#auto_explain.log_wal = true#auto_explain.log_triggers = true#auto_explain.log_nested_statements = true
Reload the vpostgres configuration from postgresql.conf:
# /opt/vmware/vpostgres/current/bin/psql -U postgres -d VCDB -c "select pg_reload_conf();"