0% found this document useful (0 votes)
11 views2 pages

Quiz 1

Uploaded by

bprak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Quiz 1

Uploaded by

bprak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

quiz 1

-- PostgreSQL Installation --
sudo apt -y update
sudo apt -y install nano wget

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key


add -

echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |


sudo tee /etc/apt/sources.list.d/pgdg.list

sudo apt update


sudo apt -y install postgresql-12 postgresql-client-12
sudo /etc/init.d/postgresql start
sudo /etc/init.d/postgresql status
sudo systemctl is-enabled postgresql

-- Configuring Master --

su postgres

psql

CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD


'giveA5tr0n9Pa55w0rD';
ALTER ROLE replication CONNECTION LIMIT -1;

CREATE DATABASE dbbunlong;


CREATE USER bunlongprak WITH ENCRYPTED PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE dbbunlong to bunlongprak ;

exit
exit

nano /etc/postgresql/12/main/postgresql.conf

listen_addresses = '*' Master IP


wal_level = replica
max_wal_senders = 10
wal_keep_segments = 64

nano /etc/postgresql/12/main/pg_hba.conf

Change ipv4: 0.0.0.0/0

Change ipv6: /0

+ append this at the end


host replication replication SlaveIp/0 md5

sudo /etc/init.d/postgresql restart


sudo /etc/init.d/postgresql status

-- Configuring Slave –

sudo /etc/init.d/postgresql stop


sudo /etc/init.d/postgresql status
nano /etc/postgresql/12/main/postgresql.conf

listen_addresses = '*' SlaveIp


wal_level = replica
max_wal_senders = 10
wal_keep_segments = 64
hot_standby = on

nano /etc/postgresql/12/main/pg_hba.conf

Change ipv4: 0.0.0.0/0

Change ipv6: /0

host replication replication MasterIP/0 md5

cd /var/lib/postgresql/12/main/
sudo rm -rfv *
sudo su postgres
pg_basebackup -h MasterIP -U replication -p 5432 -D /var/lib/postgresql/12/main/ -
Fp -Xs -P -R

It will prompt for a password for `replication` PostgreSQL user, that is in our
case giveA5tr0n9Pa55w0rD.

sudo /etc/init.d/postgresql start

You might also like