Openstack Ocata 负载均衡安装(二)

Openstack OCATA 负载节点(二)

安装haproxy:

apt install haproxy

配置haproxy:

vim /etc/haproxy/haproxy.cfg

global
maxconn 100000
#chroot /usr/local/haproxy
#stats socket /var/lib/haproxy/haproxy.sock mode 600 level admin
uid 99
gid 99
daemon
#nbproc 4
#cpu-map 1 0
#cpu-map 2 1
#cpu-map 3 2
#cpu-map 4 3
#pidfile /usr/local/haproxy/run/haproxy.pid
log 127.0.0.1 local3 info

defaults
option http-keep-alive
option  forwardfor
maxconn 100000
mode http
timeout connect 300000ms
timeout client  300000ms
timeout server  300000ms

listen stats
 mode http
 bind 0.0.0.0:9999
 stats enable
 log global
 stats uri     /haproxy-status
 stats auth    haadmin:q1w2e3r4ys

listen  openstack_mysql_port
 bind 0.0.0.0:3306
 mode tcp
 log global
 server 10.10.5.150 10.10.5.150:3306 check inter 3000 fall 2 rise 5

listen  openstack_rabbitmq_port
 bind 0.0.0.0:5672
 mode tcp
 log global
 server 10.10.5.150 10.10.5.150:5672 check inter 3000 fall 2 rise 5
 #server 10.10.5.151 10.10.5.151:5672 check inter 3000 fall 2 rise 5 backup

listen  openstack_mem_port
 bind 0.0.0.0:11211
 mode tcp
 log global
 server 10.10.5.150 10.10.5.150:11211 check inter 3000 fall 2 rise 5

################################以上内容在 公共服务完成后填写进去############################################

启动haproxy 服务:

/etc/init.d/haproxy restart
/etc/init.d/haproxy status

验证haproxy 是否好用:

root@ha-1:~# ss -tunlpa
Netid       State         Recv-Q        Send-Q                Local Address:Port                Peer Address:Port                                                                         
tcp         LISTEN        0             128                         0.0.0.0:22                       0.0.0.0:*            users:(("sshd",pid=909,fd=3))                                      
tcp         LISTEN        0             5                         127.0.0.1:631                      0.0.0.0:*            users:(("cupsd",pid=800,fd=7))                                     
tcp         LISTEN        0             128                       127.0.0.1:6010                     0.0.0.0:*            users:(("sshd",pid=1355,fd=9))                                     
tcp         LISTEN        0             128                         0.0.0.0:5672                     0.0.0.0:*            users:(("haproxy",pid=1962,fd=9))                                  
tcp         LISTEN        0             128                         0.0.0.0:3306                     0.0.0.0:*            users:(("haproxy",pid=1962,fd=8))                                  
tcp         LISTEN        0             128                         0.0.0.0:11211                    0.0.0.0:*            users:(("haproxy",pid=1962,fd=10))                                 
tcp         ESTAB         0             52                      10.10.5.140:22                     10.10.5.1:9221         users:(("sshd",pid=1355,fd=3))                                     
原文地址:https://www.cnblogs.com/zhenxing06/p/13025283.html