mancha 发表于 2018-5-31 08:18:27

OpenStack HA集群4

  1、安装haproxy
  # yum install -y haproxy
  # systemctl enable haproxy.service
  2、配置haproxy日志
  # cd /etc/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.* ~
  # scp /etc/rsyslog.d/haproxy.conf controller2:/etc/rsyslog.d/
  haproxy.conf                                       100%164   0.2KB/s   00:00
  # scp /etc/rsyslog.d/haproxy.conf controller3:/etc/rsyslog.d/
  启动rsyslog
  # systemctl restart rsyslog.service
  # systemctl status rsyslog.service
  配置haproxy
  # 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
  statsuri    /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
  statsuri    /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
  # optionhttpchk GET /index.html
  servercontroller1 controller1:8080 check
  servercontroller2 controller2:8080 check
  servercontroller3 controller3:8080 check
  listen mysql
  balance   roundrobin
  mode      http
  option      httplog
  servercontroller1 controller1:3306 check
  servercontroller2 controller2:3306 check
  servercontroller3 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
  # scp /etc/haproxy/haproxy.cfg controller2:/etc/haproxy/
  # scp /etc/haproxy/haproxy.cfg controller3:/etc/haproxy/
  # systemctl restart haproxy
  # systemctl status haproxy
  
页: [1]
查看完整版本: OpenStack HA集群4