vitabaks / postgresql_cluster

Automated database platform for PostgreSQL® A modern, open-source alternative to cloud-managed databases.
https://postgresql-cluster.org
MIT License
1.83k stars 418 forks source link

Restart ETCD will lose new config added to HaProxy #787

Closed NormanTrinh closed 1 month ago

NormanTrinh commented 1 month ago

I have added kafka configuration to haproxy.cfg as follows:

global
    maxconn 100000
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

defaults
    mode               tcp
    log                global
    option             tcplog
    retries            2
    timeout queue      5s
    timeout connect    5s
    timeout client     60m
    timeout server     60m
    timeout check      15s

listen stats
    mode http
    bind 10.17.1.96:17000
    stats enable
    stats uri /

listen master
    bind 10.17.1.96:5000
    maxconn 10000
    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 staging-bigdata01 10.17.1.96:6432 check port 8008
 server staging-bigdata02 10.17.1.9:6432 check port 8008
 server staging-bigdata03 10.17.1.64:6432 check port 8008

listen replicas
    bind 10.17.1.96:5001
    maxconn 10000
        option httpchk OPTIONS /replica?lag=100MB
        balance roundrobin
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 2 on-marked-down shutdown-sessions
 server staging-bigdata01 10.17.1.96:6432 check port 8008
 server staging-bigdata02 10.17.1.9:6432 check port 8008
 server staging-bigdata03 10.17.1.64:6432 check port 8008

listen replicas_sync
    bind 10.17.1.96:5002
    maxconn 10000
        option httpchk OPTIONS /sync
        balance roundrobin
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 2 on-marked-down shutdown-sessions
 server staging-bigdata01 10.17.1.96:6432 check port 8008
 server staging-bigdata02 10.17.1.9:6432 check port 8008
 server staging-bigdata03 10.17.1.64:6432 check port 8008

listen replicas_async
    bind 10.17.1.96:5003
    maxconn 10000
        option httpchk OPTIONS /async?lag=100MB
        balance roundrobin
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 2 on-marked-down shutdown-sessions
 server staging-bigdata01 10.17.1.96:6432 check port 8008
 server staging-bigdata02 10.17.1.9:6432 check port 8008
 server staging-bigdata03 10.17.1.64:6432 check port 8008

# Add kafka endpoint
listen kafka
    bind *:19092
    mode tcp
    option tcp-check
    server staging-bigdata01 10.17.1.96:9092 check
    server staging-bigdata02 10.17.1.9:9092 check backup
    server staging-bigdata03 10.17.1.64:9092 check backup

After restart ETCD leader, it turn back to this:

global
    maxconn 100000
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

defaults
    mode               tcp
    log                global
    option             tcplog
    retries            2
    timeout queue      5s
    timeout connect    5s
    timeout client     60m
    timeout server     60m
    timeout check      15s

listen stats
    mode http
    bind 10.17.1.96:17000
    stats enable
    stats uri /

listen master
    bind 10.17.1.96:5000
    maxconn 10000
    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 staging-bigdata01 10.17.1.96:6432 check port 8008
 server staging-bigdata02 10.17.1.9:6432 check port 8008
 server staging-bigdata03 10.17.1.64:6432 check port 8008

listen replicas
    bind 10.17.1.96:5001
    maxconn 10000
        option httpchk OPTIONS /replica?lag=100MB
        balance roundrobin
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 2 on-marked-down shutdown-sessions
 server staging-bigdata01 10.17.1.96:6432 check port 8008
 server staging-bigdata02 10.17.1.9:6432 check port 8008
 server staging-bigdata03 10.17.1.64:6432 check port 8008

listen replicas_sync
    bind 10.17.1.96:5002
    maxconn 10000
        option httpchk OPTIONS /sync
        balance roundrobin
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 2 on-marked-down shutdown-sessions
 server staging-bigdata01 10.17.1.96:6432 check port 8008
 server staging-bigdata02 10.17.1.9:6432 check port 8008
 server staging-bigdata03 10.17.1.64:6432 check port 8008

listen replicas_async
    bind 10.17.1.96:5003
    maxconn 10000
        option httpchk OPTIONS /async?lag=100MB
        balance roundrobin
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 2 on-marked-down shutdown-sessions
 server staging-bigdata01 10.17.1.96:6432 check port 8008
 server staging-bigdata02 10.17.1.9:6432 check port 8008
 server staging-bigdata03 10.17.1.64:6432 check port 8008

Why is that, is there any config to pay attention to?

vitabaks commented 1 month ago

The haproxy configuration is managed by the confd service, so the configuration template should be changed here /etc/confd/templates/haproxy.tmpl

vitabaks commented 1 month ago

I have indicated this in the documentation: https://postgresql-cluster.org/docs/management/basic-commands#confd

NormanTrinh commented 1 month ago

Thank you.