Skip to main content
Gophalr
Gold ⭐️
May 8, 2020 4:53 PM UTC
Solved

Postgresql upgrade from 9.2 to 9.6 on Ambari 2.7 and HDP3.0

Hi,

I'm trying to update the PostgreSQL from 9.2.24 to 9.6. I tried the following
Took backup of the DB with following command.

pg_dumpall > outputfile

Once the backup is done I stopped the service and Rename the pgsql directory under /var/lib/pgsql/

Updated the postgres with the following command :

yum install postgresql96-server postgresql96.

After the installation the new directory got created /var/lib/pgsql/9.6/. I ran the initdb command to create the cluster. Restored the old  pg_hba.conf and postgresql.conf files from the backup directory. Started the postgres service with the following command:

/usr/pgsql-9.6/bin/pg_ctl start -D /var/lib/pgsql/9.6/data

Once the service was up I restored the DB with the following command:
/usr/pgsql-9.6/bin/psql -d postgres -f outputfile

The DB restoration done but still while starting the ambari server  I'm getting the error  Ident authentication failed for user "ambari"

 

I have the doubt that is the upgrade properly done I mean the ambari server is using the 9.6 postgresql version that we installed. I have a doubt that still its using the old version when I give yum list postgresql it shows only the 9.2.4 version as installed. 

Can anyone help on this issue I fighting with this for 2 days.

Gophalr
GophalrAnswer
Gold ⭐️
May 12, 2020 9:30 AM UTC

Hi,

 

I'm able to solve the issue by running the ambari-server setup command again and select the 4 option instead of embedded DB. That solved the issue. Now I'm able to start the service without any issue.

 

Thanks,

GophalRaj

8 replies

rachid-berkane
Gold ⭐️
May 9, 2020 12:54 AM UTC

your problem is probably related to 

/var/lib/pgsql/<PGSQL_VERSION>/data/pg_hba.conf

 

please check you did not restore pg_hba config file to old postgresql version DIR in /var/lib/psql

 

if it's not the case

please try to allow any source connections (to eliminate this possible cause)

 

for ex by adding the following in the end of pg_hba 

vi /var/lib/pgsql/<NEW_POSTGRES_VERSION>/data/pg_hba.conf
host   all   all   0.0.0.0/0  md5

also check bellow file (for ex if you use many network interfaces in your host/VM):

vi /var/lib/pgsql/<NEW_POSTGRES_VERSION>/data/postgresql.conf
listen_addresses = '*'

and restart postgres 

Translate
Gophalr
GophalrAuthor
Gold ⭐️
May 9, 2020 7:39 AM UTC

Thanks for the response.

I tried starting the service but still I'm getting the following error while starting postgresql.

 

/usr/pgsql-9.6/bin/pg_ctl start -D /var/lib/pgsql/9.6/data/
server starting
-bash-4.2$ LOG: skipping missing configuration file "/var/lib/pgsql/9.6/data/postgresql.auto.conf"
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.6.17.

 

 

 

Translate
rachid-berkane
Gold ⭐️
May 9, 2020 9:43 AM UTC

 

after you renamed old installation pg DIR and created new one using initDb (in old installation DIR) a pg_upgrade step needs to be done (https://www.postgresql.org/docs/9.6/pgupgrade.html)

 

for ex ( with /usr/pgsql-9.6 as your new pgsql9.6 bin DIR installation path and /usr/bin/ as olg binDIR)

/usr/pgsql-9.6/bin/pg_upgrade --old-datadir /var/lib/pgsql/data/ --new-datadir /var/lib/pgsql/9.6/data/ --old-bindir /usr/bin/ --new-bindir /usr/pgsql-9.6/bin/

 

restart postgres after pg_upgrade is done

 

if (psql --version) gives old version update PATH

also systemd unit files etc... and pgsql_profile (/var/lib/pgsql/.pgsql_profile) / bash_profile  /etc/ files etc...

 

Translate