ulimit 설정

가지가지 2019. 10. 31. 16:36

# 설정 확인

> ulimit -a 



# 임시 설정

sudo su
ulimit -f unlimited    # file size 
ulimit -t unlimited    # cpu time 
ulimit -v unlimited    # virtual memory 
ulimit -l unlimited    # locked-in-memory size 
ulimit -n 64000       # open files 
ulimit -m unlimited  # memory size 
ulimit -u 64000      # processes/threads 
ulimit -c unlimited    # core file size



# 영구 설정

> sudo vi /etc/security/limits.conf 
* soft fsize unlimited 
* hard fsize unlimited 
* soft cpu unlimited 
* hard cpu unlimited 
* soft as unlimited 
* hard as unlimited 
* soft memlock unlimited 
* hard memlock unlimited 
* soft rss unlimited 
* hard rss unlimited 
* soft nproc 64000 
* hard nproc 64000 
* soft nofile 1048576 
* hard nofile 1048576 
* soft core unlimited 
* hard core unlimited 
root      soft   nofile      1048576 
root      hard   nofile      1048576 
root      soft   core        unlimited 
root      hard   core        unlimited 




# 영구 설정

>sudo vi /etc/sysctl.conf 

fs.file-max = 1048576 
net.ipv4.tcp_fin_timeout = 10 
vm.max_map_count=262144 
net.core.rmem_default=253952 
net.core.wmem_default=253952 
net.core.rmem_max=16777216 
net.core.wmem_max=16777216 
net.core.somaxconn = 65535 
net.core.netdev_max_backlog = 5000 
net.ipv4.tcp_rmem=253952 12582912 16777216 
net.ipv4.tcp_wmem=253952 12582912 16777216 


# Protect Against TCP Time-Wait 
net.ipv4.tcp_rfc1337 = 1 

# Decrease the time default value for connections to keep alive 
net.ipv4.tcp_keepalive_time = 300 
net.ipv4.tcp_keepalive_probes = 5 
net.ipv4.tcp_keepalive_intvl = 15 
net.ipv4.tcp_max_syn_backlog = 8096 
net.ipv4.tcp_slow_start_after_idle = 0 
net.ipv4.tcp_tw_reuse = 1 
#net.ipv4.ip_local_port_range = 10240 65535 

# allow processes to bind to the non-local address 
net.ipv4.ip_nonlocal_bind = 1 

# TCP retransmisson retry count 
net.ipv4.tcp_retries2=5 

net.core.somaxconn=65535 
vm.overcommit_memory=1

 

 

# 서비스 사용시 (systemctl) nofile 지정 필요

...
[Service]
LimitNOFILE=1048576
...

 

#  process nofile 확인

# 프로세스 nofiles 확인
> prlimit --nofile --output RESOURCE,SOFT,HARD --pid 2033

# 프로세스 nofile 개수 설정
> prlimit --nofile=500000 --pid=6161

 

참고.

https://fun25.co.kr/blog/ubuntu-16-04-maximum-numbers-open-files/?category=001
https://medium.com/hbsmith/too-many-open-files-%EC%97%90%EB%9F%AC-%EB%8C%80%EC%9D%91%EB%B2%95-9b388aea4d4e

'가지가지' 카테고리의 다른 글

logstash grok sample  (0) 2020.03.10
tcpdump  (0) 2020.03.03
로그 시간별로 쪼개기  (0) 2020.02.06
git "tag name > branch name > commit revision" 으로 구해오기  (0) 2019.12.17
Nginx 1.16.1 수동 컴파일 설치 on ubuntu 18.04  (0) 2019.10.28
[GO] 1.13.1 go module  (0) 2019.10.25
crontab  (0) 2019.10.15
[centos] sudo 권한 부여. centos 7  (0) 2019.08.21