zoukankan      html  css  js  c++  java
  • haproxy安装及配置

    安装

    操作系统:Centos7.4

    yum install haproxy


    配置


    [root@wsjy-proxy01 haproxy]# cat haproxy.cfg
    global
        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        stats socket /var/run/haproxy-admin.sock mode 660 level admin
        stats timeout 30s
        user haproxy
        group haproxy
        daemon
        nbproc 1
    
    defaults
        log     global
        timeout connect 5000
        timeout client  10m
        timeout server  10m
    
    listen  admin_stats
        bind 0.0.0.0:10080
        mode http
        log 127.0.0.1 local0 err
        stats refresh 30s
        stats uri /status
        stats realm welcome login Haproxy
        stats auth admin:123456
        stats hide-version
        stats admin if TRUE
    
    listen wsjy_proxy
        bind 0.0.0.0:80
        mode tcp
        option tcplog
        balance source
        server 10.101.75.121 10.101.75.121:30080 check inter 2000 fall 2 rise 2 weight 1
        server 10.101.75.122 10.101.75.122:30080 check inter 2000 fall 2 rise 2 weight 1
        server 10.101.75.123 10.101.75.123:30080 check inter 2000 fall 2 rise 2 weight 1


    systemctl restart haproxy

    日志配置

    /etc/rsyslog.conf 添加:

    # /dev/log to chroot'ed HAProxy processes
    $AddUnixListenSocket /dev/log
    if $programname startswith 'haproxy' then /var/log/haproxy/haproxy.log

    [root@wsjy-proxy01 haproxy]# systemctl restart rsyslog


    日志查看


    [root@wsjy-proxy01 haproxy]# tailf /var/log/haproxy/haproxy.log 
    May 17 14:43:53 wsjy-proxy01 haproxy-systemd-wrapper: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
    May 17 14:43:53 wsjy-proxy01 haproxy[1985]: Proxy admin_stats started.
    May 17 14:43:53 wsjy-proxy01 haproxy[1985]: Proxy admin_stats started.
    May 17 14:43:53 wsjy-proxy01 haproxy[1985]: Proxy wsjy_proxy started.
    May 17 14:43:53 wsjy-proxy01 haproxy[1985]: Proxy wsjy_proxy started.
    May 17 14:43:53 wsjy-proxy01 haproxy[1985]: Proxy wsjy_public_proxy started.
    May 17 14:43:53 wsjy-proxy01 haproxy[1985]: Proxy wsjy_public_proxy started.


    参考

    https://unix.stackexchange.com/questions/260940/does-haproxy-support-logging-to-a-file

  • 相关阅读:
    init进程解析rc文件的相关函数分析
    Ubuntu 安装Android Studio与使用手册
    Vim的撤销与重做
    Vim 配色设置与配色脚本语法
    js常用的语句
    xshell常用的命令
    java常用的语句
    maven工程配置日志
    根据一个oss的pdf文件的 地址转换成一个File文件
    根据一个oss的地址把图片转换成一个文件
  • 原文地址:https://www.cnblogs.com/bugbeta/p/10881292.html
Copyright © 2011-2022 走看看