postgresql_cluster
postgresql_cluster copied to clipboard
Support Consul for distributed consensus
any update about supporting consul please
I do not plan to implement and maintain code to deploy the Consul cluster, instead we can use this playbook https://github.com/ansible-community/ansible-consul I will add variables to configure interaction with the Consul. In addition, we need to configure the connection with Consul and test the operation of these components: confd for the [Type A] schema, vip-manager for the [Type B] schema (if variable cluster_vip is specified).
I'll do it right away as soon as I can allocate more time. I appreciate any help.
Thanks For your update, and for your info i installed consul cluster manually and changed that in patroni.yml file the part of etcd: hosts with consul and changed with consul ports and restarted patroni and worked with no issues. as I faced an issues with etcd and could not solve it so I changed to consul
as I faced an issues with etcd and could not solve it so I changed to consul
etcd is very reliable, usually there are no problems with it. If you encountered a problem, do not hesitate to open a new issue.
I’m studying the work of Consul Service Discovery with DNS resolving and I’m starting to like it.
It is convenient to search for the master and replicas (without using vip-manager or haproxy) example: master.patroni.service.consul and replica.patroni.service.consul as a client access point. But it requires the installation of a consul in client mode on each application server for service DNS resolution (or check forward DNS to the remote consul server instead of installing a local consul client).
Nevertheless, it can be useful for a distributed cluster across different data centers. We can specify in advance which data center the database server is located in and then use this for applications running in the same data center.
Example:
replica.patroni.service.dc1.consulreplica.patroni.service.dc2.consul
And, we can add any custom checks so that the service is considered healthy and the DNS record for this service is active.
I'm thinking of adding a new type of schema: "[Type C] PostgreSQL High-Availability with Consul Service Discovery (DNS)" based on "Patroni" and "Consul".
I'm thinking of doing it!
@RashadAnsari @gc-ss
PR: https://github.com/vitabaks/postgresql_cluster/pull/238
To test, follow these steps:
# 1. clone this repository from branch "consul"
git clone --branch consul --single-branch https://github.com/vitabaks/postgresql_cluster.git
# 2. Go to the playbook directory
cd postgresql_cluster/
# 3. Edit the inventory file
vim inventory
## Specify (non-public) IP addresses and connection settings (`ansible_user`, `ansible_ssh_pass` or `ansible_ssh_private_key_file` for your environment
# 4. Edit the variable file vars/main.yml
vim vars/main.yml
## Specify the variable: "dcs_type: consul"
# 5. install consul role requirements on the control node
ansible-galaxy install -r roles/consul/requirements.yml
# 6. Run playbook:
ansible-playbook deploy_pgcluster.yml
Client access point:
master.postgres-cluster.service.consulreplica.postgres-cluster.service.consul
cc @askurihin
Done.