As you can see from your question, you are trying to create a SLAVE server from your master.
1 - Install RSYNC on your master and slave server.
If it is CentOS / Fedora / Red hat:
yum install -y rsync
2 - Create a REPLICATOR
user on your Master server (if you have not already done so):
psql -c "CREATE USER replicator REPLICATION LOGIN CONNECTION LIMIT 5 ENCRYPTED PASSWORD 'suasenhaaqui';"
3 - On your master server, change the following parameters in postgresql.conf:
listen_addresses = ‘*’
wal_level = 'hot_standby'
archive_mode = on
archive_command = 'cd .'
max_wal_senders = 1
hot_standby = on
4 - In the pg_hba.conf
file, change the following:
host replication replicator endereco_ip_do_slave/32 md5
5 - Restart your master Postgres server:
service postgresql-9.6 restart
6 - To start RSYNC
, so that we have a copy of your bank on the slave server, perform the following steps on your master server: ( Do not forget that you need STEP NUMBER 3 here )
psql -c "select pg_start_backup('initial_backup');"
rsync -cva --inplace /var/lib/pgsql/9.6/data/ ip_servidor_slave:/var/lib/pgsql/9.6/data/
psql -c "select pg_stop_backup();"
After the step up, remember to have recovery.conf [1] on your slave before starting Postgres.
You will also need to change the pg_hba.conf
in your slave to:
host replication replicator endereco_ip_do_master/32 md5