RedHat5修改打开文件数

上传人:野鹰 文档编号:1133763 上传时间:2017-05-29 格式:DOC 页数:4 大小:197KB
返回 下载 相关 举报
RedHat5修改打开文件数_第1页
第1页 / 共4页
RedHat5修改打开文件数_第2页
第2页 / 共4页
RedHat5修改打开文件数_第3页
第3页 / 共4页
RedHat5修改打开文件数_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《RedHat5修改打开文件数》由会员分享,可在线阅读,更多相关《RedHat5修改打开文件数(4页珍藏版)》请在金锄头文库上搜索。

1、 - 1 -1. 总体说明1.1. 配置文件 limits.conf 说明limits.conf 文件实际是 Linux PAM(插入式认证模块,Pluggable Authentication Modules)中 pam_limits.so 的配置文件,而且只针对于单个会话。另外还需要/etc/pam.d/system-auth文件有下面内容:session required pam_limits.so,确保系统会执行这个限制。limits.conf的格式如下:usernamegroupname type resource limit usernamegroupname:设置需要被限制的用户

2、名,组名前面加和用户名区别。也可以用通配符*来做所有用户的限制。 type:有 soft、hard 和 - 三种,soft 指的是当前系统生效的设置值。hard 表明系统中所能设定的最大值。soft的限制不能比hard限制高。用 - 就表明同时设置了 soft 和 hard 的值。 resource:core 限制内核文件的大小date 最大数据大小fsize 最大文件大小memlock 最大锁定内存地址空间nofile 打开文件的最大数目rss 最大持久设置大小stack 最大栈大小cpu 以分钟为单位的最多CPU时间noproc 进程的最大数目as 地址空间限制maxlogins 此用户允

3、许登录的最大数目配置文件里的原文解释:# can be one of the following:# - core - limits the core file size (KB)# - data - max data size (KB)# - fsize - maximum filesize (KB)# - memlock - max locked-in-memory address space (KB)# - nofile - max number of open files# - rss - max resident set size (KB)# - stack - max stack

4、size (KB)# - cpu - max CPU time (MIN)# - nproc - max number of processes# - as - address space limit# - maxlogins - max number of logins for this user# - maxsyslogins - max number of logins on the system# - priority - the priority to run user process with - 2 -# - locks - max number of file locks th

5、e user can hold# - sigpending - max number of pending signals# - msgqueue - max memory used by POSIX message queues (bytes)# - nice - max nice priority allowed to raise to# - rtprio - max realtime priority1.2. ulimit 命令参数说明ulimit options limitoptions 含义-H 设置硬资源限制。-S 设置软资源限制,不能超过硬资源设置。-a 显示当前所有的 limi

6、t 信息。-c 最大的 core 文件的大小, 以 blocks 为单位。-d 进程最大的数据段的大小,以 Kbytes 为单位。-f 进程可以创建文件的最大值,以 blocks 为单位。-l 最大可加锁内存大小,以 Kbytes 为单位。-m 最大内存大小,以 Kbytes 为单位。-n 可以打开最大文件数的数量。-p 管道缓冲区的大小,以 Kbytes 为单位。-s 线程栈大小,以 Kbytes 为单位。-t 最大的 CPU 占用时间,以秒为单位。-u 用户最大可用的进程数。-v 进程最大可用的虚拟内存,以 Kbytes 为单位。1.3. RedHat5.5 用户限制的默认值roottes

7、t3 # ulimit -acore file size (blocks, -c) 0data seg size (kbytes, -d) unlimitedscheduling priority (-e) 0file size (blocks, -f) unlimitedpending signals (-i) 40960max locked memory (kbytes, -l) 32max memory size (kbytes, -m) unlimitedopen files (-n) 1024pipe size (512 bytes, -p) 8POSIX message queue

8、s (bytes, -q) 819200real-time priority (-r) 0stack size (kbytes, -s) 10240cpu time (seconds, -t) unlimitedmax user processes (-u) 40960virtual memory (kbytes, -v) unlimitedfile locks (-x) unlimited可以发现,常用的“max user processes”(最大用户进程数)无需修改, “open files”(打开文件数)需要修改。 - 3 -2. 修改打开文件数 nofile2.1. 方法 1,修改

9、limits.conf例如安装数据库时,希望将oracle用户的打开文件数改为65536。对所有用户:# vi /etc/security/limits.conf* soft nofile 65536* hard nofile 65536只针对oracle用户:# vi /etc/security/limits.conforacle soft nofile 65536oracle hard nofile 655362.2. 方法 2,修改 profile对所有用户:# vi /etc/profileulimit -n 65536只针对oracle、grid用户:# vi /etc/profil

10、eif $USER = oracle | $USER = grid ; thenif $SHELL = /bin/ksh ; thenulimit -u 16384ulimit -n 65536elseulimit -u 16384 -n 65536fifi2.3. 注意事项 方法 1、方法 2 均不需要重启主机,只要重新登录主机或者重新切换到 oracle 用户即可。 如果方法 1、方法 2 均做了修改,以方法 2 为准,因为 profile 在 limit.conf 后执行 方法 1 里的 soft、hard 均要设置,只设置 soft,有可能会大于当前的 hard 值,导致设置失败。3.

11、 其它说明3.1. 查询用户所有的限制值使用 ulimit -a 看到的就是 soft 类型的限制值,hard 类型的限制值只是用作调整 soft 值时的一个上限限制。 - 4 -3.2. 设置参数值如果 soft 值大于当前的 hard 值,使用 ulimit 修改会报错。例如打开文件数的原先 hard 值为 1024,修改 soft 值时提示失败:roottest3 # ulimit -Sn 2048-bash: ulimit: open files: cannot modify limit: Invalid argument先修改 hard 值,再修改 soft 值:roottest3 # ulimit -Hn 2048roottest3 # ulimit -Sn 2048或者最简单的方法,只用“-n”参数,同时修改 hard 值、hard 值:roottest3 # ulimit -n 20483.3. 几种查询“打开文件数”方法查询当前值,也就是 soft 值:roottest3 # ulimit -n1024查询当前的 hard 值:roottest3 # ulimit -Hn2048查询当前的 soft 值,与不加 S 的效果相同:roottest3 # ulimit -Sn1024

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 研究报告 > 综合/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号