标签:openstack ha
1、安装haproxy
# yum install -y haproxy
# systemctl enable haproxy.service
2、配置haproxy日志
[root@controller1 ~]# cd /etc/rsyslog.d/
[root@controller1 rsyslog.d]# vim haproxy.conf
$ModLoad imudp
$UDPServerRun 514
$template Haproxy,"%msg%"
local0.=info -/var/log/haproxy.log;Haproxy
local0.notice -/var/log/haproxy-status.log;Haproxy
local0.* ~
[root@controller1 ~]# scp /etc/rsyslog.d/haproxy.conf controller2:/etc/rsyslog.d/
haproxy.conf 100% 164 0.2KB/s 00:00
[root@controller1 ~]# scp /etc/rsyslog.d/haproxy.conf controller3:/etc/rsyslog.d/
启动rsyslog
[root@controller1 ~]# systemctl restart rsyslog.service
[root@controller1 ~]# systemctl status rsyslog.service
配置haproxy
[root@controller1 ~]# vim /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
# common defaults that all the ‘listen‘ and ‘backend‘ sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
stats uri /haproxy-stats
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
listen haproxy-status
bind *:80
option http-server-close
option forwardfor
default_backend httpd
maxconn 10
stats refresh 30s
stats hide-version
stats auth admin:admin
stats uri /haproxy-stats
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
listen httpd
balance roundrobin
mode http
option httplog
# option httpchk HEAD / HTTP/1.1\r\nHost:\ localhost
# option httpchk GET /index.html
server controller1 controller1:8080 check
server controller2 controller2:8080 check
server controller3 controller3:8080 check
listen mysql
balance roundrobin
mode http
option httplog
server controller1 controller1:3306 check
server controller2 controller2:3306 check
server controller3 controller3:3306 check
listen keystone_api_cluster
# bind 192.168.17.132:5000
balance source
option tcpka
option httpchk
option tcplog
server controller1 controller1:5000 check inter 2000 rise 2 fall 5
server controller2 controller2:5000 check inter 2000 rise 2 fall 5
server controller3 controller3:5000 check inter 2000 rise 2 fall 5
listen cinder_api_cluster
bind 192.168.17.132:8776
balance source
option tcpka
option httpchk
option tcplog
server controller1 controller1:8778 check inter 2000 rise 2 fall 5
server controller2 controller2:8778 check inter 2000 rise 2 fall 5
server controller3 controller3:8778 check inter 2000 rise 2 fall 5
listen nova_vncproxy_cluster
bind 192.168.17.132:6080
balance source
option tcpka
option httpchk
option tcplog
server controller1 controller1:6081 check inter 2000 rise 2 fall 5
server controller2 controller2:6081 check inter 2000 rise 2 fall 5
server controller3 controller3:6081 check inter 2000 rise 2 fall 5
listen neutron_api_cluster
bind 192.168.17.132:9696
balance source
option tcpka
option httpchk
option tcplog
server controller1 controller1:9797 check inter 2000 rise 2 fall 5
server controller2 controller2:9797 check inter 2000 rise 2 fall 5
server controller3 controller3:9797 check inter 2000 rise 2 fall 5
[root@controller1 ~]# scp /etc/haproxy/haproxy.cfg controller2:/etc/haproxy/
[root@controller1 ~]# scp /etc/haproxy/haproxy.cfg controller3:/etc/haproxy/
[root@controller1 ~]# systemctl restart haproxy
[root@controller1 ~]# systemctl status haproxy
本文出自 “技术成就梦想” 博客,请务必保留此出处http://andyliu.blog.51cto.com/518879/1917398
标签:openstack ha
原文地址:http://andyliu.blog.51cto.com/518879/1917398