Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to setup HAproxy in conjunction with Percona XtraDB Cluster on a series of 3 EC2 instances. I have found a few tutorials online dealing with this specific issue, but I am a bit stuck.

Both the Percona servers and the HAproxy servers are running ubuntu 12.04. The HAProxy version is 1.4.18,

When I start HAProxy I get the following error: Server pxc-back/db01 is DOWN, reason: Socket error, check duration: 2ms.

I am not really sure what the issue could be. I have verified the following:

  1. EC2 security groups ports are open
  2. Poured over my config files looking for issues. I currently do not see any.
  3. Ensured that xinetd was installed
  4. Ensured that I am using the correct ip address of the mysql server.

Any help with this is greatly appreciated.

Here are my current config

Load Balancer


  log local0
  log local1 notice
  maxconn 4096
  user haproxy
  group haproxy

  log global
  mode http
  option tcplog
  option dontlognull
  retries 3
  option redispatch
  maxconn 2000
  contimeout 5000
  clitimeout 50000
  srvtimeout 50000

frontend pxc-front
  mode tcp
  default_backend pxc-back

frontend stats-front
  mode http
  default_backend stats-back

backend pxc-back
  mode tcp
  balance leastconn
  option httpchk
  server db01 check port 9200 inter 12000 rise 3 fall 3

backend stats-back 
  mode http
  balance roundrobin
  stats uri /haproxy/stats

MySql Server


# default: on
# description: mysqlchk
service mysqlchk
# this is a config for xinetd, place it in /etc/xinetd.d/
        disable = no
        flags           = REUSE
        socket_type     = stream
        port            = 9200
        wait            = no
        user            = nobody
        server          = /usr/bin/clustercheck
        log_on_failure  += USERID
        #only_from       =
        # recommended to put the IPs that need
        # to connect exclusively (security purposes)
        per_source      = UNLIMITED

MySql Server


Added the line mysqlchk 9200/tcp # mysqlchk

MySql Server


# GNU nano 2.2.6 File: /usr/bin/clustercheck
# Script to make a proxy (ie HAProxy) capable of monitoring Percona XtraDB Cluster nodes properly
# Author: Olaf van Zandwijk <>
# Documentation and download:
# Based on the original script from Unai Rodriguez


# Perform the query to check the wsrep_local_state
WSREP_STATUS=`mysql --user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} -e "SHOW STATUS LIKE 'wsrep_local_state';" 2>${ERR_FILE} | awk '{if (NR!=1){print $2}}' 2>${ERR_FILE}`

if [[ "${WSREP_STATUS}" == "4" ]] || [[ "${WSREP_STATUS}" == "2" && ${AVAILABLE_WHEN_DONOR} == 1 ]]
    # Percona XtraDB Cluster node local state is 'Synced' => return HTTP 200
    /bin/echo -en "HTTP/1.1 200 OK\r\n"
    /bin/echo -en "Content-Type: text/plain\r\n"
    /bin/echo -en "\r\n"
    /bin/echo -en "Percona XtraDB Cluster Node is synced.\r\n"
    /bin/echo -en "\r\n"
    # Percona XtraDB Cluster node local state is not 'Synced' => return HTTP 503
    /bin/echo -en "HTTP/1.1 503 Service Unavailable\r\n"
    /bin/echo -en "Content-Type: text/plain\r\n"
    /bin/echo -en "\r\n"
    /bin/echo -en "Percona XtraDB Cluster Node is not synced.\r\n"
    /bin/echo -en "\r\n"
share|improve this question
what does curl -I localhost:9200 return when run on one of the db cluster nodes? HAproxy will look for a 200 HTTP return code when running that check in order for it to mark the server up. – carillonator Feb 1 '13 at 0:19

Please ensure the following steps and post the results here.

  1. xinetd is running.
  2. Create the mysql test user testuser as you mentioned
  3. verify listening tcp port(9200) by netstat -nlt
  4. If you have enabled iptables, please allow port 9200
  5. if the port is open and in listen state, install telnet client in percona node and try to telnet by telnet 9200
  6. If the xinetd is working, you should see the http response.
  7. if not, execute /usr/bin/clustercheck

Once you done all this, please post the results here.

share|improve this answer

I had problem where telnet 9200 gave 503 Server unavailable response, but when I executed /usr/bin/clustercheck as root it showed that everything was fine.

With this command I was able to execute clustercheck as user nobody and got real MySQL error to /tmp/cluster.log:

sudo -H -u nobody bash -c "/usr/bin/clustercheck clustercheckuser clustercheckpassword! 0 /tmp/cluster.log"

And /tmp/cluster.log contained:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (13)

Problem was that directory where mysql.sock was located didn't have execute (+x) flag on it and therefore wasn't readably by user nobody and fix was:

chmod o+x /var/run/mysql

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.