织梦后台怎么建设网站,小网站开发成本,网站建设费用核算,wordpress加帝国cmshaproxy 进阶 应用场景
只是作为负载均衡的工具#xff0c;至于是什么应用集群都可以#xff0c;例如#xff1a;上面的RabbitMQ集群 下面那redis集群再给大家举个例子#xff1a;
创建配置haproxy配置文件
#创建haproxy配置文件
touch /etc/haproxy/haproxy.cfg
#Hapro…haproxy 进阶 应用场景
只是作为负载均衡的工具至于是什么应用集群都可以例如上面的RabbitMQ集群 下面那redis集群再给大家举个例子
创建配置haproxy配置文件
#创建haproxy配置文件
touch /etc/haproxy/haproxy.cfg
#Haproxy配置
PS:haproxy 配置文件haproxy.cfg详解
vim /etc/haproxy/haproxy.cfg添加内容如下
#logging options
globallog 127.0.0.1 local0 info #日志输出配置,所有日志都记录在本机,通过local0输出maxconn 5120chroot /app/haproxy #haproxy 安装路径uid 99 #所属运行的用户uidgid 99 #所属运行的用户组daemon #后台运行quietnbproc 20pidfile /var/run/haproxy.pid #指定PID文件路径defaultslog global#使用4层代理模式mode http为7层代理模式mode tcp#if you set mode to tcp,then you nust change tcplog into httplogoption tcplogoption dontlognullretries 3option redispatchmaxconn 2000#连接超时时间timeout connect 5s#客户端空闲超时时间为 60秒 则HA 发起重连机制timeout client 60s#服务器端连接超时时间为 15秒 则HA 发起重连机制timeout server 15s #front-end IP for consumers and producters
listen rabbitmq_clusterbind 0.0.0.0:5672 #绑定协议端口#配置TCP模式#所处理的类别,默认采用http模式,可配置成tcp作4层消息转发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集群节点配置 #inter 每隔五秒对mq集群做健康检查 2次正确证明服务器可用2次失败证明服务器不可用并且配置主备机制server redis-01 192.168.0.115:5672 check inter 5000 rise 2 fall 2server redis-02 192.168.0.117:5672 check inter 5000 rise 2 fall 2server redis-03 192.168.0.118:5672 check inter 5000 rise 2 fall 2
#配置haproxy web监控查看统计信息
listen statsbind 192.168.0.119:8100 #前端浏览器中查看统计的WEB界面地址mode httpoption httplog #日志类别,采用httplogstats enablestats auth admin:123456 #设置查看统计的账号密码#设置haproxy监控地址为http://localhost:8100/rabbitmq-statsstats uri /rabbitmq-statsstats refresh 5s #5s刷新一次注以上配置基于haproxy-2.1.2 版本低版本有部分差异
不相同部分剖析 redis集群 server redis-01 192.168.0.115:5672 check inter 5000 rise 2 fall 2server redis-02 192.168.0.117:5672 check inter 5000 rise 2 fall 2server redis-03 192.168.0.118:5672 check inter 5000 rise 2 fall 2MQ集群 server mq-01 192.168.0.115:5672 check inter 5000 rise 2 fall 2server mq-02 192.168.0.117:5672 check inter 5000 rise 2 fall 2server mq-03 192.168.0.118:5672 check inter 5000 rise 2 fall 2其他部分属于公共自定义部分保持默认即可