Ad Widget

Collapse

Postgresql DB connection through Haproxy

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stayler
    Junior Member
    • Nov 2019
    • 8

    #1

    Postgresql DB connection through Haproxy

    I want to use Haproxy as load-balancer for Zabbix-DB connection:
    I setup haproxy & custom check.
    And I do not have problems with checks, my node is always UP, but in time to time(once in 1-2 days, in random time) a get message, "Zabbix database is not available.", in logs:
    Code:
     16708:20200224:202412.152 [Z3001] connection to database 'zabbix' failed: [0] server closed the connection unexpectedly
            This probably means the server terminated abnormally
            before or while processing the request.
    Can you help me, where to look?

    Code:
    #> haproxy -v
    HA-Proxy version 1.8.17 2019/01/08
    Haproxy.conf:
    Code:
    global
      log 127.0.0.1:514 local3
      pidfile /run/haproxy.pid
    
      maxconn 30000
      nbproc  6
      cpu-map 1 0
      cpu-map 2 1
      cpu-map 3 2
      cpu-map 4 3
      cpu-map 5 4
      cpu-map 6 5
      stats bind-process 6
      stats socket /run/haproxy/admin.sock mode 660 level admin
      user  haproxy
      group haproxy
      external-check
      daemon
    
    
    defaults
      mode  http
      log   global
      option  dontlognull
      retries 3
      maxconn 30000
    
    #
    # Endpoints
    #
    
    #PostgreSql-Write
    
    listen PostgreSql-Write
      bind *:19307
      mode tcp
      balance leastconn
      timeout client  24h
      timeout server  24h
      timeout connect  3s
      log-format '{"hostname":"%H","type":"haproxy","date_time":"%t","timestamp":"%Ts","format":"tcp","remote_addr":"%ci","frontend_port":"%fp","backend_name":"%b","upstream_addr":"%si","bytes_read":"%B","bytes_uploaded":"%U","retries":"%rc","upstream_connect_time":"%Tc","session_duration":"%Tt","termination_state":"%ts","handshake_time":"%Th"}'
      acl is-PostgreSql-Write-dead nbsrv(PostgreSql-Write) gt 1
      tcp-request content reject if is-PostgreSql-Write-dead
      option external-check
      external-check command /etc/haproxy/zabbix_psql_master.sh
      server DB1 <IP>:<PORT> check inter 3s fall 2 rise 2 on-marked-down shutdown-sessions
      server DB2 <IP>:<PORT> check inter 3s fall 2 rise 2 on-marked-down shutdown-sessions
Working...