-
Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
-
Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
-
Update the package lists:
sudo apt-get update
-
Install PostgreSQL:
sudo apt-get -y install postgresql
- Open the PostgreSQL port (default, 5432) in the firewall.
-
Configure PostgreSQL to accept remote connections:
a. Go to this location: /etc/postgresql/12/main
Note: /12/ is the version number; in your case, if you have installed a different version, the path will reflect that.
b. Edit the postgresql.conf file and replace the line:
#listen_addresses = 'localhost'
with
listen_addresses = '*'
Note: * is for any IP. Alternatively, you can add IPs delimited by commas.
c. Edit the pg_hba.conf file and add the following lines at the end:
host all all 0.0.0.0/0 md5
host all all ::/0 md5
-
Restart the PostgreSQL server:
sudo service postgresql restart
-
Connect to the PostgreSQL server:
sudo -u postgres psql
-
(Optional) Change the password of the postgres user (by default it has no password):
ALTER ROLE postgres WITH PASSWORD 'password';
-
Create Databases and Roles:
CREATE ROLE dc_user LOGIN PASSWORD 'dc_password';
ALTER USER dc_user WITH CREATEDB;
CREATE DATABASE dc_db;
GRANT ALL PRIVILEGES ON DATABASE dc_db TO dc_user;
CREATE ROLE uam_user LOGIN PASSWORD 'uam_password';
ALTER USER uam_user WITH CREATEDB;
CREATE DATABASE uam_db;
GRANT ALL PRIVILEGES ON DATABASE uam_db TO uam_user;
CREATE ROLE quartz_user LOGIN PASSWORD 'quartz_password';
ALTER USER quartz_user WITH CREATEDB;
CREATE DATABASE quartz_db;
GRANT ALL PRIVILEGES ON DATABASE quartz_db TO quartz_user;
CREATE ROLE notification_user LOGIN PASSWORD 'notification_password';
ALTER USER notification_user WITH CREATEDB;
CREATE DATABASE notification_db;
GRANT ALL PRIVILEGES ON DATABASE notification_db TO notification_user;
CREATE ROLE audit_user LOGIN PASSWORD 'audit_password';
ALTER USER audit_user WITH CREATEDB;
CREATE DATABASE audit_db;
GRANT ALL PRIVILEGES ON DATABASE audit_db TO audit_user;
Install PostgreSQL on Ubuntu (for single/multiple nodes with an external DB)
Please sign in to leave a comment.
Comments
0 comments