Support Questions
Find answers, ask questions, and share your expertise

Can't authenticate user "ambari" in ambari-server setup in PostgreSQL

Can't authenticate user "ambari" in ambari-server setup in PostgreSQL

Contributor

I am setting up a single-node Hortonworks stack. I am stuck in the part where I am setting up my ambari-server, using my PostgreSQL database (not default, not embedded).

I also intend to use this same PostgreSQL instance for Hive and Oozie.

After following the instructions from here:

https://docs.hortonworks.com/HDPDocuments/Ambari-2.2.2.0/bk_ambari_reference_guide/content/_using_am...

https://docs.hortonworks.com/HDPDocuments/Ambari-2.2.2.0/bk_ambari_reference_guide/content/_using_hi...

https://docs.hortonworks.com/HDPDocuments/Ambari-2.2.2.0/bk_ambari_reference_guide/content/_using_oo...

Here's how I named my database, user and schema:

ambari, ambari, ambari

hive, hive

oozie, oozie

This is how I configured my /var/lib/pgsql/data/pg_hba.conf file:

# Default
local 	all 	all 	peer
host 	all 	all 	127.0.0.1/32 	ident

# added settings
local  	all  	ambari 	md5
host  	all   	ambari 	0.0.0.0/0  	md5
host  	all   	ambari 	::/0 		md5
host	oozie	oozie	<my-host-ip>/0	md5
host	hive	hive	<my-host-ip>/0	md5

I run this, for Hive and Oozie:

$ ambari-server setup --jdbc-db=postgres --jdbc-driver=/usr/share/java/postgresql-jdbc.jar

Then for the actual Ambari setup

$ ambari-server setup

Enter advanced database configuration [y/n]? y
...
Enter choice (1): 4
Hostname (localhost): <my-fqdn-host-name>
Port (5432):
Database name (ambari):
Postgres schema (ambari):
Username (ambari):
Enter Database Password (bigdata) : <my-ambari-password>

However, I can't start the ambari-server, as I get this from /var/log/ambari-server/ambari-server.log on a number of lines:

Internal Exception: org.postgresql.util.PSQLException: FATAL: Ident authentication failed for user "ambari"

Although I am sure that my password is correct, and I can even connect using

$ psql -h <my-fqdn-host-name> -U ambari -d ambari -W
password: <my-ambari-password>
$ psql -h <my-host-ip> -U ambari -d ambari -W
password: <my-ambari-password>

However, I can't connect with

$ psql -h localhost -U ambari -d ambari -W
password: <my-ambari-password>
psql: FATAL: Ident authentication failed for user "ambari"
$ psql -h 127.0.0.1 -U ambari -d ambari -W
password: <my-ambari-password>
psql: FATAL: Ident authentication failed for user "ambari"

And I get the same error as what I get from /var/log/ambari-server/ambari-server.log. I suspect that ambari-server setup is connecting via localhost, that's why I get the same error.

Can you tell what's wrong with my configuration with Ambari and/or Postgres?

3 REPLIES 3

Re: Can't authenticate user "ambari" in ambari-server setup in PostgreSQL

Mentor

@J. D. Bacolod

Look at this document and also this

Select n at Enter advanced database configuration to use the default, embedded PostgreSQL database for Ambari. The default PostgreSQL database name is ambari. The default user name and password are ambari/bigdata.

Hope that helps

Re: Can't authenticate user "ambari" in ambari-server setup in PostgreSQL

Contributor

Sorry, that is not the answer, I specified on my question that I'm not using the embedded PostgreSQL (option 1), but the advanced configuration.

Re: Can't authenticate user "ambari" in ambari-server setup in PostgreSQL

Expert Contributor

I had the same problem. I tried to figure out almost a day long and then I accdentally realized my amazing mistake. I had always changed wrong "pg_hba.conf" and "postgresql.conf". Following command led me realized my mistake:

[root@myserver ~]# find / -name "pg_hba.conf"
/var/lib/pgsql/data/pg_hba.conf
/var/lib/pgsql/9.6/data/pg_hba.conf

There are two pg_hba.conf and postgresql.conf. I modified to pg_hba.conf:

local   all             all                                     trust
# IPv4 local connections:
host    all             all             0.0.0.0/0            trust

And then /var/lib/pgsql/9.6/data/postgresql.conf:

listen_addresses = '*'

The result is amazing :)

[root@myserver~]# ambari-server start
Using python  /usr/bin/python
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
Ambari database consistency check started...
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
Waiting for server start...............................
Server started listening on 8080


DB configs consistency check: no errors and warnings were found.
Ambari Server 'start' completed successfully.