Ubuntu 修改文件最大打开数

设置

# 系统
echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
# 用户
sudo tee -a /etc/security/limits.conf << EOF
*               hard    nofile          65535
*               soft    nofile          65535
root            hard    nofile          65535
root            soft    nofile          65535
EOF
# Systemd
sudo sed -i '/DefaultLimitNOFILE/c DefaultLimitNOFILE=65535' /etc/systemd/*.conf
sudo systemctl daemon-reexec

验证

# 查看系统限制
cat /proc/sys/fs/file-max
# 查看用户硬限制
ulimit -Hn
# 查看用户软限制
ulimit -Sn
# 查看某进程的限制
cat /proc/PID/limits # 将 PID 替换为具体的进程 ID
# 查看其他用户限制
su - root -c 'ulimit -aHS' -s '/bin/bash'
posted @ 2022-12-30 12:07  Yiersansi_1221  阅读(660)  评论(0)    收藏  举报