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.

1 Like

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
1 Like

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.

2 Likes

@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.
1 Like

@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.

Hi @lukastribus
Could you please check the highlighted text below…what could be the problem…?

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-28 22:33:55 IST; 3min 32s ago
Docs: man:haproxy(1)
file:/usr/share/doc/haproxy/configuration.txt.gz
Process: 7246 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0/SUCCESS)
Main PID: 7256 (haproxy)
Tasks: 3 (limit: 4915)
CGroup: /system.slice/haproxy.service
├─7256 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
└─7262 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock

May 28 22:33:55 Test-QA systemd[1]: Starting HAProxy Load Balancer…
May 28 22:33:55 Test-QA haproxy[7256]: [ALERT] 148/223355 (7256) : sendmsg()/writev() failed in logger #1: Permission denied (errno=13)
May 28 22:33:55 Test-QA haproxy[7256]: [NOTICE] 148/223355 (7256) : New worker #1 (7262) forked
May 28 22:33:55 Test-QA systemd[1]: Started HAProxy Load Balancer.
May 28 22:33:57 Test-QA haproxy[7256]: [WARNING] 148/223357 (7262) : Server mysql-cluster/Test-QA is DOWN, reason: Layer4 timeout, check duration: 2001ms. 1 active and 0
May 28 22:33:58 Test-QA haproxy[7256]: [WARNING] 148/223358 (7262) : Server mysql-cluster/irl-dev-pr-proxysql is DOWN, reason: Layer4 timeout, check duration: 2002ms. 0 active a
May 28 22:33:58 Test-QA haproxy[7256]: [ALERT] 148/223358 (7262) : proxy ‘mysql-cluster’ has no server available!

Your OS again refuses to work with the IP 127.0.0.0. Please remove it all including the logging configuration and make sure logging actually works properly.

Your mysql backends are not reachable at 10.0.0.1:3306 and 10.0.0.2:3306 at layer4. Check that those services are actually listening and available on the IP:port set you configured in haproxy.

This worked perfect for me. I had a missing ssl certificate and HAProxy would not start if it does not find it.
Thanks!