欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

haproxy軟件的日志如何輸出到指定文件

 更新時(shí)間:2024年12月18日 14:48:48   作者:忍冬行者  
本文介紹了如何將haproxy的日志從系統(tǒng)syslog中分離出來,并獨(dú)立記錄到不同的日志文件中,通過修改rsyslog配置文件和haproxy配置文件,可以實(shí)現(xiàn)這一目標(biāo),并便于后期的日志管理和分析

haproxy軟件日志輸出到指定文件

默認(rèn)haproxy的日志是輸出到系統(tǒng)syslog中,查看起來不是非常方便,為了更好的管理haproxy的日志,我們?cè)谏a(chǎn)環(huán)境中一般單獨(dú)定義出來。需要將haproxy的info及notice日志分別記錄到不同的日志文件中。

需要修改rsyslog配置,為了便于管理。

將haproxy相關(guān)的配置獨(dú)立定義到haproxy.conf,并放到/etc/rsyslog.d/下,rsyslog啟動(dòng)時(shí)會(huì)自動(dòng)加載此目錄下的所有配置文件。

默認(rèn)的haproxy的配置文件

如下

#---------------------------------------------------------------------
# Example configuration for a possible web application.  See the
# full configuration options online.
#
#   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# 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 info

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     40000
    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
    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

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
#frontend  main *:5000
#    acl url_static       path_beg       -i /static /images /javascript /stylesheets
#    acl url_static       path_end       -i .jpg .gif .png .css .js
#
#    use_backend static          if url_static
#    default_backend             app

#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
#backend static
#    balance     roundrobin
#    server      static 127.0.0.1:4331 check

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
#backend app
#    balance     roundrobin
#    server  app1 127.0.0.1:5001 check
#    server  app2 127.0.0.1:5002 check
#    server  app3 127.0.0.1:5003 check
#    server  app4 127.0.0.1:5004 check

其中日志的配置文件有關(guān)日志的配置是 log 127.0.0.1 local2 info

為了便于管理將haproxy相關(guān)的配置獨(dú)立定義到haproxy.conf

配置方式

1.編輯“/etc/sysconfig/rsyslog”文件

將如下配置增加 -r 參數(shù):

SYSLOGD_OPTIONS=""
改成
SYSLOGD_OPTIONS="-r"

2.編輯“/etc/rsyslog.conf”取消紅框部分內(nèi)容的注釋

并在“local7.*”前面插入一行:

local2.*                /var/log/haproxy/haproxy.log

3.重啟服務(wù)

重啟 rsyslog

systemctl restart rsyslog

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Ubuntu添加swap分區(qū)的方法

    Ubuntu添加swap分區(qū)的方法

    這篇文章主要介紹了Ubuntu添加swap分區(qū)的方法,提高服務(wù)器響應(yīng)速度和防止應(yīng)用程序內(nèi)存不足錯(cuò)誤的最簡單方法之一是添加一些交換空間,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2018-05-05
  • LuManager VPS主機(jī)控制面板安裝和Eduvps免費(fèi)VPS測(cè)評(píng)

    LuManager VPS主機(jī)控制面板安裝和Eduvps免費(fèi)VPS測(cè)評(píng)

    這篇文章主要介紹了LuManager VPS主機(jī)控制面板安裝和Eduvps免費(fèi)VPS測(cè)評(píng),需要的朋友可以參考下
    2016-04-04
  • Linux下“/”和“~”的區(qū)別詳解

    Linux下“/”和“~”的區(qū)別詳解

    這篇文章主要介紹了Linux下“/”和“~”的區(qū)別詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • Linux之如何設(shè)置CPU Performance模式

    Linux之如何設(shè)置CPU Performance模式

    這篇文章主要介紹了Linux之如何設(shè)置CPU Performance模式問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • 關(guān)于linux下core dump【總結(jié)】

    關(guān)于linux下core dump【總結(jié)】

    下面小編就為大家?guī)硪黄P(guān)于linux下core dump【總結(jié)】。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-01-01
  • ubuntu 16.04系統(tǒng)完美解決pip不能升級(jí)的問題

    ubuntu 16.04系統(tǒng)完美解決pip不能升級(jí)的問題

    這篇文章主要介紹了ubuntu 16.04系統(tǒng)完美解決pip不能升級(jí)的問題 ,本文圖文并茂給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2018-04-04
  • Apache之AllowOverride參數(shù)使用說明

    Apache之AllowOverride參數(shù)使用說明

    通常利用Apache的rewrite模塊對(duì) URL 進(jìn)行重寫的時(shí)候, rewrite規(guī)則會(huì)寫在 .htaccess 文件里。但要使 apache 能夠正常的讀取.htaccess 文件的內(nèi)容,就必須對(duì).htaccess 所在目錄進(jìn)行配置。
    2011-01-01
  • linux中的7z命令參數(shù)說明

    linux中的7z命令參數(shù)說明

    Linux中的7z命令具備多樣的參數(shù)來控制其功能,如添加文件、刪除、提取、更新存檔等。常用的命令包括a、d、e、x等,而開關(guān)如-o、-p、-m等則進(jìn)一步定義了操作的細(xì)節(jié),例如設(shè)置密碼、輸出目錄和壓縮方法。此命令強(qiáng)大且靈活,適合進(jìn)行文件壓縮和管理
    2024-09-09
  • linux讓程序開機(jī)自動(dòng)運(yùn)行最簡單的方法

    linux讓程序開機(jī)自動(dòng)運(yùn)行最簡單的方法

    在本篇文章里小編給大家整理的是一篇關(guān)于linux讓程序開機(jī)自動(dòng)運(yùn)行最簡單的方法以及相關(guān)代碼,需要的朋友們學(xué)習(xí)下。
    2019-11-11
  • 初窺Linux 之我最常用的20條命令總結(jié)

    初窺Linux 之我最常用的20條命令總結(jié)

    Linux中的命令的確是非常多,我們只需要了解常用的命令就可以了,本篇文章介紹了Linux 之我最常用的20條命令總結(jié),有興趣的可以了解一下。
    2016-12-12

最新評(píng)論