Rsyslog

From 탱이의 잡동사니
Revision as of 12:41, 13 June 2017 by Pchero (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

rsyslog(rocket-fast system for log) 내용 정리.

Basic

기본적으로 rsyslog 는 syslog 의 확장 버전이다. 로그 레벨과 관련된 기본적인 내용은 syslog 를 참조하면 된다.

TCP vs UDP logging

rsyslog 는 TCP 혹은 UDP 를 이용한 로깅을 지원한다.

TCP 를 이용할 경우, 흐름제어를 통한 메시징 관리로, 모든 메시지를 정확하게 전달이 가능하게 되지만, UDP 를 이용할 경우, 100% 메시지 전달을 기대할 수는 없다.

하지만 TCP 를 이용하게 되면, 대용량의 메시지를 전송할 경우, 소켓에 무리가 가게되어, 시스템 장애를 일으키게 되는 원인이 될 수 있다. 하지만 UDP 를 사용하게 되면 이런 문제에서 자유로워 진다.

즉, 기본은 UDP 를 사용하되, 특별한 이유가 있다면 TCP 를 사용하는 것이 좋다.

처음 rsyslog 를 사용해본 어느 바보에게 팀장이 보낸 메일. 2017.06.13

...
Not using 'user', see facility

this is not a random user program, so we use localX to identify it.

other change.. 
we are not going to use TCP, it might be reliable in transferring data, but alot of data overloaded on the socket, 
and there is a posibility to halt/buffer full the voicemail server. 

I'm not sacrificing production uptime to have logging.. 

so we are sticking to UDP, you can live with the few loglines that might get lost when reloading/rebooting the destination host.

Configuration

rsyslog 의 기본 설정파일은 /etc/rsyslog.conf 파일이다.

온라인으로 설정파일을 생성할 수 있다.

Example

#  /etc/rsyslog.conf	Configuration file for rsyslog.
#
#			For more information see
#			/usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#
#  Default logging rules can be found in /etc/rsyslog.d/50-default.conf


#################
#### MODULES ####
#################

$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog   # provides kernel logging support
#$ModLoad immark  # provides --MARK-- message capability

# provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

# provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514

# Enable non-kernel facility klog messages
$KLogPermitNonKernelFacility on

###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# Filter duplicated messages
$RepeatedMsgReduction on

#
# Set the default permissions for all log files.
#
$FileOwner syslog
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$PrivDropToUser syslog
$PrivDropToGroup syslog

#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf