참고-비교-ulimit vs limits.conf .docx



CentOS7.4 – ulimit vs limits.conf 차이점

http://pchero21.com/?p=918

http://board.theko.co.kr/bbs/board.php?bo_table=Command&wr_id=5

 

* to do

중요:  limit 명령은 일시적인 것이고 영구적으로 설정하려면  /etc/security/limits.conf 에 설정해야 한다.

ulimit 는 하나의 유저(,프로세스)에 대허서 할당할 자원량의 한계를 정하는 것으로서 다중 프로그램/사용자를 기본으로하는 리눅스 시스템에서 과부하를 막아주는 (한프로세스가 미쳐도 다른것에 영향이 덜가도록) 방패가 되어 주는 유용한 설정이다.

 

01. ulimit

- 명령어 (확인-소프트)

[root@localhost ~]#ulimit -a (또는 ulimit -Sa) // soft 한도

core file size                 (blocks, -c) 0

data seg size                (kbytes, -d) unlimited

scheduling priority                  (-e) 20

file size                      (blocks, -f) unlimited

pending signals                     (-i) 16382

max locked memory          (kbytes, -l) 64

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) 8192

cpu time                     (seconds, -t) unlimited

max user processes                   (-u) unlimited

virtual memory                (kbytes, -v) unlimited

file locks                             (-x) unlimited

- 명령어 (확인-하드)

[root@localhost ~]#ulimit -Ha // hard 한도

core file size                 (blocks, -c) unlimited
data seg size                (kbytes, -d) unlimited
scheduling priority                  (-e) 20
file size                      (blocks, -f) unlimited
pending signals                      (-i) 16382
max locked memory         (kbytes, -l) 64
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) unlimited
cpu time                   (seconds, -t) unlimited
max user processes                 (-u) unlimited
virtual memory             (kbytes, -v) unlimited
file locks                           (-x) unlimited

- 명령어 (확인-소프트/하드)

[root@localhost ~]#ulimit -Ha / ulimit –Sa     (하드 설정 전체 보기 / 소프트 설정 전체 보기)

è 하드는 해당쉘의 최대값을 뜻한다 하면 되고,  소프트는 현재 설정을 말한다 생각하면 된다.

è soft설정은 hard설정값을 넘을수 없으므로. 그냥 soft/hard같이 설정해주는 버릇을 들이자.

 

- 명령어 (설정-예제)

[root@localhost ~]# ulimit -n 8192     // 오픈 파일의 최대 수

 

- 옵션

 ulimit 옵션

 -a 모든 제한 사항을 보여준다.
 -c
최대 코어 파일 사이즈
 -d
프로세스 데이터 세그먼트의 최대 크기
 -f shell
에 의해 만들어질 수 있는 파일의 최대 크기
 -s
최대 스택 크기
 -p
파이프 크기
 -n
오픈 파일의 최대 수
 -u
프로세스 최대 수
 -v
최대 가상 메모리의 량

 

02. /etc/security/limits.conf 에 설정 파일

: 수정한 내용의 적용은 해당 유저가 새로운 접속을 시도하면 적용됩니다.(짧게 말해 재접^^;)

- 형식은 (limit.conf-)

# /etc/security/limits.conf

[유저이름] [hard/soft] [설정할 항목] [설정값]

 

- ex

mklife hard nofile 320000  => mklife 유저는 한번 접속에 하드세팅으로 32만개 파일까지 열수 있다.

mklife hard nproc 10000   => mklife 유저는 한번 접속에 하드 세팅으로 1만개 프로시져를 생성가능

mklife soft  nproc 10000   => mklife 유저는 한번 접속에 소프트 세팅으로 1만개 프로시져를 생성가능

(주의) soft설정은 hard설정값을 넘을수 없으므로. 그냥 soft/hard같이 설정해주는 버릇을 들이자.

 

- 옵션

# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#       
an user name
#       
a group name, with @group syntax
#       
the wildcard *, for default entry
#       
the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#       
NOTE: group and wildcard limits are not applied to root.
#          To apply a limit to the root user, <domain> must be
#          the literal username root.
#
#<type> can have the two values:
#       
– “soft for enforcing the soft limits
#       
– “hard for enforcing hard limits
#
#<item> can be one of the following:
#       
core limits the core file size (KB)
#       
data max data size (KB)
#       
fsize maximum filesize (KB)
#       
memlock max locked-in-memory address space (KB)
#       
nofile max number of open files
#       
rss max resident set size (KB)
#       
stack max stack size (KB)
#       
cpu max CPU time (MIN)
#       
nproc max number of processes
#       
as address space limit (KB)
#       
maxlogins max number of logins for this user
#       
maxsyslogins max number of logins on the system
#       
priority the priority to run user process with
#       
locks max number of file locks the user can hold
#       
sigpending max number of pending signals
#       
msgqueue max memory used by POSIX message queues (bytes)
#       
nice max nice priority allowed to raise to values: [-20, 19]
#       
rtprio max realtime priority
#       
chroot change root to directory (Debian-specific)
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#root            hard    core            100000
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#ftp            
      chroot          /ftp
#@student       
      maxlogins       4

# End of file

 

 

 

 


'Linux > CentOS7 > 비교' 카테고리의 다른 글

[참고] 비교-rpm vs yum  (0) 2018.04.16

+ Recent posts