yum install gcc vim wget -y2.下载HAProxy
wget https://www.haproxy.org/download/1.6/src/haproxy-1.6.5.tar.gz3.解压
tar -zxvf haproxy-1.6.5.tar.gz -C /usr/local4.进入目录,进行编译和安装
cd /usr/local/haproxy-1.6.5 make TARGET=linux31 PREFIX=/usr/local/haproxy make install PREFIX=/usr/local/haproxy mkdir /etc/haproxy5.赋权
groupadd -r -g 149 haproxy useradd -g haproxy -r -s /sbin/nologin -u 149 haproxy6.配置HAProxy
touch /etc/haproxy/haproxy.cfg vim /etc/haproxy/haproxy.cfg
#loggin options global log 127.0.0.1 local0 info maxconn 5120 chroot /usr/local/haproxy uid 99 gid 99 daemon quiet nbproc 20 pidfile /var/run/haproxy.pid defaults log global #使用4层代理模式,"mode http"为7层代理模式 mode tcp #if you set mode to tcp,then you nust change tcplog into httplog option tcplog option dontlognull retries 3 option redispatch maxconn 2000 contimeout 5s clitimeout 60s srvtimeout 15s listen rabbitmq_cluster bind 0.0.0.0:5672 #配置tcp模式 mode tcp balance roundrobin #负载均衡算法 server bhz128 192.168.171.128 check inter 5000 rise 2 fall 2 #定义的多个后端 server bhz132 192.168.171.132 check inter 5000 rise 2 fall 2 #定义的多个后端 server bhz134 192.168.171.134 check inter 5000 rise 2 fall 2 #定义的多个后端 listen stats bind 192.168.171.157:8100 mode http option httplog stats enable stats uri /rabbitmq-stats stats refresh 5s7.启动HAProxy
/usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg
查看haproxy进程状态
ps -ef | grep haproxy访问HAProxy
192.168.171.157:8100/rabbitmq-stats
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)