Last active
December 22, 2015 20:19
-
-
Save boardstretcher/6525924 to your computer and use it in GitHub Desktop.
install and set up latest haproxy for four nodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# scientific linux 6.4 | |
# lb node - no sql on this node | |
# sql nodes: db1, db2, db3, db4 | |
yum -y update | |
yum -y install gcc | |
useradd haproxy | |
wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.24.tar.gz | |
tar zxvf haproxy-1.4.24.tar.gz | |
cd haproxy-1.4.24 | |
make install | |
mkdir -v /etc/haproxy | |
tee /etc/haproxy/haproxy.cfg <<EOF | |
global | |
log 127.0.0.1 local0 | |
maxconn 4096 | |
user haproxy | |
group haproxy | |
daemon | |
defaults | |
log global | |
mode tcp | |
option tcplog | |
option dontlognull | |
retries 3 | |
option redispatch | |
maxconn 2000 | |
contimeout 3600000 | |
clitimeout 3600000 | |
srvtimeout 3600000 | |
stats enable | |
stats scope . | |
frontend mysql_cluster | |
bind mysql_lb:3306 | |
default_backend mysql_cluster | |
backend mysql_cluster | |
mode tcp | |
balance roundrobin | |
option mysql-check user haproxyUser | |
server db1 db1:3306 check | |
server db2 db2:3306 check | |
server db3 db3:3306 check | |
server db4 db4:3306 check | |
listen stats *:80 | |
mode http | |
option httpclose | |
balance roundrobin | |
stats uri / | |
stats realm Haproxy\ Statistics | |
stats auth admin:admin | |
EOF | |
mysql -hdb1-uroot -p -e "GRANT ALL ON *.* to 'haproxyUser'@'%' IDENTIFIED BY '';" | |
mysql -hdb2-uroot -p -e "GRANT ALL ON *.* to 'haproxyUser'@'%' IDENTIFIED BY '';" | |
mysql -hdb3-uroot -p -e "GRANT ALL ON *.* to 'haproxyUser'@'%' IDENTIFIED BY '';" | |
mysql -hdb4-uroot -p -e "GRANT ALL ON *.* to 'haproxyUser'@'%' IDENTIFIED BY '';" | |
/usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg -V | |
# be sure to modify iptables accordingly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment