replication error

1

I'm trying to use a command in shell in PostgreSQL (Windows) with the following syntax:

select pg_start_backup('nome do meu banco de dados', true);

It responds to a record. Now, when I type the following command nothing happens:

pg_basebackup -U postgres -D /var/lib/pgsql/9.4/data/db/secundario -P -h Ip do Slave -Ft

When I give this command:

pg_stop_backup();

The following message appears:

  

ERROR: syntax error at or near "ph_basebackup"
  LINE 1: pg_basebackup -U postgres -D /var/li/psql/9.4/data/db/secu ...

Does anyone know what's going on?

Thank you in advance, thank you!

    
asked by anonymous 06.03.2015 / 15:42

1 answer

0

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
    
13.10.2016 / 04:35