OpenStack HA集群4-Haproxy

简介:

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

本文转自    OpenStack2015 博客,原文链接:   http://blog.51cto.com/andyliu/1917398     如需转载请自行联系原作者



相关文章
|
Kubernetes API Docker
如何用Ansible部署Kubernetes集群到OpenStack
最近的Austin OpenStack峰会上,参会者中对容器感兴趣的人数之多,让我印象深刻。几乎所有跟容器相关的会议现在都意识到了它的优点。通过将应用程序容器化,就能够将主机操作系统虚拟化。这也就意味着,你可以在主机操作系统中为每个容器创建隔离环境,比如文件系统,网络堆栈和进程空间,令容器之间互相可见。
2932 0
|
消息中间件 Kafka Apache
OpenStack 上搭建 Kafka 集群
Kafka 最近在 OpenStack 环境下需要部署消息队列集群,包括 RabbitMQ 和 Kafka,这篇记述一下 Kafka 集群的部署过程。
2563 0
|
消息中间件 监控 负载均衡
|
关系型数据库 MySQL 开发工具
|
消息中间件 负载均衡 关系型数据库