openstack haproxy配置

openstack haproxy配置node

####全部控制節點配置
yum
install haproxy -y ############haproxy配置, #容許沒VIP時啓動 echo "net.ipv4.ip_nonlocal_bind = 1" >>/etc/sysctl.conf sysctl -p #haproxy日誌 echo ' $ModLoad imudp $UDPServerRun 514 $template Haproxy,"%rawmsg% \n" local0.=info -/var/log/haproxy.log;Haproxy local0.notice -/var/log/haproxy-status.log;Haproxy ' >/etc/rsyslog.d/haproxy.conf systemctl status rsyslog.service systemctl restart rsyslog.service cp /etc/haproxy/haproxy.cfg{,.bak} ##############默認配置 echo ' ###########全局配置######### global log 127.0.0.1 local0 log 127.0.0.1 local1 notice daemon nbproc 1 #進程數量 maxconn 4096 #最大鏈接數 user haproxy #運行用戶 group haproxy #運行組 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid ########默認配置############ defaults log global mode http #默認模式{ tcp|http|health } option httplog #日誌類別,採用httplog option dontlognull #不記錄健康檢查日誌信息 retries 2 #2次鏈接失敗不可用 option forwardfor #後端服務得到真實ip option httpclose #請求完畢後主動關閉http通道 option abortonclose #服務器負載很高,自動結束比較久的連接 maxconn 4096 #最大鏈接數 timeout connect 5m #鏈接超時 timeout client 1m #客戶端超時 timeout server 31m #服務器超時 timeout check 10s #心跳檢測超時 balance roundrobin #負載均衡方式,輪詢 ########統計頁面配置######## listen stats :8100 mode http option httplog stats enable stats uri /stats stats refresh 5s ' >/etc/haproxy/haproxy.cfg systemctl restart haproxy.service curl -I 'http://127.0.0.1:8100/stats' ######### echo ' ########WEB############ listen dashboard_cluster bind :80 balance source option tcpka option httpchk option tcplog server node171 192.168.0.171:8080 check port 8080 inter 2000 rise 2 fall 5 server node172 192.168.0.172:8080 check port 8080 inter 2000 rise 2 fall 5 server node173 192.168.0.173:8080 check port 8080 inter 2000 rise 2 fall 5 server node174 192.168.0.174:8080 check port 8080 inter 2000 rise 2 fall 5 ' >>/etc/haproxy/haproxy.cfg sed -i 's#^Listen.*80#Listen 8080#' /etc/httpd/conf/httpd.conf grep '^Listen' /etc/httpd/conf/httpd.conf systemctl restart httpd systemctl status httpd netstat -lntp |grep httpd systemctl restart haproxy systemctl status haproxy