This article explains how to prepare the vCenter Server Appliance to connect with external Postgres Management Tools like pgAdmin. This method works with vCenter Server Appliance version 6.5, 6.7, and 7.0.
Caution: Working with the database can cause issues with the vCenter Service. Make sure that you know what you are doing and double-check that you have a working backup or snapshots of the vCenter Server Appliance. Consider working with VMware Support if you have problems in a critical production environment.
Disclaimer: This is not officially supported by VMware, please use at your own risk.
vCenter Server Appliance Preparation
- Connect to the vCenter Servier Appliance with ssh as root user.
- Extract the database password from the configuration file in /etc/vmware-vpx/vcdb.properties
# cat /etc/vmware-vpx/vcdb.properties
- Configure the firewall to accept connections on port 5432
# iptables -I INPUT 1 -p tcp --dport 5432 -j ACCEPT
- Configure vPostgres to allow connections from remote hosts. The configuration file is located at /storage/db/vpostgres/pg_hba.conf.
echo "host all vc 0.0.0.0/0 md5" >> /storage/db/vpostgres/pg_hba.conf
This entry allows connections from all hosts, but you still need a password to log in. If you use "all" instead of "vc", the postgres user can connect without a password! To limit connections to a specific address, change 0.0.0.0/0 to your local network. Example: 192.168.0.0/24 to allow a subnet or 192.168.0.10/32 to allow a specific IP address.
- Reload vPostgres Configuration to activate changes in pg_hba.conf
# /opt/vmware/vpostgres/current/bin/psql -U postgres -c "SELECT pg_reload_conf();"
pgAdmin Installation and Configuration
- Download and Install the latest version of pgAdmin: www.pgadmin.org/download/
- Open pgAdmin (Web-based Interface)
- Right-Click Servers and navigate to Create > Server...
- Enter a Name
- Enter Hostname, Username, and Password in the Connection Tab.
- Click Save
You are now connected to the vPostgres database and should see two instances: VCDB and postgres.
If you have not worked with a database management tool, this is how you could get started: To get a list of registered Virtual Machines, for example, navigate to Servers > vCenter DB > Databases > VCDB > Schemas > vc > Views > vpxv_vms and click View Data (Table Icon above navigation bar).