• RabbitMQ集群使用Haproxy负载均衡


    (1)、下载

      http://www.haproxy.org/#down

    (2)、解压  

    tar -zxvf haproxy-1.5.18.tar.gz 

    (3)、安装

      1)、编译 

    make TARGET=linux26 PREFIX=/usr/local/haproxy

      2)、安装(指定目录)

    make install PREFIX=/usr/local/haproxy

      3)、新建一个配置文件 

    global
    	log	127.0.0.1 local0
    #	log	127.0.0.1 local1
    	maxconn	4000
    	ulimit-n 8000
    	uid	0
    	gid	0
    #	chroot	/tmp
    #	nbproc	2
    #	daemon
    #	debug
    #	quiet
    
    listen proxy1 0.0.0.0:8000
    	mode	http
    #	source	127.0.0.2:0
    #	log	127.0.0.1 local0
    #	log	127.0.0.1 local1
    	log global
    	#mode	tcp
            cookie SERVERID insert indirect
    	balance roundrobin
    	#dispatch 127.0.0.1:3130
    	#dispatch 127.0.0.1:31300
    	#dispatch 127.0.0.1:80
    	#dispatch 127.0.0.1:22
    	option httpchk
    	server test 10.1.1.2:80 cookie cookie1 check inter 300
    #	server nc 127.0.0.1:8080 cookie cookie1 check inter 300
    #	server tuxlocal0 10.101.23.9:80 cookie cookie1 check
    #	server tuxlocal1 127.0.0.1:80 cookie cookie1 check
    #	server tuxlocal2 127.0.0.1:80 cookie cookie2 check
    #	server tuxlocal3 127.0.0.1:80 cookie cookie3 check
    #	server tuxlocal4 127.0.0.1:80 cookie cookie4 check
    #	server vax 10.101.14.1:80 cookie cookie1 check
    	#server tuxceleron 10.101.0.1:80 cookie cookie2 check
    	#server telnet 127.0.0.1:23
    	#server ssh 127.0.0.1:22
    	#server local 127.0.0.1:3130 cookie cookie3 check
    	#server ko 127.0.0.1:0 cookie cookie3 check
    	#server local 127.0.0.1:8001 cookie cookie3 check
    	#server local 127.0.0.1:3130
    	#server celeron 10.101.0.1:80 cookie srv1
    	#server celeron 10.101.0.1:31300
    	#server local 10.101.23.9:31300
    	contimeout	3000
    	clitimeout	150000
    	srvtimeout	150000
    	maxconn 60000
    	redispatch
    	retries	3
    	grace 3000
    	#rsprep	^Server.* Server: IIS
    	#rspdel	^Server.*
    	#rspadd Set-Cookie: mycookie=0; path=/
    	#rsprep ^(Date: )([^,]*)(, )(.*) LaDate est: 4 (2)
    	# force connection:close
    	#reqidel ^Connection:
    	#rspidel ^Connection:
    	#reqadd	Connection: close
    	#rspadd	Connection: close
    	# processing options
    	#option	keepalive
    	option	forwardfor
    	option httplog
    	option dontlognull
    #	reqirep ^(Test: ) _toto_1_toto
    #	reqidel ^X-Forwarded-for:
    #	reqirep ^(GET|POST) .* 
    #	reqirep ^(Host:|Connection:|User-agent:|Cookie:) .* 
    #	reqideny ^
    	
    listen proxy1 0.0.0.0:8001
    	mode	http
    	#mode	tcp
    	dispatch 127.0.0.1:80
    	#dispatch 127.0.0.1:31300
    	#dispatch 127.0.0.1:80
    	#dispatch 127.0.0.1:22
    	#server tuxlocal 127.0.0.1:80 cookie cookie1 check
    	#server tuxceleron 10.101.0.1:80 cookie cookie2 check
    	#server telnet 127.0.0.1:23
    	#server ssh 127.0.0.1:22
    	#server local 127.0.0.1:3130 cookie cookie3 check
    	#server local 127.0.0.1:3130
    	#server celeron 10.101.0.1:80 cookie srv1
    	#server celeron 10.101.0.1:31300
    	#server local 10.101.23.9:31300
    	contimeout	3000
    	clitimeout	150000
    	srvtimeout	150000
    	maxconn 60000
    	redispatch
    	retries	3
    	grace 3000
    	#rsprep	^Server.* Server: IIS
    	#rspdel	^Server.*
    	rspadd Set-Cookie: SERVERID=12345678; path=/
    	#rsprep ^(Date: )([^,]*)(, )(.*) LaDate est: 4 (2)
    	
    listen proxy1 0.0.0.0:3128
    	disabled
    	mode	http
            cookie SERVERID insert indirect
    	#dispatch 127.0.0.1:8080
    	server srv1 127.0.0.1:8080
     	#server srv2 192.168.12.3:8080
    	contimeout	3000
    	clitimeout	450000
    	srvtimeout	450000
    	maxconn 60000
    	redispatch
    	retries	3
    	grace 3000
    	rspdel ^Via:.*
    	monitor-net	192.168.12.252/30
    	
    
    listen proxy2 0.0.0.0:3129
    	disabled
    	mode	http
    	transparent
    #	dispatch 127.0.0.1:80
    	contimeout	3000
    	clitimeout	150000
    	srvtimeout	150000
    	maxconn 60000
    	retries	3
    	grace 3000
    
    #	log	10.101.11.1 local1
    #	log	10.101.11.1 local2
    
    #	cliexp	^(.*ASPSESSIONID.*=)(.*) 1FENICGGCBECLFFEEOAEAIFGF
    #	cliexp	^(GET.*)(.free.fr)(.*) 1.online.fr3
    #	cliexp	^(POST.*)(.free.fr)(.*) 1.online.fr3
    #	cliexp	^Proxy-Connection:.*	Proxy-Connection: close
    #	srvexp	^(Location: )([^:]*://[^/]*)(.*) 13
    
    listen health 0.0.0.0:3130
    	mode	health
    	clitimeout	1500
    	srvtimeout	1500
    	maxconn 6000
    	grace 0
    
    
    listen health 0.0.0.0:31300
    	mode	health
    	option  httpchk
    	clitimeout	1500
    	srvtimeout	1500
    	maxconn 6000
    	grace 0
    
    listen rabbitmq_local_cluster 0.0.0.0:25672 #定义名称及监控地址
    	#开启TCP模式
    	mode tcp
    	option tcplog
    	#简单的轮询
    	balance roundrobin
    	#rabbitmq集群节点配置
    	server rabbitmq1 0.0.0.0:5672 check inter 5000 rise 2 fall 2#每5000毫秒检查一次,如果2次检查失败,则认为服务器不可用
    	server rabbitmq2 0.0.0.0:5673 check inter 5000 rise 2 fall 2
    	server rabbitmq3 0.0.0.0:5674 check inter 5000 rise 2 fall 2
    ##服务器定义(check指健康状况检查,inter 5000指检测频率;rise 2指从离线状态转换至正常状态需要成功检查的次数;fall 2指失败2次即认为服务器不可用)
    
    #配置haproxy web监控,查看统计信息
    	listen private_monitoring :8100
    	mode http #以Http模式
    	option httplog
    	stats enable
    	#设置haproxy监控地址为http://localhost:8100/stats
    	stats uri /stats
    	stats refresh 30s
    	#添加用户名密码认证
    	stats auth admin:1234

      4)、指定配置文件

    ./haproxy -f /usr/local/haproxy/sbin/haproxy.cfg
  • 相关阅读:
    asp.net webform 动态调试技巧
    SQL RAND() 返回一个介于 0 到 1(不包括 0 和 1)之间的伪随机 float 值。
    SQL GUID之 NEWID()、NEWSEQUENTIALID()、UUID()、UUID_SHORT() 全局通用唯一标识符
    Linux环境下GraalVM nativeimage将jar包编译为二进制
    idea设置@vue跳转
    elupload 点击阻止弹窗
    使用Kotlin开发多平台应用
    你了解业务吗
    SQL 的理论基础是关系代数,而关系代数的主要操作只有 5 种,分别是并、差、积、选择、投影。所有的 SQL 语句最后都能用这 5 种操作组合完成。而一个嵌套子查询可以等价转换成一个连接(join)操作
    NO ONE CAN BEAT US
  • 原文地址:https://www.cnblogs.com/fanqisoft/p/10408899.html
Copyright © 2020-2023  润新知