질문&답변
클라우드/리눅스에 관한 질문과 답변을 주고 받는 곳입니다.
리눅스 분류

logrotate 메모리 상주, 부하증가 원인은?

작성자 정보

  • 제로투 작성
  • 작성일

컨텐츠 정보

본문

제가 이번에 새로 손보는 서버가 ...
유휴 상태에서도 부하가 항상 1을 넘더군요. 다른 서버들은 1 이하인데 ...

그래서 top 으로 살펴보니 ...
/usr/sbin/logrotate /etc/logrotate.conf 
위 프로세서가 R 상태에서 계속 실행되며 메모리 부하도 주고 하는데 ...
kill -9로 해당 프로세서를 죽이면  부하는 0 가까이 내려갑니다.

결국 아래 logrotate 실행중 어디에선가 문제가 있는 것 같은데 ...
 /usr/sbin/logrotate /etc/logrotate.conf 

그 다음은 어떤식으로 분석해 들어가야 하는지
고수님들의 조언 부탁드립니다.

=========================================================================
top - 02:54:12 up 117 days, 22:05,  6 users,  load average: 1.12, 1.12, 1.08
Tasks: 106 total,   2 running, 104 sleeping,   0 stopped,   0 zombie
Cpu(s): 50.2% us,  0.1% sy,  0.0% ni, 49.3% id,  0.2% wa,  0.0% hi,  0.1% si
Mem:   1034416k total,  1012448k used,    21968k free,   142792k buffers
Swap:  2096440k total,   146944k used,  1949496k free,   256176k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                                                    
25197 root      25   0  151m 150m  612 R 99.7 14.9   1301:24 /usr/sbin/logrotate /etc/logrotate.conf  

관련자료

댓글 3

gurum님의 댓글

  • gurum
  • 작성일
안녕하세요

유휴상태에서 1은 크게 문제가 되지는 않는 것 같지만 top 실행시 logrotate가 우선 순위로 잡히는 것은 점검이 한번 필요할 것 같습니다.

제가 하는 방법은 참고용이니 참고만 하세요

ls -al /proc/PID로 프로세스 감사를 한번 해보시고

logrotate.conf 한번 살펴보시고요

root@TMS8:/# cd /etc/logrotate.d/
root@TMS8:/etc/logrotate.d# ls -al
합계 48
drwxr-xr-x  2 root root 4096 2010-06-16 16:01 .
drwxr-xr-x 93 root root 4096 2010-06-24 14:32 ..
-rw-r--r--  1 root root  293 2010-03-10 06:07 apache2
-rw-r--r--  1 root root  84 2009-04-17 13:27 apt
-rw-r--r--  1 root root  79 2009-02-10 22:45 aptitude
-rw-r--r--  1 root root  111 2009-01-07 21:32 dpkg
-rw-r--r--  1 root root  146 2009-02-11 22:53 exim4-base
-rw-r--r--  1 root root  126 2009-02-11 22:53 exim4-paniclog
-rw-r--r--  1 root root  94 2009-02-21 02:25 ppp
-rw-r--r--  1 root root  85 2010-06-16 16:01 trac_tms
-rw-r--r--  1 root root  106 2009-04-09 10:44 wpa_action
-rw-r--r--  1 root root  114 2009-04-09 10:44 wpa_supplicant
root@TMS8:/etc/logrotate.d#

도 한번 보세요 불필요한 것이 들어 있지 않은지.!!

여기까지 해보시고 한번 더 글을 서줘보세요 ...~ ~

제로투님의 댓글

  • 제로투
  • 작성일
■■■
해당 디렉토리에 아래와 같이 일반적으로 시스템 설치 될 때 깔리는 것들이 있는데 ...

[root@apparelnews logrotate.d]# ll
합계 48
-rw-r--r--  1 root root 144  6월 25 23:30 acpid
-rw-r--r--  1 root root 240  6월 25 23:30 apache
-rw-r--r--  1 root root 161  6월 25 23:30 cups
-rw-r--r--  1 root root 571  6월 25 23:30 mgetty
-rw-r--r--  1 root root 136  6월 25 23:30 ppp
-rw-r--r--  1 root root 242  6월 25 23:30 psacct
-rw-r--r--  1 root root  61  6월 25 23:30 rpm
-rw-r--r--  1 root root 154  6월 25 23:30 snmpd
-rw-r--r--  1 root root 228  6월 25 23:30 syslog
-rw-r--r--  1 root root  32  6월 25 23:30 up2date
-rw-r--r--  1 root root  92  6월 25 23:30 vsftpd.log
-rw-r--r--  1 root root  89  6월 25 23:32 yum

■■■
/etc/logrotate.conf 파일도 특별한 것은 없습니다.

[root@apparelnews logrotate.d]# vi /etc/logrotate.conf

:w
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 9

# 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 wtmp -- we'll rotate them here
# Zero
/var/log/wtmp {
    monthly
    create 0664 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.

■■■
근데 실행해 보면 항상 마지막 녀석에서 멈춤니다.

[root@apparelnews logrotate.d]# /usr/sbin/logrotate -d /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file acpid
reading config info for /var/log/acpid
reading config file apache
reading config info for /log/httpd/*
reading config file cups
reading config info for /var/log/cups/*_log
reading config file mgetty
reading config info for /var/log/mgetty.log.tty[^.] /var/log/mgetty.log.tty[^.][^.] /var/log/mgetty.log.tty[^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.unknown /var/log/mgetty.callback
reading config file ppp
reading config info for /var/log/ppp/connect-errors
reading config file psacct
reading config info for /var/account/pacct
reading config file rpm
reading config info for /var/log/rpmpkgs
reading config file snmpd
reading config info for /var/log/snmpd.log
reading config file syslog
reading config info for /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron
reading config file up2date
reading config info for /var/log/up2date
reading config file vsftpd.log
reading config info for /var/log/xferlog
reading config file yum
reading config info for /var/log/yum.log
reading config info for /var/log/wtmp

■■■
시험삼아 하나 하나 마지막 것 즉
/var/log/wtmp 를 지우면 다음처럼 yum.log에서 멈추고 ...

[root@apparelnews logrotate.d]# /usr/sbin/logrotate -d /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file acpid
reading config info for /var/log/acpid
reading config file apache
reading config info for /log/httpd/*
reading config file cups
reading config info for /var/log/cups/*_log
reading config file mgetty
reading config info for /var/log/mgetty.log.tty[^.] /var/log/mgetty.log.tty[^.][^.] /var/log/mgetty.log.tty[^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.unknown /var/log/mgetty.callback
reading config file ppp
reading config info for /var/log/ppp/connect-errors
reading config file psacct
reading config info for /var/account/pacct
reading config file rpm
reading config info for /var/log/rpmpkgs
reading config file snmpd
reading config info for /var/log/snmpd.log
reading config file syslog
reading config info for /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron
reading config file up2date
reading config info for /var/log/up2date
reading config file vsftpd.log
reading config info for /var/log/xferlog
reading config file yum
reading config info for /var/log/yum.log

■■■
yum 부분을 지우면 그전 단계에서 멈춤니다 ...
그래서 logrotate.d 방 안의 내용 다 지우고 ...
/etc/logrotate.conf 파일의 내용도 "#"으로 주석처리 다 했는데 ...
그랬더니 ...
걍 아무것도 안하고 멈춰 있습니다.
부하다 1넘게 나오고 ... ㅠㅜ~


[root@apparelnews logrotate.d]# vi /etc/logrotate.conf

# see "man logrotate" for details
# rotate log files weekly
#weekly

# keep 4 weeks worth of backlogs
#rotate 9

# 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 wtmp -- we'll rotate them here
# Zero
#/var/log/wtmp {
#    monthly
#    create 0664 root utmp
#    rotate 1
#}

# system-specific logs may be also be configured here.

■■■
[root@apparelnews logrotate.d]# /usr/sbin/logrotate -d /etc/logrotate.conf
reading config file /etc/logrotate.conf

[root@apparelnews logrotate.d]# /usr/sbin/logrotate  /etc/logrotate.conf

top - 23:44:31 up 118 days, 18:56,  2 users,  load average: 1.02, 0.80, 0.50
Tasks:  81 total,  3 running,  78 sleeping,  0 stopped,  0 zombie
Cpu(s): 49.8% us,  0.2% sy,  0.0% ni, 49.6% id,  0.0% wa,  0.0% hi,  0.5% si
Mem:  1034416k total,  1004124k used,    30292k free,  162540k buffers
Swap:  2096440k total,  146852k used,  1949588k free,  468240k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                       
 6461 root      25  0  7024 6000  448 R 99.9  0.6  1:32.95 /usr/sbin/logrotate /etc/logrotate.conf       
    1 root      16  0  1696  240  212 S  0.0  0.0  0:48.58 init [3]                                       
    2 root      RT  0    0    0    0 S  0.0  0.0  0:27.27 [migration/0]                                 
    3 root      34  19    0    0    0 S  0.0  0.0  0:18.95 [ksoftirqd/0]   


■■■
logrotate 새로 받아서 컴파일하고 해 봐야 하는 건가요 .... 음 ...
운용된지 1년된 서버인데,
언제부턴가 ... 이케 문제가 생겨요~
3월에 몇번 ftp 해킹 당한뒤 부터 인듯도 하고 ...
확실치는 않습니다만 ... 쩝 ...

gurum님의 댓글

  • gurum
  • 작성일
안녕하세요 음 제가 경험담을 말씀드리겠습니다.

리눅스 웹서버에 해킹 흔적을 발견하고 고생한적이 있습니다.

제로투님의 마지막 말씀이 가슴에 와 닿는데 3월에 ftp 해킹 당하신적이 있으시다면 분명 백도어나 다른 ...스크립트, 또는 해킹파일들을  변조들을 했을 가능성이 매우 큽니다.

시스로그 로테이션이나 시스로그쪽에 문제가 있다라는 것은 의심할 여지는 없는 듯하고 악의적인 해커들의 기본적인 패컨은 로그 파일 조작 및 변조기 때문에 한번 시간 내셔서 정밀 검사해보셔야 할 것 같습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,041 명
  • 현재 강좌수 :  35,855 개
  • 현재 접속자 :  118 명