To resolve this issue:
- Check for .pgpass file under /root folder. If not available, proceed with below steps to recreate the file:
- Login to Source VCSA using SSH.
- Execute the command ls /root/ -larth to verify the file presence.
Note: Take Snapshot of Source vCenter Server Appliance before proceeding with below steps.
- Copy PGUSER Password from the /etc/vmware-vpx/embedded_db.cfg file.
For example:
root@testvcenter [ / ]# cat /etc/vmware-vpx/embedded_db.cfg | grep PGUSER_PASSWORD
PGUSER_PASSWORD='PG-PASSWORD'
- Create the .pgpass file under /root with the new password:
- touch /root/.pgpass
- chmod 0600 /root/.pgpass
- vi /root/.pgpass
- Press Insert Key and Copy below contents to the file, replace PASSWORD with the password copied from above step and press ESC Key and wq! to exit the VI editor:
localhost:5432:postgres:postgres:PASSWORD
127.0.0.1:5432:postgres:postgres:PASSWORD
localhost:5432:VCDB:postgres:PASSWORD
127.0.0.1:5432:VCDB:postgres:PASSWORD
/var/run/vpostgres:5432:*:postgres:PASSWORD
- Take a copy of /storage/db/vpostgres/pg_hba.conf file:
cp /storage/db/vpostgres/pg_hba.conf /storage/db/vpostgres/pg_hba.conf_backup
- Edit the /storage/db/vpostgres/pg_hba.conf file using VI editor and change md5 to trust for below values:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
- Save and close the pg_hba.conf file.
- Stop and Start vPostgres service for the changes to be effective:
service-control --stop vmware-vpostgres
service-control --start vmware-vpostgres
- Connect to the database as a postgres user. It does not ask for a password because we have changed the method in pg_hba.conf file to trust:
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres
- Change the postgres user password with the password copied from the first step (from file /etc/vmware-vpx/embedded_db.cfg):
ALTER USER postgres PASSWORD 'new_password';
\q (to exit from postgres)
- Revert the changes made on pg_ha.conf file, edit /storage/db/vpostgres/pg_hba.conf using VI editor and change trust to md5 for below values:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
- Save and close the pg_hba.conf file.
- Stop and Start vPostgres service for the changes to be effective:
service-control --stop vmware-vpostgres
service-control --start vmware-vpostgres
- Connect to the database as a postgres user to verify the new password. If password is set properly, it will not ask for a password as it will take the password from .pgpass file:
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres
\q (to exit from postgres)
- Continue with the upgrade process.