Core 파일 생성 방법

OS/Linux 2013. 1. 10. 09:47 Posted by 이정식

1. /etc/security/limits.conf 수정

* soft core -1
* hard core -1

-1 은 unlimited 뜻함.

2. /etc/profile 수정
#ulimit -S -c 0 > /dev/null 2>&1 ; 변경 전
ulimit -S -c unlimited > /dev/null 2>&1 ; 변경 후

3. reboot

#### 자세한 설명 ###
초기 설정에는 core file size가 0으로 설정이 되어있어, core file이 생성이 되지 않는다.
따라서 core dump시 core file이 생성되게 하려면 다음과 같이 설정값을 수정해야 한다.

ulimit 설정 값 변경은 위의 현재 설정값에서 나온 옵션을 써주고 값을 써주면 된다.

[root@devlinux ~]# ulimit -c unlimited
[root@devlinux ~]# ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 98304
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 98304
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

위와 같은 명령으로 변경한 것은 해당 user만 변경되어 적용이 되며, reboot 후에는 다시 설정을 해야한다.
위의 설정을 reboot 후에도 유지되게 하기 위해선 아래의 파일 수정이 필요하다.


/etc/security/limits.conf


위 파일에는 ulimit값을 적용할 domain, type, item, value가 들어가게 되어있다.
입력 형식은 다음과 같다.


<domain> <type> <item> <value>
< domain> 해당 설정값을 적용시킬 범위
- user name (userid) - 한 유저의 설정 변경
- group name (@groupid) - 한 그룹에 대한 설정 변경
- wildcard (*) - 모든 유저, 그룹에 대한 설정 변경
- wildcard (%) - * 와 동일, 단 maxlogins 변경에만 사용

<type>
- hard : superuser와 kernel에 의해 설정이 되게 하며, user는 설정된 값 이상으로 변경이 불가능하다.
- soft : soft로 설정한 값은 user가 얼마든지 설정값을 변경 가능하다.
- - : hard와 soft 둘다 설정

<item>
- core : limits the core file size (KB)
- data : maximum data size (KB)
- fsize : maximum filesize (KB)
- memlock : maximum locked-in-memory address space (KB)
- nofile : maximum number of open files
- rss : maximum resident set size (KB) (Ignored in Linux 2.4.30 and higher)
- stack : maximum stack size (KB)
- cpu : maximum CPU time (minutes)
- nproc : maximum number of processes
- as : address space limit
- maxlogins : maximum number of logins for this user
- maxsyslogins : maximum number of logins on system
- priority : the priority to run user process with (negative values boost process priority)
- locks : maximum locked files (Linux 2.4 and higher)
- sigpending : maximum number of pending signals (Linux 2.6 and higher)
- msqueue : maximum memory used by POSIX message queues (bytes) (Linux 2.6 and higher)
- nice : maximum nice priority allowed to raise to (Linux 2.6.12 and higher)
- rtprio : maximum realtime priority allowed for non-privileged processes (Linux 2.6.12 and higher)

example) core dump file size를 변경

astrix - core 1000
@group1 - core unlimited
* - core 200000

이 설정을 변경 하였는데도 불구하고, reboot 시 적용이 안된다면 /etc/profile 파일을 살펴보자!!

...

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
...


위 빨간 글자로 된 부분을 주석처리 해버리고 reboot하면 적용 된다.

'OS > Linux' 카테고리의 다른 글

SUDO 제한 방법  (0) 2013.01.10
Python 설치(easy install)  (0) 2013.01.10
커널 파라미터 설정 정보  (0) 2013.01.10
커널 패닉 시 자동 리부팅 설정  (0) 2013.01.10
메모리 누수 확인 방법  (0) 2013.01.10