oikonomiyaki
oikonomiyaki

Reputation: 7951

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

I am setting up the Hortonworks Hadoop stack on a single instance RHEL 7 node. I am stuck in the part where I am setting up my ambari-server, using my PostgreSQL 9.2.15 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_ambari_with_postgresql.html

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

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

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?

Upvotes: 0

Views: 2562

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246453

The problem is your pg_hba.conf file.

It is parsed from top to bottom, and the first matching line is used.
In your case, the line chosen is

host    all     all     127.0.0.1/32    ident

(you seem to connect from localhost) which is not what you want.

Either remove that line or move it to the end of the file.

Upvotes: 2

Related Questions