-
Notifications
You must be signed in to change notification settings - Fork 80
/
TASK_50-Install_and_Configure_PostgreSQL.sh
128 lines (80 loc) · 5.51 KB
/
TASK_50-Install_and_Configure_PostgreSQL.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
-----------------------------------------------------------------------------------------------------------------
Start 2020-11-22 00:29:39
Finished 2020-11-22 00:52:26
-----------------------------------------------------------------------------------------------------------------
TASK 50 - Install and Configure PostgreSQL
** This is a repeat task. This was Task 36, finished last 2020-09-09
REQUIREMENTS:
TASK 36 - Install and Configure PostgreSQL
REQUIREMENTS:
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_cap and set its password to dCV3szSGNA.
c. Create a database kodekloud_db10 and grant full permissions to user kodekloud_cap on this database.
d. Make appropriate settings to allow all local clients (local socket connections) to connect to the kodekloud_db10 database through kodekloud_cap 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 sudo user.
-----------------------------------------------------------------------------------------------------------------
CONTENT:
I. REFERENCES
II. STEPS - SUMMARY
III. STEPS - BREAKDOWN
-----------------------------------------------------------------------------------------------------------------
I. REFERENCES
-----------------------------------------------------------------------------------------------------------------
II. STEPS - SUMMARY
# 1. SSH into the jump server, Storage Server, App server 1, App server 2, and App server 3 and switch
# to root.
# 2. Install postgresql and initialize.
# Enable, start, and then verify status of postgresql service.
# 3. Sign-in to the postgresql db. Create the required user and database, and then grant all
# privileges (for the database) to the user. Exit afterwards.
# 4. Modify '/var/lib/pgsql/data/postgresql.conf' and uncomment the 'listen_addresses'.
# Afterwards, modify '/var/lib/pgsql/data/pg_hba.conf' to change methods of local and host to 'md5'
# 5. Restart postgresql and verify status of the service.
# 6. Test by accessing the created database using the created user.
-----------------------------------------------------------------------------------------------------------------
III. STEPS - BREAKDOWN
# 1. SSH into the jump server, Storage Server, App server 1, App server 2, and App server 3 and switch
# to root.
sshpass -p '******' ssh -o StrictHostKeyChecking=no peter@172.16.239.10
sudo su -
******
# 2. Install postgresql and initialize.
# Enable, start, and then verify status of postgresql service.
yum install -y postgresql-server postgresql-contrib
postgresql-setup initdb
systemctl enable postgresql && systemctl start postgresql && systemctl status postgresql
# 3. Sign-in to the postgresql db. Create the required user and database, and then grant all
# privileges (for the database) to the user. Exit afterwards.
sudo -u postgres psql
create user kodekloud_cap with encrypted password 'dCV3szSGNA';
create database kodekloud_db10 owner kodekloud_cap;
grant all privileges on database kodekloud_db10 to kodekloud_cap ;
exit
# 4. Modify '/var/lib/pgsql/data/postgresql.conf' and uncomment the 'listen_addresses'.
# Afterwards, modify '/var/lib/pgsql/data/pg_hba.conf' to change methods of local and host to 'md5'
vi /var/lib/pgsql/data/postgresql.conf
listen_addresses = 'localhost' # what IP address(es) to listen on
vi /var/lib/pgsql/data/pg_hba.conf
host all all 0.0.0.0/0 md5
local all all 0.0.0.0/0 md5
# 5. Restart postgresql and verify status of the service.
sudo systemctl restart postgresql
systemctl enable postgresql && systemctl start postgresql && systemctl status postgresql
# 6. Test by accessing the created database using the created user.
psql -U kodekloud_cap -d kodekloud_db10 -h 127.0.0.1 -W
psql -U kodekloud_cap -d kodekloud_db10 -h localhost -W
(enter password: dCV3szSGNA)
-----------------------------------------------------------------------------------------------------------------
############################################################################################################
####### ### ### ####### ####### ######### ####### ####### ### ###
#### #### ### ### #### #### #### #### ######### #### #### #### #### ### ###
### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
### ### ### ### ### ### ### ### ### ###
####### ### ### ### ### ######## ####### ####### ### ###
####### ### ### ### ### ######## ####### ####### ### ###
### ### ### ### ### ### ### ### ### ###
### ### ### ### ### ### ### ### ### ### ### ### ###
######### ######### #### #### #### #### ######### ######### ######### ### ###
####### ####### ####### ####### ######### ####### ####### ### ###
############################################################################################################