Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Unable to create hive database using Ambari embedded postgres database

Unable to create hive database using Ambari embedded postgres database

New Contributor

I installed Ambari as root user with its default/embedded Postgresql db and would like to use it to create hive and oozie databases. Ambari was installed successfully and postgress is running. But when running the following command to create hive database as root user

echo "CREATE DATABASE hive;" | psql -U postgres

I get the following error:

psql: FATAL:  Peer authentication failed for user "postgres"

Here is /var/lib/pgsql/data/pg_hba.conf

local all postgres peer
# IPv4 local connections:
host    all   postgres             127.0.0.1/32            ident
local  all  ambari,mapred md5
host  all   ambari,mapred 0.0.0.0/0  md5
host  all   ambari,mapred ::/0 md5


3 REPLIES 3

Re: Unable to create hive database using Ambari embedded postgres database

Super Mentor

@Zaili Xu

Please try to do "su - postgres" first.

Example:

# su - postgres
Last login: Thu Feb 22 00:52:08 UTC 2018 on pts/0


$ echo "CREATE DATABASE hive;" | psql -U postgres
CREATE DATABASE

.

Highlighted

Re: Unable to create hive database using Ambari embedded postgres database

New Contributor

Thank you, Jay, for the prompt response. I used the following cmd to to run from script and it worked

cmd="echo ${sql}|psql -U postgres"
su - postgres -c "$cmd"

Re: Unable to create hive database using Ambari embedded postgres database

Super Mentor

@Zaili Xu

Good to know your issue is resolved.

The actual cause of the following error can be solved by using "su - postgres". after that you can execute whatever command you want. The Key to fix the following error us to use "su - postgres"

psql: FATAL:  Peer authentication failed for user "postgres"
Don't have an account?
Coming from Hortonworks? Activate your account here