Configuring a PostgreSQL Database for Ranger or Ranger KMS
Complete the following steps to configure a PostgreSQL database instance for Ranger or Ranger KMS.
Configuring a PostgreSQL Database for Ranger or Ranger KMS on RHEL7/Centos7
-
Run the following command to install PostgreSQL server:
sudo yum install postgresql-server
-
Initialize the Postgres database and start PostgreSQL:
sudo postgresql-setup initdb sudo systemctl start postgresql
-
Optional: Configure PostgreSQL to start on boot:
sudo systemctl enable postgresql
-
Update the
postgresql.conf
file, which is usually found in/var/lib/pgsql/data
or/var/lib/postgresql/data
:- Uncomment and change
#listen_addresses = 'localhost'
tolisten_addresses = '*'
- Uncomment the
#port =
line and specify the port number (the default is 5432) - Optional: Uncomment and change
#standard_conforming_strings=
tostandard_conforming_strings = off
- Uncomment and change
-
Update the
pg_hba.conf
file, which is usually found in/var/lib/pgsql/data
or/etc/postgresql/<version>/main
:-
Add the following line to allow connection to the Ranger database from any host:
host ranger rangeradmin 0.0.0.0/0 md5
-
-
Restart PostgreSQL:
sudo systemctl restart postgresql
-
The PostgreSQL database administrator should be used to create the Ranger databases.
The following series of commands could be used to create the rangeradmin user and grant
it adequate privileges. Be sure to replace 'password' with a strong password.
echo "CREATE DATABASE ranger;" | sudo -u postgres psql -U postgres echo "CREATE USER rangeradmin WITH PASSWORD 'password';" | sudo -u postgres psql -U postgres echo "GRANT ALL PRIVILEGES ON DATABASE ranger TO rangeradmin;" | sudo -u postgres psql -U postgres
-
Install the PostgreSQL JDBC driver. If you would like to use the
PostgreSQL JDBC driver version shipped with the OS repositories, run
the following command:
You can also download the JDBC driver from the official PostgreSQL JDBC Driver website – https://jdbc.postgresql.org/.yum install postgresql-jdbc*
-
Rename the Postgres JDBC driver
.jar
file topostgresql-connector-java.jar
and copy it to the/usr/share/java
directory. The following copy command can be used if the Postgres JDBC driver.jar
file is installed from the OS repositories:cp /usr/share/java/postgresql-jdbc.jar /usr/share/java/postgresql-connector-java.jar
-
Confirm that the .jar file is in the Java share directory:
ls /usr/share/java/postgresql-connector-java.jar
-
Change the access mode of the .jar file to 644:
chmod 644 /usr/share/java/postgresql-connector-java.jar