X-Git-Url: http://git.rot13.org/?p=edozvola;a=blobdiff_plain;f=edozvola-dpavlin.txt;h=b8ab38b18b7842dfb62d142dce70fe79be3caf15;hp=c248649b335990d101b40b1b007b287e30591fde;hb=3fd8e6627e01f259fdeeef08ba4b764780a79e98;hpb=6100bbebebfc8e9a8f8bf606b7b03cfc1dd74043 diff --git a/edozvola-dpavlin.txt b/edozvola-dpavlin.txt index c248649..b8ab38b 100644 --- a/edozvola-dpavlin.txt +++ b/edozvola-dpavlin.txt @@ -8,6 +8,8 @@ git config --global user.name "Dobrica Pavlinusic" git commit -m base +PostgreSQL replikacija, wal shipping, streaming, host standby + https://www.postgresql.org/docs/9.6/static/warm-standby.html @@ -110,7 +112,7 @@ https://www.postgresql.org/docs/9.6/static/continuous-archiving.html [root@edozvola-db-01 ~]# vi /var/lib/pgsql/9.6/data/postgresql.conf -wal_level = replica +wal_level = replica # same as hot_standby # https://www.postgresql.org/docs/9.6/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit = on @@ -208,7 +210,7 @@ da bi svi podaci zavrsili na slave-u, na masteru je dobro izvrsiti komandu check - +# recovery.conf [root@edozvola-db-02 ~]# cat recovery.conf standby_mode = 'on' @@ -238,40 +240,30 @@ archive_cleanup_command = 'pg_archivecleanup /shared/pgsql %r' [root@edozvola-db-01 pgsql]# cat create-pgsql-slave.sh #!/bin/sh -e - # WARNING: this script depends that two database nodes have IPs which and in x1 and x2 # tr 12 21 does swap from currnet node number/ip to other one! - test "`whoami`" != "postgres" && echo "$0 needs to be run as postgres user!" && exit 1 - here=`hostname -s` there=`hostname -s | tr 12 21` - my_ip=`ip addr | grep 10.200.1. | sed 's/^.*\(10\.200\.1\.[0-9]*\)\/.*$/\1/'` other_ip=`echo $my_ip | tr 12 21` - echo "Create slave on $here $my_ip using data from master on $there $other_ip" echo "[enter] to start" read - #systemctl stop postgresql-9.6.service || true /usr/pgsql-9.6/bin/pg_ctl --pgdata=/var/lib/pgsql/9.6/data stop || true - echo "select pg_start_backup('slave')" | ssh $there psql - rsync -rav --delete --exclude pg_xlog $there:/var/lib/pgsql/9.6/data/ /var/lib/pgsql/9.6/data/ - echo "select pg_stop_backup()" | ssh $there psql - test -e /var/lib/pgsql/9.6/data/recovery.done || ( echo "ERROR: no recovery.done !" && exit 1 ) cat /var/lib/pgsql/9.6/data/recovery.done | sed -e s/$my_ip/$other_ip/ > /var/lib/pgsql/9.6/data/recovery.conf @@ -286,4 +278,3 @@ cat /var/lib/pgsql/9.6/data/recovery.done | sed -e s/$my_ip/$other_ip/ > /var/li -hot_standby?