haproxy(3)Upgrade haproxy to 1.4.25 and Proxy RabbitMQ Cluster

haproxy(3)Upgrade haproxy to 1.4.25 and Proxy RabbitMQ Cluster

1. Install the latest Version
Prepare the latest Package
>wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.25.tar.gz
Unzip the file and Move to the working directory.
>make TARGET=generic ARCH=x86_64 USE_PCRE=1
>make install DESTDIR='/Users/carl/tool/haproxy-1.4.25' PREFIX=''

>sudo ln -s /Users/carl/tool/haproxy-1.4.25 /opt/haproxy-1.4.25
>sudo ls -s /opt/haproxy-1.4.25 /opt/haproxy

Add that sbin path to my system.
export PATH=/opt/haproxy/sbin:$PATH

Installation is success.
>haproxy -v
HA-Proxy version 1.4.25 2014/03/27 Copyright 2000-2014 Willy Tarreau <w@1wt.eu>

2. Configuration
http://cbonte.github.io/haproxy-dconv/configuration-1.5.html

The sample configuration is as follow:
#this config needs haproxy-1.4.25

#logging options

global        

log 127.0.0.1 local0 info        

maxconn 5120        

chroot /opt/haproxy        

uid 99        

gid 99        

daemon         quiet        

nbproc  2        

pidfile /opt/haproxy/haproxy.pid

#load balancing

defaults defaults       

log        global        #使用4层代理模式,"mode   http"为7层代理模式       

mode       tcp       

#if you set mode to tcp,then you nust change tcplog into http

log        option    

tcplog        option    

dontlognull       

retries    3       

option redispatch       

maxconn 2000       

contimeout      5s       

clitimeout      120s       

srvtimeout      120s

#front-end IP for consumers and producters

listen rabbitmq_local_cluster 127.0.0.1:5670       

#配置TCP模式       

mode      tcp       

#balance url_param userid       

#balance url_param session_id check_post 64       

#balance hdr(User-Agent)       

#balance hdr(host)       

#balance hdr(Host) use_domain_only       

#balance rdp-cookie       

#balance leastconn       

#balance source  //ip        #简单的轮询       

balance roundrobin       

#rabbitmq集群节点配置       

server rabbit1  127.0.0.1:5672 check inter 5000 rise 2 fall 2       

server rabbit2 127.0.0.1:5673 check inter 5000 rise 2 fall 2

#配置haproxy web监控,查看统计信息

listen private_monitoring :8100       

mode    http       

option  httplog       

stats   enable       

#设置haproxy监控地址为http://localhost:8100/rabbitmq-stats       

stats   uri  /rabbitmq-stats       

stats   refresh 5s

I  can check the status page here.
http://localhost:8100/rabbitmq-stats

And when we plan to use rabbitmq, we will connect to this port number 5670.

References:
http://sillycat.iteye.com/blog/562645  installation and loadbalance
http://sillycat.iteye.com/blog/562646  session stick
http://sillycat.iteye.com/blog/1055846

相关推荐