1)配置網路,安裝軟體
yum -y install haproxy
2)修改配置檔案vim /etc/haproxy/haproxy.cfgglobal log3)啟動伺服器並設定開機啟動…listen websrv-rewrite 0.0.0.0:80
balance roundrobin
server web1 192.168.2.100:80 check inter 2000 rise 2 fall 5
server web2 192.168.2.200:80 check inter 2000 rise 2 fall 5
…定義web伺服器可多台…
systemctl start haproxy
systemctl enable haproxy
安裝keepalived軟體
注意:兩台haproxy伺服器做相同的操作
web1 ~]# yum install -y keepalived
web2 ~]# yum install -y keepalived
修改兩台haproxy伺服器keepalived配置檔案
vim /etc/keepalived/keepalived.conf
global_defsnotification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id web-haproxy-0001
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
vrrp_iptables
}
vrrp_instance vi_13)啟動兩台伺服器服務virtual_ipaddress
}real_server 192.168.4.100 80
}real_server 192.168.4.200 80
}
systemctl start keepalived
總體配置對應解釋:global_defsnotification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id web-haproxy-0001
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
vrrp_iptables
}global_defs
notification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id web-haproxy-0001
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
haproxy簡介與安裝
有關高負載均衡方法比較多,軟體如haproxy nginx和lvs,硬體如f5。haproxy 簡介 haproxy 是一款高效能tcp http 反向 負載均衡伺服器,目前用它做前端 tcp負載。haproxy原理 haproxy提供高可用性 負載均衡以及基於tcp 第四層 和http 第七層 應...
openstack 例項配置keepalived
bin bash nginx1 192.168.97.101 nginx2 192.168.97.102 vip 192.168.97.241 安裝軟體 yum install nginx wget echo e 192.168.97.101 nginx master usr share nginx...
systemctl無法停掉keepalived
這個問題搞了好半天,記錄一下,啟停都是用的systemctl 起初是測試vip漂移時候發現,主備節點都開啟keepalived的狀況下,一切正常,主節點的vip也可以訪問。第一次停掉主節點的keepalived程式時,vip順利漂移到從節點 再次啟動主節點keepalived,vip順利漂移到主節點...