Server & OS

apache log정리/관리

페이지 정보

본문

# 레드헷 리눅스 7.3

아래와 같이 가상호스트를 추가했다면

<VirtualHost xxx.xxx.xxx.xx >
        ServerAdmin xxxx@xxx.xxx
        DocumentRoot /home/xxxxxx/docs
        ServerName test.com
        CustomLog /logs/test.com_log common
</VirtualHost>

서버상에 /logs/test.com_log란 파일이 남겠죠...
그런데 방문자 수가 많아서 test_log란 로그파일이 무한정
넘어서 하드용량을 꽉잡아먹는다면
문제가 생길것입니다.
아마 이를 방지하기위해 apache로그파일에 대한 용량을
제한한듯합니다.
( 자세한문서를보지는 못했습니다. )

apache.kr.net가서 검색해본결과 apache log파일의 저장의
기본값은 2G로 되있다는 글을 보았습니다. 또한
제가 사용하는 1.3.27버전도 2G로 설정되있는것 같습니다.
-----
정정사항:
File System 에서 단일 화일을 2G 까지만 핸들링 할수있기때문인것으로 정정합니다.
-----

access, error에 로그파일 아님 test_log파일등 각각의
용량중 1개라도 2기가 이상 넘어가게되면 웹브라우져에서
test.com을 요청했을시 엄청느려지더군요... 느려저도
로그파일은 쌓이네요... 2.1기가까지 쌓였는데 아마도
브라우져 여시는게 짜증난다는...^^*

몇일전 특정 브라우저에서 홈페이지를 열은순간
엄청느려지더군요.. 외부에서 터미널로 접속해서 cup점유율,
데몬등을 체크해본결과 특별히 부하걸린것이
없는데 계속 웹에서만느려지는 것을 보고 찾던중
확인하였습니다.

방문자가 많다면 로그파일은 금방 2기가를 넘을듯합니다.
그러기에 로그파일 관리에 대해서 찾다가 아래와 같이
하면 될듯하네요.
아직 안해봤습니다.. 한번 테스트후 리플달아주세요..

======================================================
기본 /etc/logrotate.conf
======================================================
# see "man logrotate" for details
# rotate log files weekly
daily

# keep 4 weeks worth of backlogs
rotate 4

# send errors to root
errors root

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

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

======================================================
수정후 /etc/logrotate.conf
======================================================
# see "man logrotate" for details
# rotate log files weekly
daily

# keep 4 weeks worth of backlogs
rotate 2

# send errors to root
errors root

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

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

/log/*_log {
          postrotate
                                    killall -HUP httpd
          endscript
      }

/usr/local/apache/logs/*log {
          postrotate
                                    killall -HUP httpd
          endscript
}

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

결과1, 결과2
======================================================
결과1 cd /log  후에 ll이라고 쳤을경우
======================================================
test.com_log
test.com_log.1
test.com_log.2

======================================================
결과2 cd /usr/local/apache/conf  후에 ll이라고 쳤을경우
======================================================
access_log
access_log.1
error_log
error_log.1


유용한 주소1 : http://www.apache-kr.org/cgi-bin/bbs?act=mread&board=0&mater=4373&vid=33&page=1
유용한 주소2 : http://www.apache-kr.org/cgi-bin/bbs?act=mread&board=0&mater=6823&vid=44&page=1

잘못된부분( 제가 잘못알고있는부분 )있으면 맘 안아프게 딴지 걸어주세요. 수정하겠습니다.

관련자료

nuno님의 댓글

  2G 제한는, FS 의 제약입니다. File System 에서 단일 화일을 2G 까지만 핸들링 할 수 있는거고요.., Apache 의 제약이 아닙니다.
Today's proverb
사랑이란 남이 모르는 숨겨진 오솔길을 알고 있는 것이다. (독일 속담)