Chinaunix首页 | 论坛 | 博客

OPS

  • 博客访问: 489792
  • 博文数量: 117
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1210
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-05 14:50
个人简介

hellow 运维

文章分类

全部博文(117)

文章存档

2019年(1)

2018年(1)

2017年(45)

2016年(38)

2015年(32)

我的朋友

分类: 系统运维

2016-05-26 10:31:19


[root@mysql login]# cat /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
# Example configuration for a possible web application.  See the
# full configuration options online.
#
#  
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    # to have these messages end up in /var/log/haproxy.log you will
    # need to:
    #
    # 1) configure syslog to accept network log events.  This is done
    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
    #    /etc/sysconfig/syslog
    #
    # 2) configure local2 events to go to the /var/log/haproxy.log
    #   file. A line like the following can be added to
    #   /etc/sysconfig/syslog
    #
    #    local2.*                       /var/log/haproxy.log
    #
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    # turn on stats unix socket
    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      #日志格式是httpd格式
    option                  dontlognull  #httpd请求完毕,自动关闭连接通道
    option http-server-close             #不记录健康监测日志
    option forwardfor       except 127.0.0.0/8 #后端web记录访问的真实ip地址,需要在后端配置文件上记录LogFormat上添加“%{X-Forwarded-For}i”
    option                  redispatch   #后端server单挂机,自动切换位健康主机
    retries                 3    #健康监测检查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
   errorfile 403 /data/sh/hanye.html
   errorfile 503 /data/sh/hanye1.html

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main
     log global
     bind :80
     bind :8089
     maxconn 4000

     acl nginx path_beg   -i /www  /static /images /styles /vides
     acl nginx path_end   -i  .jsp .css .js .php .png .jpg
     acl login path_beg /login
     redirect location if login

     acl httpd   dst_port    8089
     redirect prefix if httpd

     acl host   hdr(host)   -i hanye.com

     use_backend static  if nginx
     use_backend webserver   if  host
    default_backend webserver
#---------------------------------------------------------------------
backend webserver
   balance  roundrobin
   cookie webserver insert nocache
   server s2 192.168.0.170:8080  check port 8080 maxconn 1500 inter 2000 rise 3 fall 3  maxconn 1500 weight 2
   #server s1 192.168.0.171:8080  check port 8080 maxconn 1500 inter 2000 rise 3 fall 3  maxconn 1500 weight 2
backend static
   cookie png insert nocache
    server a1 192.168.0.171:8080  check port 8080 inter 2000 rise 3 fall 3  maxconn 1500

listen status
     bind :19999
     stats enable
     stats hide-version
     stats scope .
     stats uri /haroxy?admin
     stats auth admin:admin
     stats admin if TRUE
[root@mysql login]# cat /etc/haproxy/haproxy.cfg.mysql
global
    # to have these messages end up in /var/log/haproxy.log you will
    # need to:
    #
    # 1) configure syslog to accept network log events.  This is done
    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
    #    /etc/sysconfig/syslog
    #
    # 2) configure local2 events to go to the /var/log/haproxy.log
    #   file. A line like the following can be added to
    #   /etc/sysconfig/syslog
    #
    #    local2.*                       /var/log/haproxy.log
    #
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

defaults
    mode                    tcp
    log                     global
    option                  tcplog
    option                  dontlognull
    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                 600

listen stats
    mode http
    bind 0.0.0.0:1080
    stats enable
    stats hide-version
    stats uri     /haproxyadmin?stats
    stats realm   Haproxy\ Statistics
    stats auth    admin:admin
    stats admin if TRUE


frontend mysql
    bind *:1000
    mode tcp
    log global
    default_backend mysqlservers

backend mysqlservers
    balance leastconn
    server dbsrv1 192.168.0.170:3306 check port 3306 inter 2000 rise 1 fall 2 maxconn 300 weight 2
    server dbsrv2 192.168.0.171:3306 check port 3306 inter 2000 rise 1 fall 2 maxconn 300 weight 1

阅读(1489) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~