vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on "Patroni" and DCS "etcd" or "consul"). Automating with Ansible.
MIT License
1.29k stars 353 forks source link

Several pg clusters with one etcd cluster #283

Closed a-b-v closed 1 year ago

a-b-v commented 1 year ago

Hi! I'm trying to make this setup, but then the patroni from the secondary cluster starting, the log messages appeared:

Mar 20 08:16:14 pg02-node01 systemd[1]: Started Runners to orchestrate a high-availability PostgreSQL - Patroni.
Mar 20 08:16:14 pg02-node01 patroni[12816]: 2023-03-20 08:16:14,681 INFO: Selected new etcd server http://172.16.16.14:2379
Mar 20 08:16:14 pg02-node01 patroni[12816]: 2023-03-20 08:16:14,690 INFO: No PostgreSQL configuration items changed, nothing to reload.
Mar 20 08:16:14 pg02-node01 patroni[12816]: 2023-03-20 08:16:14,703 INFO: Lock owner: pg01-node01; I am pg02-node01
Mar 20 08:16:14 pg02-node01 patroni[12816]: 2023-03-20 08:16:14,709 INFO: trying to bootstrap from leader 'pg01-node01'

How i can to make setup like this?

vitabaks commented 1 year ago

Hi @a-b-v

I don't see any errors in the log, please attach more Patroni logs

sudo journalctl -u patroni

a-b-v commented 1 year ago

I Have read the patrony documentation. looks like he can't do that

a-b-v commented 1 year ago

Hi @a-b-v

I don't see any errors in the log, please attach more Patroni logs

sudo journalctl -u patroni

Patroni from second cluster tried to restore postgresql data from first cluster instead of initizlise it own cluster

a-b-v commented 1 year ago

I guess I have to setup several etcd on different ports

vitabaks commented 1 year ago

It should do so) The replica will simply copy the data from the primary. The replica cannot initiate its own PGDATA because it will already be a different cluster.

vitabaks commented 1 year ago

one etcd cluster is enough (3 or 5 nodes)

Maybe I don't quite understand what you want to do. A little more details

vitabaks commented 1 year ago

Several pg clusters with one etcd cluster

Now I understand what you need.

In this case, just specify a different patroni_cluster_name for the second cluster.

vitabaks commented 1 year ago

https://github.com/vitabaks/postgresql_cluster/commit/87992a6cec4dcf390d469b679eca9711db504510

a-b-v commented 1 year ago

It's worked, thanks). Missed this option