vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on Patroni). Automating with Ansible.
https://postgresql-cluster.org
MIT License
1.48k stars 394 forks source link

How to make permanent changes on the postgresql cluster #702

Closed JY-210 closed 4 weeks ago

JY-210 commented 1 month ago

I want to point the control node to below 2 ports:

I modified the configuration files and it works fine. But after i reboot the VM, the changes to listen to port 7000 and 6432 will disappear. Tested to modify the files after deploy the cluster and before deploy the cluster, but both having same issue. Would like to ask if there is a way to make the changes permanent even after reboot?

Thanks.

vitabaks commented 1 month ago

Hello. Please attach your vars/main.yml

JY-210 commented 1 month ago

Hi, i pasted the parts that i did changes.

  1. Control node - vars/main.yml (part Load Balancing)

with_haproxy_load_balancing: true # or 'true' if you want to install and configure the load-balancing haproxy_listen_port: master: 5000 replicas: 5001 replicas_sync: 5002 replicas_async: 5003 pgbouncer: 6432 <------------------ added line stats: 7000 haproxy_maxconn: global: 100000 master: 10000 replica: 10000 haproxy_timeout: client: "60m" server: "60m"

  1. HAProxy node /etc/haproxy/haproxy.cfg

listen stats mode http bind [HAProxy node 1 IP]:7000 bind [Control node IP]:7000 <------------------ added line stats enable stats uri /

frontend pgbouncer_frontend bind *:6432 default_backend pgbouncer_backend option tcplog

backend pgbouncer_backend balance roundrobin option httpchk OPTIONS /primary http-check expect status 200 default-server inter 3s fastinter 1s fall 3 rise 4 on-marked-down shutdown-sessions server pgnode01 [PGNODE01 IP]:6432 check port 8008 server pgnode02 [PGNODE02 IP]:6432 check port 8008 server pgnode03 [PGNODE03 IP]:6432 check port 8008

After the changes, I am able to view haproxy stats using [Control node IP]:7000 and connect [Control node IP]:6432 at pgadmin. Just that the changes won't be permanent.

vitabaks commented 1 month ago

pgbouncer: 6432 <------------------ added line

See pgbouncer_listen_port variable

If you want to make manual changes (not recommended) to the HAProxy configuration after deploying the cluster, then you need to do this in the confd service template because it manages the haproxy configuration.

/etc/confd/templates/haproxy.tmpl

JY-210 commented 1 month ago

May I know any concerns if edited /etc/confd/templates/haproxy.tmpl?

vitabaks commented 1 month ago

Well, I would say that manual modification is highly undesirable, only if you know what you are doing, with mandatory testing before starting production.