Configure the VIP & HAProxy

Configure the VIP

  1. [root@controller1 ~]# pcs resource create vip ocf:heartbeat:IPaddr2 ip="192.168.220.20" cidr_netmask="24" op monitor interval="30s"

Installing HAProxy On Controllers

  1. [root@controller ~]# yum install haproxy httpd -y

Configuring HAProxy

  1. [root@controller1 ~]# cp /etc/haproxy/haproxy.cfg{,.bak}
  2.  
  3. [root@controller1 ~]# diff /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak
  4. 87,99d86
  5. < listen stats  
  6. <       bind 0.0.0.0:1080 
  7. <       mode http
  8. <       option httplog
  9. <       log 127.0.0.1 local0 err  
  10. <       maxconn 10
  11. <       stats refresh 30s
  12. <       stats uri /admin
  13. <       stats realm Haproxy\ Statistics
  14. <       stats auth admin:admin
  15. <       stats hide-version
  16. <       stats admin if TRUE
  17. < 
  18.  
  19. [root@controller1 ~]# scp /etc/haproxy/haproxy.cfg [email protected]:/etc/haproxy/haproxy.cfg
  20. [root@controller1 ~]# scp /etc/haproxy/haproxy.cfg [email protected]:/etc/haproxy/haproxy.cfg

Allow Non-Local IP Binding

  1. [root@controller ~]# echo "net.ipv4.ip_nonlocal_bind = 1" >>/etc/sysctl.conf
  2. [root@controller ~]# sysctl -p
  3. net.ipv4.ip_nonlocal_bind = 1

Add HAProxy To The Cluster

  1. [root@controller1 ~]# pcs resource create lb-haproxy systemd:haproxy --clone
  2. [root@controller1 ~]# pcs constraint order start vip then lb-haproxy-clone kind=Optional
  3. Adding vip lb-haproxy-clone (kind: Optional) (Options: first-action=start then-action=start)
  4. [root@controller1 ~]# pcs constraint colocation add lb-haproxy-clone with vip

Now, Take the Browser

http://192.168.220.20:1080/admin

username/password :

admin/admin

Add RabbitMQTo The HAProxy

  1. [root@controller1 ~]# echo '#RabbitMQ
  2. > listen RabbitMQ-Server
  3. > bind controller:5673
  4. > mode tcp
  5. > balance roundrobin
  6. > option tcpka
  7. > timeout client  3h
  8. > timeout server  3h
  9. > option          clitcpka
  10. > server controller1 controller1:5672 check inter 5s rise 2 fall 3
  11. > server controller2 controller2:5672 check inter 5s rise 2 fall 3
  12. > server controller3 controller3:5672 check inter 5s rise 2 fall 3
  13. > 
  14. > listen RabbitMQ-Web
  15. > bind controller:15673
  16. > mode tcp
  17. > balance roundrobin
  18. > option tcpka
  19. > server controller1 controller1:15672 check inter 5s rise 2 fall 3
  20. > server controller2 controller2:15672 check inter 5s rise 2 fall 3
  21. > server controller3 controller3:15672 check inter 5s rise 2 fall 3
  22. > '>>/etc/haproxy/haproxy.cfg
  23. [[email protected] ~]# 
  24. [[email protected] ~]# systemctl restart haproxy.service

Leave a Reply

Your email address will not be published. Required fields are marked *