Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

WIP:

cat << 'EOL' >postgresql_replication_master.sh
systemctl stop postgresql
psqlver=10
replicationuser=rep_user
repuserpwd=password
su postgres
psql -c "CREATE ROLE $replicationuser WITH REPLICATION PASSWORD ‘$repuserpwd’ LOGIN;"

#wal_level = replica
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep wal_level 
sed -i '/wal_level/s/^#//g' /etc/postgresql/$psqlver/main/postgresql.conf 
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep wal_level 

#synchronous_commit = on
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep synchronous_commit
sed -i '/synchronous_commit/s/^#//g' /etc/postgresql/$psqlver/main/postgresql.conf 
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep synchronous_commit

#max_wal_senders = 10
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep max_wal_senders
sed -i '/max_wal_senders/s/^#//g' /etc/postgresql/$psqlver/main/postgresql.conf 
#sed -i -e 's/###/10/g' /etc/postgresql/$psqlver/main/postgresql.conf
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep max_wal_senders

#wal_keep_segments = 10
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep wal_keep_segments
sed -i '/wal_keep_segments/s/^#//g' /etc/postgresql/$psqlver/main/postgresql.conf 
sed -i -e 's/0/10/g' /etc/postgresql/$psqlver/main/postgresql.conf
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep wal_keep_segments

#synchronous_standby_names = '*'
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep synchronous_standby_names
sed -i '/synchronous_standby_names/s/^#//g' /etc/postgresql/$psqlver/main/postgresql.conf 
sed -i -e "s/synchronous_standby_names = ''/synchronous_standby_names = '*'/g" /etc/postgresql/$psqlver/main/postgresql.conf
cat /etc/postgresql/$psqlver/main/postgresql.conf | grep synchronous_standby_names

#host replication [replication user] [allowed IP addresses] trust
cat /etc/postgresql/$psqlver/main/pg_hba.conf | grep replication
#sed -i '/host    replication     all             127.0.0.1/32            md5/s/^/#/g' /etc/postgresql/$psqlver/main/pg_hba.conf 
#sed -i '/host    replication     all             ::1/128                 md5/s/^/#/g' /etc/postgresql/$psqlver/main/pg_hba.conf 
echo "host    replication     $replicationuser         192.168.1.1/24            trust" >> /etc/postgresql/$psqlver/main/pg_hba.conf
cat /etc/postgresql/$psqlver/main/pg_hba.conf | grep replication

systemctl start postgresql
netstat -nltp | grep postgre
EOL
chmod +x postgresql_replication_master.sh
./postgresql_replication_master.sh
  • No labels