Haproxy集羣
Haproxy輪詢集羣不僅可以輪詢傳輸層,也可以輪詢應用層服務。
搭建Haproxy集羣
#yum -y install haproxy
1)監控端口服務
[haproxy:50]
#vim /etc/haproxy/haproxy.cfg
frontend 描述接受客戶端偵聽套結字
frontend web *:80
default_backend app
backend 描述轉發鏈接的服務器集
backend app
backend roundrobin
server app1 192.168.4.53:80 check
server app1 192.168.4.52:80 check
#service haproxy start
#elinks --dump http://192.168.4.50
2)針對不同web頁面轉發給不同的服務器集
frontend web *:80
acl url_html path_end -i .html 設置策略,檢測url的末尾,以.html 結尾 ,策略名爲url_html
use_backend html_group if url_html 如果是url_html策略,則轉給html_group 服務器集
acl url_php path_end -i .php
use_backend php_group if url_php
default_backend html_group
backend html_group
balance roundrobin
server web51 192.168.4.51:80 check
server web52 192.168.4.52:80 check
backend php_group
balance roundrobin
server web53 192.168.4.53:80 check
server web54 192.168.4.54:80 check
這樣就可以根據不同的url結尾訪問html頁面或者是php頁面