Before using Hive with a new or existing PostgrSQL database; obtain the appropriate
driver and .jar files, and create a Hive user with sufficient permissions.
Determine the appropriate database version and obtain the
release drivers and .jar file.
-
On the Ambari Server host, stage the appropriate PostgreSQL connector for later
deployment.
-
On the Ambari Server host, Download the PostgreSQL JDBC Driver from
PostgreSQL.
-
Confirm that .jar is in the Java share directory.
ls /usr/share/java/postgresql-jdbc.jar
-
Change the access mode of the .jar file to 644.
chmod 644 /usr/share/java/postgresql-jdbc.jar
-
Execute the following command:
ambari-server setup --jdbc-db=postgres
--jdbc-driver=/usr/share/java/postgresql-jdbc.jar
-
Create a user for Hive and grant it permissions.
using the PostgreSQL database admin utility:
echo "CREATE DATABASE [HIVE_DATABASE];" | psql -U postgres
echo "CREATE USER [HIVE_USER] WITH PASSWORD '[HIVE_PASSWORD]';" | psql -U postgres
echo "GRANT ALL PRIVILEGES ON DATABASE [HIVE_DATABASE] TO [HIVE_USER];" | psql -U postgres
Where [HIVE_USER] is the Hive user name,
[HIVE_PASSWORD] is the Hive user password and
[HIVE_DATABASE] is the Hive database name.