file-max与ulimit的关系与差别
来源:互联网 发布:三星n9008刷4g网络 编辑:程序博客网 时间:2024/05/21 07:08
典型的,提供大量静态文件访问的web服务器,缓存服务器(如squid), 均要注意这个问题
网上的教程,大约只是简单说明了如何设置ulimit和file-max, 但并没有说清楚这两者之间的差别,让人一头雾水
1. file-max的含义
man proc,可得到file-max的描述:
/proc/sys/fs/file-max
This file defines a system-wide limit on the number of open files for all processes. (See
also setrlimit(2), which can be used by a process to set the per-process limit,
RLIMIT_NOFILE, on the number of files it may open.) If you get lots of error messages
about running out of file handles, try increasing this value:
即file-max是设置系统所有进程一共可以打开的文件数量。同时一些程序可以通过setrlimit调用,设置每个进程的限制。如果得到大量使用完文件句柄的错误信息,是应该增加这个值。
也就是说,这项参数是系统级别的。
echo 6553560 > /proc/sys/fs/file-max
或修改 /etc/sysctl.conf, 加入
fs.file-max = 6553560 重启生效
2. ulimit的
Provides control over the resources available to the shell and to processes started by it, on systems that allow such control.
即设置当前shell以及由它启动的进程的资源限制。
显然,对服务器来说,file-max, ulimit都需要设置,否则就可能出现文件描述符用尽的问题,为了让机器在重启之后仍然有效,强烈建立作以下配置,以确保file-max, ulimit的值正确无误:
1. 修改/etc/sysctl.conf, 加入
fs.file-max = 6553560
2.系统默认的ulimit对文件打开数量的限制是1024,修改/etc/security/limits.conf并加入以下配置,永久生效
* soft nofile 65535
* hard nofile 65535
修改完之后,重启即可生效
- file-max与ulimit的关系与差别
- file-max与ulimit的关系与差别
- file-max与ulimit的关系与差别
- 与文件系统及程序的限制关系: ulimit
- fd与FILE*的关系
- androidpn和smack的关系与使用上的差别
- struts+spring+hibernate之间的关系与差别
- struts+spring+hibernate之间的关系与差别 (转)
- 数据仓库与传统关系型数据库的差别
- Hive与关系型数据的一些差别
- “>”与">>"的差别
- ()与{}的差别
- $(())与$()还有${}的差别
- $@与$*的差别
- &&与||的差别
- [[]]与[]的差别
- group by与avg(),max(),min(),sum()函数的关系
- 设置Linux打开文件句柄/proc/sys/fs/file-max和ulimit -n的区别
- STL最小值算法
- 3.3 E7
- 驱动学习笔记(一)
- CSharp - Type Inference and usage of var
- 28个Unix/Linux的命令行神器
- file-max与ulimit的关系与差别
- 九月四号作业讲解:
- 程序员常去的地方
- 用Jdk自带工具keytool生成受信任的证书
- 【笔试&面试】C#中的指针
- linux驱动头文件说明
- 查询锁表进程及杀掉进程
- 基准测试工具之tpcc-mysql
- struts1配置