Set Up HA Proxy for the Database Role

This topic details the installation and configuration of HA Proxy on a Moogsoft AIOps server, for connection to a remote Percona XtraDB Cluster.

Percona XtraDB Cluster must be run as a 3-node (minimum) cluster distributed across the database roles.

HA architecture

Before you install and configure HA Proxy, configure PerconaXtraDB as described in Set Up the Database for HA, with the components installed as follows:

HA_db.png

Server 3: DB 1 (Percona Node 1).

Server 4: DB 2 (Percona Node 2).

Server 5: DB 3 (Percona Node 3).

Fully distributed installation

See Distributed HA Installation for a reference diagram and steps to achieve a fully distributed installation.

Minimally distributed installation

Complete the following steps to install and configure HA Proxy and the required packages for a minimally distributed installation. Replace server 3, server 4 and server 5 with the relevant values for your architecture.

Configure HA Proxy for connection to Percona XtraDB Cluster

Complete the following steps:

  1. Install the Moogsoft AIOps packages on server 3 and server 4:

    VERSION=7.3.1.1; yum -y install moogsoft-server-${VERSION} \
        moogsoft-db-${VERSION} \
        moogsoft-utils-${VERSION} \
        moogsoft-search-${VERSION} \
        moogsoft-ui-${VERSION} \
        moogsoft-common-${VERSION} \
        moogsoft-mooms-${VERSION} \
        moogsoft-integrations-${VERSION} \
        moogsoft-integrations-ui-${VERSION}
  2. Edit the ~/.bashrc file on server 3 and server 4 to contain the following lines, the source the file:

    vim ~/.bashrc
    
    export MOOGSOFT_HOME=/usr/share/moogsoft
    export APPSERVER_HOME=/usr/share/apache-tomcat
    export JAVA_HOME=/usr/java/latest
    export PATH=$PATH:$MOOGSOFT_HOME/bin:$MOOGSOFT_HOME/bin/utils 
    
    source ~/.bashrc
  3. On server 3 and server 4, run the following command to configure and start HA Proxy:

    $MOOGSOFT_HOME/bin/utils/haproxy_installer.sh -l 3307 -c -i <server 3 ip address>:3306,<server 4 ip address>:3306,<server 5 ip address>:3306

    Note

    Moogsoft advises providing IP addresses instead of host names for servers running the Percona Cluster, in order to reduce the network latency.

    The script performs the following tasks:

    • Installs HAProxy v1.5.

    • Configures HAProxy to listen on 0.0.0.0:3306 and route connections to one of three MySQL back ends (as specified by the -i properties).

Verify HAProxy connection status

On server 3 or server 4, run the following command to verify the connection status:

$MOOGSOFT_HOME/bin/utils/check_haproxy_connections.sh

A successful response is as follows:

HAProxy Connection Counts
 
Frontend:
    0.0.0.0:3307 : 13
Backend:
    mysql_node_1 10.99.1.24:3306 : 13
    mysql_node_2 10.99.1.23:3306 : 0
    mysql_node_3 10.99.1.18:3306 : 0