| 로그파일 종류... |
| 글 쓴 이 |
linux |
| 날 짜 |
2003년 01월 02일 17시 34분 34초 |
| 본 문 |
리눅스 로그 파일에 대해
리눅스서버는 다양한 로그 파일이 생기고 있으면 관리자가 되었다면 이 로그 파일에 대한 처리(백업,삭제)와 정리를 해야 할 것이다.
리눅스 시스템은 /var/log 디렉토리 로그 파일이 있으면 이곳에 다양한 로그 파일이 저정이 된다.( 소스로 프로그램 설치시 다른 디렉토리에 로그 파일이 생긴다.예로 아파치를 소스로 설치를 하였다면 /usr/local/apache/logs 디렉토리에 로그파일이 생긴다.)
[root@server mail]# cd /var/log/
[root@server log]# ls -al
total 5572
drwxr-xr-x 2 root root 4096 2월 25 04:02 ./
drwxr-xr-x 17 root root 4096 9월 22 11:50 ../
-rw-r--r-- 1 root root 262 2월 25 10:19 boot.log
-rw-r--r-- 1 root root 7711 2월 26 00:30 cron
-rw-r--r-- 1 root root 18679 2월 25 04:02 cron.1
-rw-r--r-- 1 root root 7188 12월 3 02:27 dmesg
-rw-r--r-- 1 root root 0 10월 22 17:39 htmlaccess.log
-rw-r--r-- 1 root root 522930 2월 26 00:30 maillog
-rw-r--r-- 1 root root 196796 2월 26 00:37 messages
-rw-r--r-- 1 root root 0 2월 1 04:02 netconf.log
-rw------- 1 root mail 3947393 2월 26 00:30 procmail
-rw-r--r-- 1 root root 33512 2월 26 00:07 secure
-rw-r--r-- 1 root root 0 2월 24 04:02 spooler
-rw-rw-r-- 1 root utmp 494976 2월 26 00:37 wtmp
-rw-r--r-- 1 root nobody 55397 2월 25 22:50 xferlog
-rw-r--r-- 1 root nobody 367791 2월 24 21:52 xferlog.1
[root@server log]#
boot.log
cron : cron 관련 로그 파일
dmesg : 시스템 관련 로그 파일
htmlaccess.log : linuxconf 를 웹에서 접속했를때 로그 파일
maillog : 수신 메일 로그
srcure : 원격 접속한 모든 로그파일
wtmp : 접속 시간 ip ip 기록이 있으면 last 명령로로만 볼 수 있다.
xferlog : 파일 전송 관련 로그 파일
로그 기록 데몬
[root@server log]# ps -aux | grep log
root 10662 0.0 0.2 1248 608 ? S Feb21 0:05 syslogd -m 0
root 10671 0.0 0.3 1516 828 ? S Feb21 0:00 klogd
syslogd 와 klogd 이 두개의 데몬이 로그 파일을 생성을 해 준다.
syslogd 의 설정 파일은 /etc/syslog.conf 파일이다.
# 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 /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
# Everybody gets emergency messages, plus log them on another
# machine.
*.emerg *
# Save mail and news errors of level err and higher in a
# special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
#
# 레벨의 의미
# debug 프로그램 디버깅할 때 발생하는 메세지
# info 통계,기본정보메시지
# notice 통계 기본 정보 메시지
# warming 주의를 요하는 경고 메시지
# err 에러가 발생하는 경우의 메세지
# crit 급하지 않지만 시스템에 문제가 생기는 단계의 메시지
# elert 즉각적인 조정을 해 주어야 하는 상황
# emerg 모든 사용자들에게 전달되어야 하는 위험한 상황
이렇게 생긴 로그 파일생기는데 로그 파일은 용량이 많이 차기 하기 때문에 로그 파일을 나우어서 관리 할 수 있는 프로그램이 설치 되어 작동을 하고 있는데 이것이
logrotate 이다.
이 프로그램은 cron 에 의해 작동을 하는데 매일 작동을 하면서 로그 파일이 나누어 준다.
[root@server /etc]# cd /etc/cron.daily/
[root@server cron.daily]# cat logrotate
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf
/etc/cron.daily 디렉토리 안에 있는 파일은 메일 4시 04 분에 실행이 되며
이중 logrotate 스크립트가 실행되어 로그 파일을 나누는 역활을 한다.
실행 파일 위치 : /usr/sbin/logrotate
설정 파일 : /etc/logroate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly
# 로그 파일을 주일 단위로 자르겠다
# 이 설정은 daily , weekly , monthly ,size
# 단위로 설정을 변경을 할 수 있다.
# keep 4 weeks worth of backlogs
rotate 4
# 로그파일을 4가지는 나누고 그 이상이 되면 지운다.
# 로그 파일이 중요하지 않다면 1-2개로 줄여 주어도 된다.
# send errors to root
errors root
# 에러가 나면 root 에게 메일을 보내겠다.
#
# create new (empty) log files after rotating old ones
create
# 빈 로그파일을 생성을 하겠다.
# uncomment this if you want your log files compressed
#compress
# 로그 파일을 압축을 할려면 주석을 지우면 되는데 보통 압축하지
# 않는다. nocompress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# 각각에 로그 파일을 나누는 스크립트가 있는 곳이다.
# 이렇게 되어 있는 이유는 데몬 관련 로그는 로그 파일을 임의적으로
# 생성을 하면 로그 파일이 생기기 않기 때문에 데몬을 데몬을 재시작해야
# 하는 방식으로 새로운 로그 파일을 만든다.
# no packages own lastlog or wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}
#wtmp 로그 파일은 직접적으로 생성(create) 해로 되기 때문에
#이곳에 있으면 monthly 가 있어 월 단위로 작동을 하고 로그 파일을
# wtmp.1 까지만 만든다.
# system-specific logs may be configured here
root@server /etc]# cd /etc/logrotate.d
[root@server logrotate.d]# ls
cron named syslog
[root@server logrotate.d]#
root@server /logroate.d]# cat proftpd
/var/log/xferlog {
missingok
nocompress
postrotate
/usr/bin/killall -HUP proftpd > /dev/null 2>&1
endscript
}
# ftp 관련 로그 파일이 xferlog 을 나눈 파일이다.
|
|
|
|