How to replicate a particular bank in postgres to a particular door?

Asked

Viewed 117 times

1

Well I have the following scenario, I need to do a replication of a bank A for bank B. Well so far I was able to make from one machine to another making the following changes:

Master Machine - 10.0.0.1

    sudo vim /etc/postgresql/9.4/main/postgresql.conf
        listen_addresses = 'localhost,10.0.0.1'
        wal_level = hot_standby
        max_replication_slots = 3
        max_wal_senders = 3

    sudo vim /etc/postgresql/9.4/main/pg_hba.conf
        host    replication   all        10.0.0.2/32   trust   # the slave

    sudo su - postgres
    psql 
        select * from pg_create_physical_replication_slot('theslave');

    sudo service postgresql restart

Slave Machine 10.0.0.2

   sudo vim /etc/postgresql/9.4/main/postgresql.conf
       listen_addresses = 'localhost,10.0.0.2'  
       wal_level = hot_standby
       hot_standby = on
       hot_standby_feedback = on

   sudo service postgresql stop

   sudo su - postgres
       cd ~/9.4
       rm -rf main
       pg_basebackup -v -D main -R -P -h 10.0.0.1

   sudo su postgresql start

Well using that there works a beauty, but I discovered that the banks that I have to perform replication are not at door 5432 standard postgres are at door 9700, 9701 and 9702. In other words, I have to replicate the data from the databases on port 9700,9701 and 9702 on the master computer to the slave computer on the respective ports 9700, 9701 and 9702.

What change should I make?

  • In postgresql.conf you have the parameter port to set the cluster port number and pg_basebackup has the parameter -p to set the door, I think changing these two already works.

1 answer

0


Set the data to connect to the server master in the recovery.conf server slave. This is where you tell your replica which door it will connect to:

standby_mode = 'on'
primary_conninfo = 'host=10.0.0.1 port=9700 user=foo password=foopass' 
primary_slot_name = 'theslave'

Similarly, when rotating the pg_basebackup specify port using flag -p:

pg_basebackup -v -D main -R -P -h 10.0.0.1 -p 9700.

And of course, to replicate three clusters Postgresql listening on three separate ports, you also need three other servers slave, each configured to replicate from a port as above.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.