Patroni: How to change only as slave?

Created on 10 Jan 2019  路  5Comments  路  Source: zalando/patroni

Hello, Everyone

Currently i have a 3 nodes for Postgresql cluster with HAProxy, Patroni and Etcd.

For example:
node1, node2, node3.

i want to configure only switch between node1 <> node2 servers. node3 only for replication purpose. Means node3 no need Leader.

Thanks,

Most helpful comment

Hi,

Set nofailover tag to true for node3

All 5 comments

Hi,

Set nofailover tag to true for node3

@kostiantyn-nemchenko Thank you for your quick reply. It is working as i wish.

One more question.

  1. Is it possible use same data directory patroni and postgres? Means: When i stop patroni and start only postgresql server, it different configuration.

So what is your suggestion about that? Should we use different data dir for patroni or can be same? Because I am new of patroni technology.

  1. Please correct my steps. Currently i am doing following way.
    First i stopped postgresql server, and after start patroni service. Than patroni is working fine.

So when i reboot my OS, after patroni not work. Because postgresql started first. Should i disable postgresql from startup? What is the best way? I'm not sure, i guess if patroni and postgresql use same data dir, it should be work right?

Thank you.

Is it possible use same data directory patroni and postgres? Means: When i stop patroni and start only postgresql server, it different configuration.

Yes, you can do that. Patroni is not replacing postgres, it is just managing it.

So when i reboot my OS, after patroni not work. Because postgresql started first. Should i disable postgresql from startup

Yes, postgres autostart should be disabled. Otherwise, if postgres was running as master before shutdown or crash, there is a chance to get a split-brain.
If you need autostart, just do do it with Patroni: https://github.com/zalando/patroni/tree/master/extras/startup-scripts

Yes, postgres autostart should be disabled. Otherwise, if postgres was running as master before shutdown or crash, there is a chance to get a split-brain.
If you need autostart, just do do it with Patroni: https://github.com/zalando/patroni/tree/master/extras/startup-scripts

This is working well.

I have disable postgresql and enable patroni.

.

Yes, you can do that. Patroni is not replacing postgres, it is just managing it.

Currently i couldn't solve this problem. This is my configuration follows:

  1. Same data_dir = '/data/patroni' config in /etc/patroni.yml and /etc/postgresql/9.5/main/postgresql.conf

  2. Start postgresql without patroni. It could not start (postgres@postgres FATAL: the database system is starting up)

  3. Also i tried to start different way like: /usr/sbin/pg_ctl -D /data/patroni -l /tmp/pgsql.log start
    I got following error:
    FATAL: could not start WAL streaming: ERROR: replication slot "postsqlmaster04" does not exist

recovery.conf file /data/patroni
primary_slot_name = 'postsqlmaster04' standby_mode = 'on' recovery_target_timeline = 'latest' primary_conninfo = 'user=replicator password=post host=192.168.15.205 port=5432 sslmode=prefer sslcompression=1 application_name=postsqlmaster04'

So how can i start it? or how to move patroni data to postgresql data?

Please provide me some tutorial. Because i guess, in come case i will start postgres without patroni.

Thanks

Was this page helpful?
0 / 5 - 0 ratings