218
edits
Note: Currently new registrations are closed, if you want an account Contact us
(update gitlab setup section) |
(→Backup: update for postgresql 11) |
||
Line 45: | Line 45: | ||
==Backup== | ==Backup== | ||
Backup server is provided by Manu. Running on debian gnu/linux | Backup server is provided by Manu (KVM virtual machine with 100 GB storage and 1 GB ram). Running on debian gnu/linux 10 buster. | ||
Documentation: https://linuxhint.com/setup_postgresql_replication/ | |||
===Slave configuration: Step 1=== | ===Slave configuration: Step 1=== | ||
Install postgresql and rsync | Install postgresql and rsync | ||
# apt-get install postgresql-contrib- | # apt-get install postgresql-contrib-11 rsync | ||
Check postgresql server is running | |||
# su postgres -c psql | |||
Make sure en_US.UTF-8 locale is available | Make sure en_US.UTF-8 locale is available | ||
Line 59: | Line 65: | ||
# su - postgres | # su - postgres | ||
$ ssh-keygen | $ ssh-keygen -t ed25519 | ||
Now copy /var/lib/postgresql/.ssh/ | Now copy /var/lib/postgresql/.ssh/id_ed25519.pub to master postgres users' /var/lib/postgresql/.ssh/authorized_keys | ||
Stop postgresql before changing any configuration | Stop postgresql before changing any configuration | ||
# systemctl stop postgresql@11-main | |||
cd /etc/postgresql/ | as postgres user | ||
$ su - postgres | |||
$ cd /etc/postgresql/11/main | |||
Open the postgres configuration file | Open the postgres configuration file | ||
nano postgresql.conf | $ nano postgresql.conf | ||
Set the following configuration options in the postgresql.conf file | Set the following configuration options in the postgresql.conf file | ||
listen_addresses = 'localhost,192.168.0.115' | listen_addresses = 'localhost,192.168.0.115' | ||
port=5432 | port=5432 | ||
wal_level = | wal_level = replica | ||
max_wal_senders = 1 | |||
archive_mode = on | archive_mode = on | ||
archive_command = 'cd .' | archive_command = 'cd .' | ||
hot_standby = on | hot_standby = on | ||
Line 96: | Line 105: | ||
Allow slave to connect to master using the user just created. | Allow slave to connect to master using the user just created. | ||
$ cd /etc/postgresql/ | $ cd /etc/postgresql/11/main | ||
$ nano pg_hba.conf | $ nano pg_hba.conf | ||
Line 112: | Line 121: | ||
listen_addresses = 'localhost,213.167.243.152' | listen_addresses = 'localhost,213.167.243.152' | ||
port=5432 | port=5432 | ||
wal_level = | wal_level = replica | ||
max_wal_senders = 1 | |||
archive_mode = on | archive_mode = on | ||
archive_command = 'cd .' | archive_command = 'cd .' | ||
hot_standby = on | hot_standby = on | ||
Now, to activate your changes, reload the postgresql server | Now, to activate your changes, reload the postgresql server | ||
# systemctl reload postgresql@11-main | |||
You may need to restart it via systemd, | You may need to restart it via systemd, | ||
Line 129: | Line 138: | ||
psql -c "select pg_start_backup('initial_backup');" | psql -c "select pg_start_backup('initial_backup');" | ||
rsync -cva -e 'ssh -p 12022' --inplace --exclude=*pg_xlog* /var/lib/postgresql/ | rsync -cva -e 'ssh -p 12022' --inplace --exclude=*pg_xlog* /var/lib/postgresql/11/main/ 62.210.83.200:/var/lib/postgresql/11/main/ | ||
psql -c "select pg_stop_backup();" | psql -c "select pg_stop_backup();" | ||
Open 5432 port in the firewall | |||
# ufw allow from 62.210.83.200 to any port 5432 proto tcp | |||
===Slave Configuration: Step 2=== | ===Slave Configuration: Step 2=== | ||
Line 140: | Line 153: | ||
Start the slave server | Start the slave server | ||
# systemctl start postgresql@11-main | |||
===Replication Status=== | ===Replication Status=== |