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_joy and set its password to HyAGFRVNr3.
c. Create a database kodekloud_db8 and grant full permissions to user kodekloud_joy on this database.
d. Make appropriate settings to allow all local clients (local socket connections) to connect to the kodekloud_db8 database through kodekloud_joy 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.
Sample Answer:
#login to DB server
ssh <user>@<<DB-server-IP>
#switch to root user
sudo su
#install postgresql
yum -y install postgresql-server postgresql-contrib
#initiate DB setup
postgresql-setup initdb
#enable and start postgresql servcie
systemctl enable postgresql
systemctl start postgresql
#let's Create user, database, and grant permission
sudo -u postgres psql
CREATE USER <user_from_your question> WITH PASSWORD '<password_from_your question>';
CREATE <DB_from_your question>;
GRANT ALL PRIVILEGES ON DATABASE "<DB_from_your question>" to <user_from_your question>;
type \q to exit from pgsql
#now do the configuration changes
vi /var/lib/pgsql/data/postgresql.conf
Uncomment below line
listen_addresses = 'localhost'
#another config change
vi /var/lib/pgsql/data/pg_hba.conf
#Go to bottom of the config and edit as below
local all all md5
host all all 127.0.0.1/32 md5
#restart psql service and check status
systemctl restart postgresql
systemctl status postgresql
#Testing
psql -U <user_from your _question> -d <DB_from_your_question> -h 127.0.0.1 -W
psql -U <user_from your _question> -d <DB_from_your_question> -h localhost -W
*Please comment on this post if you are facing any issues in the steps, also provide your feedback in the comments :)
Note: **The Question copied it for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.
Thanks for the tip
ReplyDeleteBelow can be mentioned as modified since those entries are already exist , people may get confused whether to add or modify
#Go to bottom of the config and edit as below
local all all md5
host all all 127.0.0.1/32 md5