Linux(CentOS 7)修改max open files的值
新安装的linux系统允许每个程序的最大打开文件数默认是1024,可以通过ulimit -n命令来查看,查看全部限制,则可以使用命令ulimit -a
[root@test ~]# ulimit -a
core file size (blocks, -c)
data seg size (kbytes, -d) unlimited
scheduling priority (-e)
file size (blocks, -f) unlimited
pending signals (-i)
max locked memory (kbytes, -l)
max memory size (kbytes, -m) unlimited
open files (-n)
pipe size ( bytes, -p)
POSIX message queues (bytes, -q)
real-time priority (-r)
stack size (kbytes, -s)
cpu time (seconds, -t) unlimited
max user processes (-u)
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
系统全局参数file-max
cat /proc/sys/fs/file-max
系统级别的限制
如果是系统服务
编辑服务配置文件:/usr/lib/systemd/system/SERVICE_NAME.service,在[Service]段添加行:LimitNOFILE=65535,下面是nginx的示例:
vim nginx.service [Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target [Service]
Type=forking
PIDFile=/opt/web_engine/nginx/run/nginx.pid
ExecStartPre=/opt/web_engine/nginx/sbin/nginx -t -c /opt/web_engine/nginx/conf/nginx.conf
ExecStart=/opt/web_engine/nginx/sbin/nginx -c /opt/web_engine/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
LimitNOFILE= [Install]
WantedBy=multi-user.target
运行systemctl daemon-reload让配置文件激活,再重启服务,即可让配置生效
临时修改,重启后失效,不对运行中程序生效
永久修改,需要重启系统
* hard nofile 65535
#MySQL env
mysql soft nproc
mysql hard nproc
mysql soft nofile
mysql hard nofile
mysql soft stack
上面的nproc是允许创建的子进程数目,不能过大,防止accidental fork bombs,一般4096比较合适
动态修改运行中程序的值
prlimit --pid 24340 --nofile=65535:65535
Linux(CentOS 7)修改max open files的值的更多相关文章
- 【转】有效修改max open files/ulimit -n
[转]有效修改max open files/ulimit -n_追梦20121222_新浪博客 [转]有效修改max open files/ulimit -n (2011-11-18 0 ...
- Linux/CentOS下修改MAC地址
Linux/CentOS下修改MAC地址 摘自:https://blog.csdn.net/qq_33233768/article/details/64906265 2017年03月22日 11:06 ...
- Linux(CentOS)用户修改密码有效期(chage命令)
Linux设置用户密码的有效期限 解决: 先查看密码过期时间,现在是90天 1 2 3 4 5 6 7 8 [root@01 ~]# chage -l testuser Last password c ...
- Linux CentOS 7修改内核启动默认顺序
1.查看系统有几个内核 a.进入grub2.cfg文件中进行查看 b.通过grub界面查看 3.设置默认启动内核 grub2-set-default "内核版本" 配置默认内核4. ...
- Linux(centos)下修改mysql的sql_mode模式
进入MySQL的配置文件 默认是/etc/my.cnf vim my.cnf 在最后一行加入 sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITU ...
- Linux - 修改系统的max open files、max user processes (附ulimit的使用方法)
目录 1 问题说明 2 修改max open files 3 修改max user processes 4 附录: ulimit命令说明 1 问题说明 Linux 系统默认的max open file ...
- Linux - 修改系统的max open files、max user processes(附ulimit的使用方法)【转载】
Linux - 修改系统的max open files.max user processes(附ulimit的使用方法)目录 1 问题说明2 修改max open files3 修改max user ...
- linux/Centos下查看和修改网卡Mac地址(ifconfig命令)
本文转载自http://www.169it.com/article/14360294838474691537.html linux/Centos下查看网卡Mac地址,输入命令: #ifconfig - ...
- Centos6 修改max user processes limits
ulimit:显示(或设置)用户可以使用的资源的限制(limit),这限制分为软限制(当前限制)和硬限制(上限),其中硬限制是软限制的上限值,应用程序在运行过程中使用的系统资源不超过相应的软限制,任何 ...
随机推荐
- redis订阅发布简单实现
适用场景 业务流程遇到大量异步操作,并且业务不是很复杂 业务的健壮型要求不高 对即时场景要求不高 原理介绍 redis官网文档:https://redis.io/topics/notification ...
- cogs 619. [金陵中学2007] 传话 Tarjan强连通分量
619. [金陵中学2007] 传话 ★★ 输入文件:messagez.in 输出文件:messagez.out 简单对比时间限制:1 s 内存限制:128 MB [问题描述] 兴趣小 ...
- Hive 这些基础知识,你忘记了吗?
Hive 其实是一个客户端,类似于navcat.plsql 这种,不同的是Hive 是读取 HDFS 上的数据,作为离线查询使用,离线就意味着速度很慢,有可能跑一个任务需要几个小时甚至更长时间都有可能 ...
- 设置java启动项目
1,
- Xmind: ZEN快捷键
- Ansible Playbooks常用模块
File模块 在目标主机创建文件或目录,并赋予其系统权限 - name: create a file file:'path=/oot/foo.txt state=touch mode=0755 own ...
- es8对object快速遍历的方法
let grade = { 'lilei' : 96, 'han' : 99 } //遍历keys console.log(Object.keys(grade)) console.log(Object ...
- [计算几何+图论]doge
题意 在平面直角坐标系上,你有一只doge在原点处.doge被绳子拴住了,绳子不会打结,没有弹性(但很柔软),并且长度为L.平面上有一些目标,因此你的doge会按照顺序去捡起它们,但是doge只能走直 ...
- POI导出excel的三种方式
原文链接:https://www.cnblogs.com/zhaoblog/p/7661245.html poi导出excel最常用的是第一种方式HSSFWorkbook,不过这种方式数据量大的话会产 ...
- maven远程部署到tomcat8服务器
maven远程部署到tomcat8服务器 环境准备 linux服务器一台 服务器安装JDK 服务器安装Tomcat 服务器Tomcat8配置 添加Tomcat权限 配置文件路径: tomcat/con ...