openstack paroxy配置

fyggzb 2019-11-08

openstack paroxy配置

####所有控制节点配置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

相关推荐