# Haproxy config

**URL:** <https://forums.percona.com/t/haproxy-config/8260>\
**Category:** Percona XtraDB Cluster 8.x\
**Created:** [November 10, 2020, 8:56am UTC](https://forums.percona.com/t/haproxy-config/8260 "2020-11-10T08:56:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cihan\_Tunali](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/cihan_tunali/32/4574_2.png) [@Cihan\_Tunali](https://forums.percona.com/u/Cihan_Tunali)\
**Post date:** [November 10, 2020, 8:56am UTC](https://forums.percona.com/t/haproxy-config/8260/1 "2020-11-10T08:56:29Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [November 10, 2020, 3:17pm UTC](https://forums.percona.com/t/haproxy-config/8260/2 "2020-11-10T15:17:43Z")

</div>

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

```auto
mysqlchk 9200/tcp # mysqlchk

```

1. HAProxy has something like (key here is check port 9200):

```auto
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.

---

<div class="post-metadata">

**Author:** ![Cihan\_Tunali](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/cihan_tunali/32/4574_2.png) [@Cihan\_Tunali](https://forums.percona.com/u/Cihan_Tunali)\
**Post date:** [November 11, 2020, 1:04am UTC](https://forums.percona.com/t/haproxy-config/8260/3 "2020-11-11T01:04:15Z")

</div>

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](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/1X/158c57c104c71e708b67d8d67dd67fc1fb35a7bb.png)

![image.png](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/1X/7177aee2968464c7e3e9b8a56a6018541d27041a.png)

![image.png](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/1X/fe7c3d333decb5402f0ed8cde6187687e3022223.png)

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

 ![image.png](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/1X/cdd8ffb9665f6595e56295527a8b5c8ab8e0ff50.png)

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

 ![image.png](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/1X/0c18b9fca8c554d131dc551e3dc44d966c10973b.png)

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

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [November 11, 2020, 1:44am UTC](https://forums.percona.com/t/haproxy-config/8260/4 "2020-11-11T01:44:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cihan\_Tunali](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/cihan_tunali/32/4574_2.png) [@Cihan\_Tunali](https://forums.percona.com/u/Cihan_Tunali)\
**Post date:** [November 11, 2020, 1:48am UTC](https://forums.percona.com/t/haproxy-config/8260/5 "2020-11-11T01:48:20Z")

</div>

Correct, i used “yum install [https://repo.percona.com/yum/percona-release-latest.noarch.rpm](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.

---

<div class="post-metadata">

**Author:** ![Cihan\_Tunali](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/cihan_tunali/32/4574_2.png) [@Cihan\_Tunali](https://forums.percona.com/u/Cihan_Tunali)\
**Post date:** [November 13, 2020, 5:18am UTC](https://forums.percona.com/t/haproxy-config/8260/6 "2020-11-13T05:18:22Z")

</div>

Hello,

Any news about finding scripts? Thx!

---

<div class="post-metadata">

**Author:** ![Evgeniy\_Patlan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/evgeniy_patlan/32/41_2.png) [@Evgeniy\_Patlan](https://forums.percona.com/u/Evgeniy_Patlan)\
**Post date:** [November 13, 2020, 6:18am UTC](https://forums.percona.com/t/haproxy-config/8260/7 "2020-11-13T06:18:45Z")

</div>

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
