HAProxy community

Failed to start HAProxy Load Balancer

root@Test-QA:/etc/haproxy# service haproxy start
Job for haproxy.service failed because the control process exited with error code.
See “systemctl status haproxy.service” and “journalctl -xe” for details.

root@Test-QA:/etc/haproxy# systemctl status haproxy.service
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-05-14 16:18:01 IST; 9min ago
Docs: man:haproxy(1)
file:/usr/share/doc/haproxy/configuration.txt.gz
Process: 8564 ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -p $PIDFILE $EXTRAOPTS (code=exited, status=1/FAILURE)
Process: 8553 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0/SUCCESS)
Main PID: 8564 (code=exited, status=1/FAILURE)

May 14 16:18:01 Test-QA systemd[1]: haproxy.service: Service hold-off time over, scheduling restart.
May 14 16:18:01 Test-QA systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.
May 14 16:18:01 Test-QA systemd[1]: Stopped HAProxy Load Balancer.
May 14 16:18:01 Test-QA systemd[1]: haproxy.service: Start request repeated too quickly.
May 14 16:18:01 Test-QA systemd[1]: haproxy.service: Failed with result ‘exit-code’.
May 14 16:18:01 Test-QA systemd[1]: Failed to start HAProxy Load Balancer.

Hi @lukastribus

Configuring MySQL load balancing

when executed the below command ,facing the ERROR

root@Test-QA:~# service haproxy start
Job for haproxy.service failed because the control process exited with error code.
See "systemctl status haproxy.service" and "journalctl -xe" for details.


root@Test-QA:~# systemctl status haproxy.service
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2020-05-20 17:48:34 IST; 4s ago
     Docs: man:haproxy(1)
           file:/usr/share/doc/haproxy/configuration.txt.gz
  Process: 14477 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=1/FAILURE)

May 20 17:48:33 Test-QA systemd[1]: haproxy.service: Control process exited, code=exited status=1
May 20 17:48:33 Test-QA systemd[1]: haproxy.service: Failed with result 'exit-code'.
May 20 17:48:33 Test-QA systemd[1]: Failed to start HAProxy Load Balancer.
May 20 17:48:34 Test-QA systemd[1]: haproxy.service: Service hold-off time over, scheduling restart.
May 20 17:48:34 Test-QA systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.
May 20 17:48:34 Test-QA systemd[1]: Stopped HAProxy Load Balancer.
May 20 17:48:34 Test-QA systemd[1]: haproxy.service: Start request repeated too quickly.
May 20 17:48:34 Test-QA systemd[1]: haproxy.service: Failed with result 'exit-code'.
May 20 17:48:34 Test-QA systemd[1]: Failed to start HAProxy Load Balancer.

Below is my Config file …

global
    log 127.0.0.0  local0 notice
    maxconn 150
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user  haproxy
    group haproxy

defaults
    log     global
    retries 2
    mode    tcp
    option  httplog
    timeout connect 4s
    timeout server  30m
    timeout client  30m
    timeout check   5s

listen mysql-cluster
    bind 127.0.0.0:3306
    mode tcp
    option mysql-check user haproxy_check
    balance roundrobin
    server Test-QA  10.0.0.1:3306 check
    server Stage-QA 10.0.0.2:3306 check

Start manually as root and in foreground and check the error message:

$ haproxy -f /path/to/haproxyconfig -db

Executed the command …:

root@Test-QA:/etc/haproxy#  haproxy -f /path/TO/haproxyconfig -db
[ALERT] 141/111636 (12567) : Cannot open configuration file/directory /path/TO/haproxyconfig : No such file or directory

/path/to/haproxyconfig was supposed to be an example, you should replace it with the actual path to your haproxy configuration file.

@lukastribus
Executed this command =>haproxy -f /etc/haproxy/haproxy.cfg -db

root@Test-QA:/etc/haproxy# haproxy -f /etc/haproxy/haproxy.cfg -db
[ALERT] 141/130238 (22117) : parsing [/etc/haproxy/haproxy.cfg:5] : log : invalid address: '127.0.0.0.' in '127.0.0.0.'

[ALERT] 141/130238 (22117) : parsing [/etc/haproxy/haproxy.cfg:25] : 'bind' : invalid address: '127.0.0.0.' in '127.0.0.0.:3306'
[ALERT] 141/130238 (22117) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
[ALERT] 141/130238 (22117) : Fatal errors found in configuration.

@lukastribus
Now getting this ERROR …when executed => haproxy -f /etc/haproxy/haproxy.cfg -d

root@Test-QA:/etc/haproxy# haproxy -f /etc/haproxy/haproxy.cfg -d
[WARNING] 141/131611 (23532) : parsing [/etc/haproxy/haproxy.cfg:17] : 'option httplog' not usable with proxy 'mysql-cluster' (needs 'mode http'). Falling back to 'option tcplog'.
Available polling systems :
      epoll : pref=300,  test result OK
       poll : pref=200,  test result OK
     select : pref=150,  test result OK
Total: 3 (3 usable), will use epoll.

Available filters :
        [SPOE] spoe
        [CACHE] cache
        [FCGI] fcgi-app
        [TRACE] trace
        [COMP] compression
Using epoll() as the polling mechanism.
[ALERT] 141/131611 (23532) : Starting proxy mysql-cluster: cannot bind socket [127.0.0.0:3306]

Your system is refusing to let you bind to 127.0.0.0, maybe you need to use 127.0.0.1 instead.

What’s your OS/kernel?

ubuntu 18 LTS

Did you try with 127.0.0.1 ?

127.0.0.0 is working …

getting new error …

root@Test-QA:/etc/haproxy# service haproxy status
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-05-21 16:53:37 IST; 16min ago
     Docs: man:haproxy(1)
           file:/usr/share/doc/haproxy/configuration.txt.gz
  Process: 4787 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0/SUCCESS)
 Main PID: 4796 (haproxy)
    Tasks: 3 (limit: 4915)
   CGroup: /system.slice/haproxy.service
           ├─4796 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
           └─4799 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock

May 21 16:53:37 Test-QA systemd[1]: Starting HAProxy Load Balancer...
May 21 16:53:37 Test-QA haproxy[4796]: [NOTICE] 141/165337 (4796) : New worker #1 (4799) forked
May 21 16:53:37 Test-QA systemd[1]: Started HAProxy Load Balancer.
May 21 16:53:39 Test-QA haproxy[4796]: [WARNING] 141/165339 (4799) : Server mysql-cluster/Test-QA is DOWN, reason: Layer4 timeout, check duration: 2000ms. 1 active and 0
May 21 16:53:40 Test-QA haproxy[4796]: [WARNING] 141/165340 (4799) : Server mysql-cluster/Stage-QA is DOWN, reason: Layer4 timeout, check duration: 2002ms. 0 active a
May 21 16:53:40 Test-QA haproxy[4796]: [ALERT] 141/165340 (4799) : proxy 'mysql-cluster' has no server available!

I assume mysql is actually reachable from haproxy?

You probably need to add the post-41 keyword to the health checks:

https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4-option%20mysql-check

@lukastribus

For your information …:
I have 2 servers CONFIGURED MySQL Master-Master Replication and

HAPROXY installed in server Test-QA 10.0.0.1

  1)  server Test-QA    10.0.0.1 port 3306
  2)  server Stage-QA 10.0.0.2 port 3306

Please review the config file below …:
i have added post-41 in my config file …

global
    log 127.0.0.0  local0
    log 127.0.0.0  local0 notice
    maxconn 150
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user  haproxy
    group haproxy
    daemon

defaults
    log     global
    retries 3
    timeout connect 4s
    timeout server  30m
    timeout client  30m
    timeout check   5s

# MySQL Load Balance Pool
listen mysql-cluster
    bind :3306
    mode tcp
    option mysql-check user haproxy_check post-41
    balance roundrobin
    server Test-QA  10.0.0.1:3306 check
    server Stage-QA 10.0.0.2:3306 check

Looks fine to me.