Ubuntu 18.04 修改 ulimit
Ubuntu 修改 18.04 ulimit
2023-09-14 09:09:52 时间
Ubuntu 18.04 修改 ulimit
1,报错too many open files
- 设置
ulimit
open files
默认为1024
# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 514927
max locked memory (kbytes, -l) 16384
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) 514927
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
2,修改open files
vim /etc/security/limits.conf
添加
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
root soft nproc 65535
root hard nproc 65535
root soft nofile 65535
root hard nofile 65535
bro soft nproc 65535
bro hard nproc 65535
bro soft nofile 65535
bro hard nofile 65535
vim /etc/pam.d/common-session
添加
session required pam_limits.so
vim /etc/pam.d/common-session-noninteractive
添加
session required pam_limits.so
vim /etc/systemd/system.conf
修改
DefaultLimitNOFILE=65535
- 重启
- 修改成功
open files 65535
# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 514927
max locked memory (kbytes, -l) 16384
max memory size (kbytes, -m) unlimited
open files (-n) 65535
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) 65535
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
8565
为进程,查看Max open files
# cat /proc/8565/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 65535 65535 processes
Max open files 65535 65535 files
Max locked memory 16777216 16777216 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 514927 514927 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
3,通过设置环境变量修改
vim /etc/profile
增加
ulimit -n 65535
# ulimit -n
65535
4,pen files修改为1048576
# cat /proc/sys/fs/file-max
19768128
# cat /proc/sys/fs/nr_open
1048576
- 当前值 hard 值
ulimit -a
# ulimit -Sa | grep -ni "open"
8:open files (-n) 1024
# ulimit -Ha | grep -ni "open"
8:open files (-n) 1048576
5,永久修改 ulimit
# ulimit -a | grep -ni "open"
8:open files (-n) 1024
# ulimit -Sa | grep -ni "open"
8:open files (-n) 1024
# ulimit -Ha | grep -ni "open"
8:open files (-n) 1048576
- 修改
# vim /etc/systemd/user.conf
#DefaultLimitNOFILE=
DefaultLimitNOFILE=1048576
# vim /etc/systemd/system.conf
#DefaultLimitNOFILE=
DefaultLimitNOFILE=1048576
vim /etc/security/limits.conf
- 添加
* soft nproc 1048576
* hard nproc 1048576
* soft nofile 1048576
* hard nofile 1048576
root soft nproc 1048576
root hard nproc 1048576
root soft nofile 1048576
root hard nofile 1048576
bro soft nproc 1048576
bro hard nproc 1048576
bro soft nofile 1048576
bro hard nofile 1048576
reboot
# ulimit -a | grep -ni "open"
8:open files (-n) 1048576
# ulimit -Sa | grep -ni "open"
8:open files (-n) 1048576
参考:
相关文章
- 在Ubuntu安装nginx
- ubuntu安装wget命令_macbook无法安装app
- ubuntu16.04配置本地镜像源_修改ubuntu镜像源
- linux显示颜色设置命令_ubuntu修改终端颜色
- Ubuntu修改用户名和密码后无法登录_ubuntu默认用户名
- ubuntu 卸载命令_Ubuntu怎么卸载
- 修改 Ubuntu 的 ulimit 文件句柄数限制
- Vue项目部署到服务器(ubuntu)
- Ubuntu 18.04 修改和添加额外IP地址
- 在Ubuntu/Linux环境下MySQL如何开放修改3306端口和开放访问权限
- ubuntu安装mysql–参考的网址详解数据库
- Ubuntu下MongoDB的安装和使用详解大数据
- Kernel 4.4 已经发布-怎样在 Ubuntu 上安装
- 如何在Ubuntu 18.04 LTS上安装LimeSurvey
- Ubuntu与Linux:开源技术的双发动机(ubuntu与linux)
- 如何在 Ubuntu 16.04 强制 APT 包管理器使用 IPv4
- 如何在 Ubuntu 中修复 VirtualBox 的 “Kernel driver not installed (rc=-1908)” 错
- 如何在 Ubuntu 上安装 MySQL 数据库?(ubuntu安装mysql)
- 在Ubuntu上安装类Winamp的音频播放器Qmmp 0.9.0
- Ubuntu下搭建MSSQL服务器快速入门(ubuntu mssql)
- Ubuntu:Linux操作系统的最佳选择?(ubuntu是linux吗)
- Ubuntu命令行修改网络配置方法