For Ubuntu
The commands to configure Postgres database are different for CentOS, Debian, and Ubuntu. Refer to the respective section to view the procedure for your platform.
-
Install the supported version of Postgres using the following commands:
echo deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main > /etc/apt/sources.list.d/postgresql.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
apt-get install postgresql-9.6
For more information about the supported version of Postgres, see the DAS Support Matrix.
-
To make Postgres accessible to the DAS webapp and the DAS event processor
host:
-
Open the
pg_hba.conf
file for editing.vi /var/lib/postgresql/9.6/main/pg_hba.conf
-
Add lines similar to the following lines:
local all <dbuser> md5 host all <dbuser> 0.0.0.0/0 md5 host all <dbuser> ::/0 md5 local all postgres ident
-
Open the
postgresql.conf
file for editing.vi /var/lib/postgresql/9.6/main/postgresql.conf
-
Add, update, or uncomment the
listen_addresses
line as follows:listen_addresses = '*'
-
Open the
-
Start the Postgres database by running the following command as a Postgres
user:
/usr/lib/postgresql/9.6/bin/pg_ctl start -D /var/lib/postgresql/9.6/main/
-
Create roles in Postgres by running the following commands as a Postgres
user:
psql -tc "SELECT 1 FROM pg_database WHERE datname = <dbuser>" | grep 1 || ( psql -c "CREATE ROLE <dbuser> WITH LOGIN PASSWORD <dbpass>;" && psql -c "ALTER ROLE <dbuser> SUPERUSER;" && psql -c "ALTER ROLE <dbuser> CREATEDB;" && psql -c "CREATE DATABASE <dbuser>;" && psql -c "GRANT ALL PRIVILEGES ON DATABASE <dbuser> TO <dbuser>;")
Replace
<dbuser>
with the database username/database name and<dbpass>
with the database password.NoteThe database user and database name must be the same. It should be the one that is used as the database username in the DAS configuration on Ambari.