Installs HaProxy on a particular host. Only for use with Galera or MySQL Cluster s9s Deployment packages ( ).
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


**   IMPORTANT INFORMATION  ** is deprecated
Please use s9s_haproxy instead!


** Installation Example:

Change into the install directory of your deployment package:
cd s9s-galera-2.1.0/mysql/scripts/install

Download haproxy:
RH/Centos: yum install git
Debian/Ubutu: apt-get install git
git clone

cd haproxy
bash ./ debian galera

The above example installs HaProxy on 10.0.11, using galera 
on an ubuntu/debian platform. For MySQL Cluster on redhat/centos it would look like:
bash ./ rhel mysqlcluster

NOTE: only tested with bash shell, and if you run with:
sh install-haproxy...
it won't work.

** SSH:

*** IMPORTANT *************************************
Make sure you can SSH to $LB_HOST without password:
   ssh $USER@$LB_HOST
If that is not possible do:
   cd ..
   ./ $LB_HOST
Then try to install again. You must also setup 
sudo if you are not running as root:
see "sudo" in the artice:

** Files: - script to check if the mysql server is up and running (for MySQL Cluster) - script to check if the mysql server is up and running (for Galera)
xinetd_mysqlchk  - the xinetd script for the mysqlchk.
haproxy.cfg.tmpl.rhel - base template for the haproxy.cfg file. Redhat.
haproxy.cfg.tmpl.debian - base template for the haproxy.cfg file. Debian. - writes the haproxy.cfg file, called from - queries the cmon db to get a list of mysql server hosts, calls
                     installs ha proxy on the specified host, and installs xinetd, and mysqlchk on 
		     the list of hosts. It also performs tuning of the TCP stack where haproxy is installed.

** Make modifications / customizations

- In haproxy.cfg.tmpl.debian|rhel  
   You may want to modify parameters here in the template file. Usually the defaults works good.
   In this file you can also change the PASSWORD to the stats www interface.
   user admin insecure-password PASSWORD
   user stats insecure-password PASSWORD
  Perhaps you want to change settings here:
  default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 256 maxqueue 128 weight 100
  But the default values work pretty well.
- (MySQL Cluster)
  You should change CHECK_QUERY to make a PRIMARY KEY select that always succeed on an NDB table.
  Change the name of the HaProxy (LB_NAME) and also what mysql port the HaProxy should listen on:

** Deployment
For smaller setups (a couple of web servers) you can isntall one HaProxy on each Web Server.  
For larger setups it may make sense to have a HaProxy layer so that many web servers goes to one HaProxy.

** Reboot the HAProxy node.
If you don't reboot you may get strange error messages after a while:
Can't connect to MySQL server on '' (99)
Can't connect to MySQL server on '' (99)

** GRANT the load balancer host access to the mysql servers
E.g, if the LB is installed on do:
GRANT INSERT, SELECT, DELETE, UPDATE ON database.* TO 'johan'@'' IDENTIFIED BY 'severalnines';
on all mysql servers in the loadbalancer set.

** TODO / Further tuning
You may have to tune your TCP further to avoid (not a bug, expected behavior) if you open/close connects "too" fast.
E.g, this TCP parameter can be tuned: tcp_fin_timeout. The install-haproxy script sets it to '5'.
If you use bencher to benchmark you may run into this issue as bencher will stress the system quite a lot.

You can also try 'tcp_tw_reuse=1' by doing echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse
This is not currently set auto (more testing needed).