Install and Configure Postgresql
The Nautilus application development team has shared that they are planning to deploy one newly developed application on Nautilus infra in Stratos DC. The application uses PostgreSQL database, so as a pre-requisite we need to set up PostgreSQL database server as per requirements shared below:
a. Install and configure PostgreSQL database on Nautilus database server.
b. Create a database user kodekloud_rin and set its password to TmPcZjtRQx.
c. Create a database kodekloud_db10 and grant full permissions to user kodekloud_rin on this database.
d. Make appropriate settings to allow all local clients (local socket connections) to connect to the kodekloud_db10 database through kodekloud_rin user using md5 method (Please do not try to encrypt password with md5sum).
e. At the end its good to test the db connection using these new credentials from root user or server's sudo user.
✔ and Do Task Again
Click on Solution:
NOTE:
Change"kodekloud_db10" to kodekloud_gem
and Pssword AS Per Task
Login to database server
ssh peter@stdb01
Then login as root
sudo su -
Then install postgresql
yum install postgresql-server postgresql-contrib -y
postgresql-setup initdb
systemctl enable postgresql
sudo systemctl start postgresql
systemctl status postgresql
Enter into postgresql database AS
sudo -u postgres psql postgres
Create user, database, and grant permission
CREATE USER kodekloud_gem WITH PASSWORD 'LQfKeWWxWD';
CREATE DATABASE kodekloud_db10;
GRANT ALL PRIVILEGES ON DATABASE "kodekloud_db10" to kodekloud_gem;
\q to exit from postgresql
Then set the config for local
sudo vi /var/lib/pgsql/data/pg_hba.conf
Go to bottom of the config and edit
local all all md5
host all all 127.0.0.1/32 md5
Change peer,ident with md5
Next open another config
sudo vi /var/lib/pgsql/data/postgresql.conf
Uncomment listen_address=localhost
Then restart
sudo systemctl restart postgresql
sudo systemctl status postgresql.service
Finally Check
psql -U kodekloud_aim -d kodekloud_db8 -h 127.0.0.1 -W ## Change name according to question
#### for the test on mode postgres u have
## \conninfo
## \l
## \dg+
## \q # to quit
psql -U kodekloud_gem -d kodekloud_db10 -h localhost -W