OpenStack HA集群4-Haproxy

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenStack HA集群4-Haproxy相关的知识,希望对你有一定的参考价值。

1、安装haproxy

# yum install -y haproxy

# systemctl enable haproxy.service

2、配置haproxy日志

[[email protected] ~]# cd /etc/rsyslog.d/

[[email protected] 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.* ~

[[email protected] ~]# scp /etc/rsyslog.d/haproxy.conf controller2:/etc/rsyslog.d/

haproxy.conf                                       100%  164     0.2KB/s   00:00   

[[email protected] ~]# scp /etc/rsyslog.d/haproxy.conf controller3:/etc/rsyslog.d/

启动rsyslog

[[email protected] ~]# systemctl restart rsyslog.service

[[email protected] ~]# systemctl status rsyslog.service

配置haproxy

[[email protected] ~]# 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

 [[email protected] ~]# scp /etc/haproxy/haproxy.cfg controller2:/etc/haproxy/

 

[[email protected] ~]# scp /etc/haproxy/haproxy.cfg controller3:/etc/haproxy/

[[email protected] ~]# systemctl restart haproxy

[[email protected] ~]# systemctl status haproxy


本文出自 “技术成就梦想” 博客,请务必保留此出处http://andyliu.blog.51cto.com/518879/1917398

以上是关于OpenStack HA集群4-Haproxy的主要内容,如果未能解决你的问题,请参考以下文章

OpenStack HA集群4-Haproxy

OpenStack HA集群3-Pacemake Corosync

openstack 高可用(HA)- Mariadb

OpenStack Mitaka HA部署方案(随笔)

Hadoop-HA集群

openstack controller ha测试环境搭建记录——配置keystone