haporxy 负载elasticsearch

<pre name="code" class="html">-bash-4.1# cat /etc/haproxy/haproxy.cfg
global
	log 127.0.0.1	local3 
	maxconn 65535 
	chroot /usr/local/haproxy
	uid 401
	gid 401 
	daemon

defaults
	log	global
	mode	http
	option	httplog
	option	dontlognull
	retries	3
	option  redispatch
	option  abortonclose 
	maxconn 65535	
	timeout connect 5000
	timeout client  50000
	timeout server 50000

	timeout check   5s
	stats   refresh 30s
	stats   uri     /stats	
	stats   realm   baison-test-Haproxy     
  	stats   auth    admin:admin
  	stats   hide-version 
       
	
frontend  	www
 bind    	*:9200

 default_backend eshttp_server
backend eshttp_server
        mode    	http
	balance		roundrobin
backend eshttp_server
        mode    	http
	balance		roundrobin
	server ela01 192.168.32.80:9200 check inter 2000 fall 3
	server ela02 192.168.32.81:9200 check inter 2000 fall 3
	server ela03 192.168.32.82:9200 check inter 2000 fall 3
#服务器定义,cookie 1表示serverid为1,check inter 1500 是检测心跳频率


#rise 3是3次正确认为服务器可用,fall 3是3次失败认为服务器不可用,weight代表权重


server mms1 10.1.5.134:80 cookie 1 check inter 1500 rise 3 fall 3 weight 1


server mms2 10.1.6.118:80 cookie 2 check inter 1500 rise 3 fall 3 weight 2








   

原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199212.html