Haproxy config

Hello,

I am trying to configure Haproxy in front of my xtradb cluster. I need to enable scripts that is checking which node is active&runnig. I followed https://www.percona.com/doc/percona-xtradb-cluster/8.0/howtos/haproxy.html this article but could not manage to use clustercheck . Does anybody know how it needs to be run?

1 Like

Hello @Ghan ,

Let’s see. Please check that:

  1. Every MySQL node has /etc/xinet.d/mysqlchk script

  2. Every MySQL node has /usr/local/bin/clustercheck

  3. Every MySQL node has the following line in /etc/services

mysqlchk        9200/tcp                # mysqlchk
  1. HAProxy has something like (key here is check port 9200):
option  httpchk

    server db01 10.4.29.100:3306 check port 9200 inter 12000 rise 3 fall 3
    server db02 10.4.29.99:3306 check port 9200 inter 12000 rise 3 fall 3
    server db03 10.4.29.98:3306 check port 9200 inter 12000 rise 3 fall 3

The way it works is the following:

  1. HAProxy connects to port 9200 on every MySQL node

  2. This in turn invokes mysqlchk script, which invokes clustercheck script

  3. If clustercheck returns 200 - all good, 503 - node is not healthy. HAproxy makes the decision based on these codes.

If something is not working as expected, try debugging the problem from the bottom. Check if clustercheck returns correct codes and works properly. Then try if you can invoke mysqlchk locally and through the network.

1 Like

Hi @spronin ,

Thank you for your reply. Here is my Comments;

  1. Every MySQL node has /etc/xinet.d/mysqlchk script // Checked, not exist.

  2. Every MySQL node has /usr/local/bin/clustercheck // Checked, exist but not that directory.

image.png

image.png

image.png

  1. Every MySQL node has the following line in /etc/services // Checked, not exist.

  1. HAProxy has something like (key here is check port 9200) // This is done.

I got how it is need to be work, Like Patroni :slight_smile: Allright, so how can i find missing parts?

1 Like

@Ghan

Have you installed XtraDB Cluster from Percona’s distribution? These scripts should come along with the distribution.

/etc/services file is not populated automatically and you need to change it manually on every MySQL node.

1 Like

Correct, i used “yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm -y” and “percona-release setup pxc80” . Then installed xtradb on nodes.

Ok, i will add above line to /etc/services.

1 Like

Hello,

Any news about finding scripts? Thx!

1 Like

Hey @Ghan

you can find mysqlcheck script in /usr/bin

[vagrant@localhost ~]$ rpm -qf /usr/bin/mysqlcheck

percona-xtradb-cluster-client-8.0.20-11.3.el7.x86_64

1 Like