標籤:haproxy 日誌配置
涉及到的設定檔如下 1) /etc/haproxy/haproxy.conf //這個是haproxy程式的主設定檔,具體路徑可以隨意指定,主要是下面這句話 log localhost local0 2) /etc/rsyslog.conf //這個設定檔不用動,預設會有下面的設定,會讀取 /etc/rsyslog.d/*.conf目錄 //下的設定檔 $IncludeConfig /etc/rsyslog.d/*.conf 3) /etc/rsyslog.d/haproxy.conf //這個檔案是需要我們手動建立的,內容如下: cat /etc/rsyslog.d/haproxy.conf $ModLoad imudp $UDPServerRun 514 $template Haproxy,"%rawmsg% \n" local0.=info -/var/log/haproxy.log;Haproxy local0.notice -/var/log/haproxy-status.log;Haproxy ### keep logs in localhost ## local0.* ~ 4) /etc/sysconfig/rsyslog 內容如下 # Options for rsyslogd # Syslogd options are deprecated since rsyslog v3. # If you want to use them, switch to compatibility mode 2 by "-c 2" # See rsyslogd(8) for more details SYSLOGD_OPTIONS="-c 2 -r -m 0" 備忘: #-c 2 使用相容模式,預設是 -c 5 #-r 開啟遠程日誌 #-m 0 標記時間戳記。單位是分鐘,為0時,表示禁用該功能 好了,日誌配置主要就是涉及到這幾個檔案了。 另外,再重啟下rsyslog和haproxy服務就可以了 centos 6: /etc/init.d/rsyslog restart centos 7: systemctl restart rsyslog killlall -9 haproxy && haproxy -f /etc/haproxy/haproxy.conf 最後,最重要的一點,一定要把iptables udp 514連接埠開起來 iptables -I INPUT -m udp -p udp --dport 514 -j ACCEPT 否則有可能會報一堆錯誤,類似下面這樣子: sendto logger #0 failed: operation not permitted (errno=1)
centos下haproxy日誌的配置