rsyslog.conf 수정할 내용

해당 파일에 아래 내용 수정 및 추가하기

# syslog 수신 포트 설정
module(load="imudp") # 주석 제거하여 활성화
input(type="imudp" port="514") # 주석 제거하여 활성화

# syslog 수신 시 저장할 위치 및 파일 설정 템플릿
$template Remote,"/var/log/rsyslog/%fromhost-ip%/%$YEAR%-%$MONTH%-%$DAY%.log" 

# syslog 수신 시 fromhost-ip가 127.0.0.1이 아닌 경우 템플릿 Remote 정책을 적용
:fromhost-ip, !isequal, "127.0.0.1" ?Remote

# 템플릿 Remote로 수신한 경우 로그 처리 중지
# 중지하지 않을 경우, OS에서 수집하는 syslog나 message에도 로그가 수집 됨 (중복 수집 됨)
& stop

 

rsyslog.conf 전체 내용 (수정할 로그의 위치 파악용)

[root@localhost ~]# cat /etc/rsyslog.conf
# rsyslog configuration file

# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# or latest version online at http://www.rsyslog.com/doc/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html

#### GLOBAL DIRECTIVES ####

# Where to place auxiliary files
global(workDirectory="/var/lib/rsyslog")

# Use default timestamp format
module(load="builtin:omfile" Template="RSYSLOG_TraditionalFileFormat")

# Include all config files in /etc/rsyslog.d/
include(file="/etc/rsyslog.d/*.conf" mode="optional")

#### MODULES ####

module(load="imuxsock"    # provides support for local system logging (e.g. via logger command)
       SysSock.Use="off") # Turn off message reception via local log socket;
                          # local messages are retrieved through imjournal now.
module(load="imjournal"             # provides access to the systemd journal
       StateFile="imjournal.state") # File to store the position in the journal
#module(load="imklog") # reads kernel messages (the same are read from journald)
#module(load="immark") # provides --MARK-- message capability

# Provides UDP syslog reception
# for parameters see http://www.rsyslog.com/doc/imudp.html
module(load="imudp") # needs to be done just once 주석제거하여 활성화
input(type="imudp" port="514") # 주석제거하여 활성화

# Provides TCP syslog reception
# for parameters see http://www.rsyslog.com/doc/imtcp.html
#module(load="imtcp") # needs to be done just once
#input(type="imtcp" port="514")

#### Template ###
$template Remote,"/var/log/rsyslog/%fromhost-ip%/%$YEAR%-%$MONTH%-%$DAY%.log"

#### RULES ####

# 로그가 Remote template을 거친 경우 여기서 로그 수집 중단
# 로그 수집이 중단되지 않을 경우 해당 경로 이후의 syslog 프로세스를 거침
# 일반적으로 syslog나 message 파일에 등록 되어 Remote template에도 등록이 되었기 때문에 중복 메시지가 됨.
:fromhost-ip, !isequal, "127.0.0.1" ?Remote
& stop

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                                                 /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none                /var/log/messages

# The authpriv file has restricted access.
authpriv.*                                              /var/log/secure

# Log all the mail messages in one place.
mail.*                                                  -/var/log/maillog


# Log cron stuff
cron.*                                                  /var/log/cron

# Everybody gets emergency messages
*.emerg                                                 :omusrmsg:*

# Save news errors of level crit and higher in a special file.
uucp,news.crit                                          /var/log/spooler

# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log


# ### sample forwarding rule ###
#action(type="omfwd"
# # An on-disk queue is created for this action. If the remote host is
# # down, messages are spooled to disk and sent when it is up again.
#queue.filename="fwdRule1"       # unique name prefix for spool files
#queue.maxdiskspace="1g"         # 1gb space limit (use as much as possible)
#queue.saveonshutdown="on"       # save messages to disk on shutdown
#queue.type="LinkedList"         # run asynchronously
#action.resumeRetryCount="-1"    # infinite retries if host is down
# # Remote Logging (we use TCP for reliable delivery)
# # remote_host is: name/ip, e.g. 192.168.0.1, port optional e.g. 10514
#Target="remote_host" Port="XXX" Protocol="tcp")

'기술 노트 > rsyslog' 카테고리의 다른 글

rsyslog 서비스로 syslog 수신하기  (0) 2023.02.15

rsyslog 설치하기

# yum install rsyslog

마지막 메타자료 만료확인 0:07:16 이전인: 2023년 02월 15일 (수) 오전 10시 50분 38초.

종속성이 해결되었습니다.

=====================================================================================================================

 꾸러미                          구조                 버전                             레포지터리               크기

=====================================================================================================================

설치 중:

 rsyslog                         x86_64               8.2102.0-109.el9                 appstream               764 k

종속 꾸러미 설치 중:

 libestr                         x86_64               0.1.11-4.el9                     appstream                26 k

 libfastjson                     x86_64               0.99.9-3.el9                     appstream                39 k

취약한 종속 꾸러미 설치 중:

 rsyslog-logrotate               x86_64               8.2102.0-109.el9                 appstream                11 k

 

연결 요약

=====================================================================================================================

설치  4 꾸러미

 

총계 내려받기 크기: 840 k

설치된 크기 : 2.6 M

진행할까요? [y/N]: y

꾸러미 내려받기 중:

(1/4): libestr-0.1.11-4.el9.x86_64.rpm                                                61 kB/s |  26 kB     00:00

(2/4): libfastjson-0.99.9-3.el9.x86_64.rpm                                            69 kB/s |  39 kB     00:00

(3/4): rsyslog-logrotate-8.2102.0-109.el9.x86_64.rpm                                  79 kB/s |  11 kB     00:00

(4/4): rsyslog-8.2102.0-109.el9.x86_64.rpm                                           205 kB/s | 764 kB     00:03

---------------------------------------------------------------------------------------------------------------------

합계                                                                                 152 kB/s | 840 kB     00:05

연결 확인 실행 중

연결 확인에 성공했습니다.

연결 시험 실행 중

연결 시험에 성공했습니다.

연결 실행 중

  준비 중           :                                                                                            1/1

  설치 중           : libfastjson-0.99.9-3.el9.x86_64                                                            1/4

  설치 중           : libestr-0.1.11-4.el9.x86_64                                                                2/4

  설치 중           : rsyslog-logrotate-8.2102.0-109.el9.x86_64                                                  3/4

  설치 중           : rsyslog-8.2102.0-109.el9.x86_64                                                            4/4

  스크립트릿 실행 중: rsyslog-8.2102.0-109.el9.x86_64                                                            4/4

Created symlink /etc/systemd/system/multi-user.target.wants/rsyslog.service → /usr/lib/systemd/system/rsyslog.service.

 

  확인 중           : libestr-0.1.11-4.el9.x86_64                                                                1/4

  확인 중           : libfastjson-0.99.9-3.el9.x86_64                                                            2/4

  확인 중           : rsyslog-8.2102.0-109.el9.x86_64                                                            3/4

  확인 중           : rsyslog-logrotate-8.2102.0-109.el9.x86_64                                                  4/4

 

설치되었습니다:

  libestr-0.1.11-4.el9.x86_64                  libfastjson-0.99.9-3.el9.x86_64    rsyslog-8.2102.0-109.el9.x86_64
  rsyslog-logrotate-8.2102.0-109.el9.x86_64

 

완료되었습니다!

[root@localhost ~]#

 

rsyslog 실행

# systemctl enable rsyslog.service # system 부팅 후 서비스 자동 실행 등록

 

# systemctl start rsyslog.service # 서비스 실행

 

# systemctl stop rsyslog.service # 서비스 중지

'기술 노트 > rsyslog' 카테고리의 다른 글

rsyslog.conf  (0) 2023.03.16

+ Recent posts