我是靠谱客的博主 故意翅膀,最近开发中收集的这篇文章主要介绍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

转载于:https://www.cnblogs.com/bugbeta/p/10881292.html

最后

以上就是故意翅膀为你收集整理的haproxy安装及配置的全部内容,希望文章能够帮你解决haproxy安装及配置所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部