分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

[httpd][daily] 查看并修改httpd的最大fd打开个数limit

发布时间:2023-09-06 02:25责任编辑:郭大石关键词:http

如题:

修改这个文件就行了:/etc/security/limits.conf

查看当前配置的方法:

1. 找到httpd的pid(中间那三个apache的)

[root@server-tong-1 ~]# ps -ef |grep httpdroot ?????1234 ????1 ?0 03:21 ? ???????00:00:00 /usr/sbin/httpd -DFOREGROUNDapache ???1235 ?1234 ?0 03:21 ? ???????00:00:00 /usr/sbin/httpd -DFOREGROUNDapache ???1236 ?1234 ?0 03:21 ? ???????00:00:00 /usr/sbin/httpd -DFOREGROUNDapache ???1237 ?1234 ?0 03:21 ? ???????00:00:00 /usr/sbin/httpd -DFOREGROUNDapache ???1239 ?1234 ?0 03:21 ? ???????00:00:00 /usr/sbin/httpd -DFOREGROUNDroot ?????1537 ?1210 ?0 03:28 pts/0 ???00:00:00 grep --color=auto httpd

2. 查看这几个进程当前使用的值

[root@server-tong-1 ~]# cat /proc/1236/limitsLimit ????????????????????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 ????????????15072 ???????????????15072 ???????????????processes Max open files ???????????1024 ????????????????4096 ????????????????files ????Max locked memory ????????65536 ???????????????65536 ???????????????bytes ????Max address space ????????unlimited ???????????unlimited ???????????bytes ????Max file locks ???????????unlimited ???????????unlimited ???????????locks ????Max pending signals ??????15072 ???????????????15072 ???????????????signals ??Max msgqueue size ????????819200 ??????????????819200 ??????????????bytes ????Max nice priority ????????0 ???????????????????0 ???????????????????Max realtime priority ????0 ???????????????????0 ???????????????????Max realtime timeout ?????unlimited ???????????unlimited ???????????us ???

3. 查看系统允许修改的最大值,以及用户名

[root@server-tong-1 ~]# cat /etc/shadow |grep apaapache:!!:17833::::::[root@server-tong-1 ~]# cat /proc/sys/fs/nr_open 1048576

查到,limit可以使用的最大值是1048576,用户名是apache

另外,需要提到的一点,我曾经尝试直接将这个值设置成unlimited, 结果导致了root无法登录。【大哭~~】,后来想办法进去之后,查看到报错如下:【tag:修改limit.conf之后 ssh失败 root无法登录 OS无法登录】

546 Dec 10 02:44:03 server-tong-1 login: pam_limits(login:session): Could not set limit for ‘nofile‘: Operation not permitted547 Dec 10 02:44:03 server-tong-1 login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)548 Dec 10 02:44:03 server-tong-1 login: Permission denied549 Dec 10 02:44:15 server-tong-1 login: pam_limits(login:session): Could not set limit for ‘nofile‘: Operation not permitted550 Dec 10 02:44:15 server-tong-1 login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)551 Dec 10 02:44:15 server-tong-1 login: Permission denied552 Dec 10 02:44:42 server-tong-1 login: pam_limits(login:session): Could not set limit for ‘nofile‘: Operation not permitted553 Dec 10 02:44:42 server-tong-1 login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)554 Dec 10 02:44:42 server-tong-1 login: Permission denied555 Dec 10 02:44:55 server-tong-1 login: pam_unix(login:auth): check pass; user unknown556 Dec 10 02:44:55 server-tong-1 login: pam_unix(login:auth): authentication failure; logname=LOGIN uid=0 euid=0 tty=tty1 ruser= rhost=557 Dec 10 02:44:57 server-tong-1 login: FAILED LOGIN 1 FROM tty1 FOR (unknown), User not known to the underlying authentication module558 Dec 10 02:45:03 server-tong-1 login: pam_limits(login:session): Could not set limit for ‘nofile‘: Operation not permitted559 Dec 10 02:45:03 server-tong-1 login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)560 Dec 10 02:45:03 server-tong-1 login: Permission denied561 Dec 10 02:50:01 server-tong-1 crond[14616]: pam_limits(crond:session): Could not set limit for ‘nofile‘: Operation not permitted562 Dec 10 03:00:01 server-tong-1 crond[14649]: pam_limits(crond:session): Could not set limit for ‘nofile‘: Operation not permitted563 Dec 10 03:00:20 server-tong-1 sshd[784]: Received signal 15; terminating.

4. 准备就绪后,我们现在来修改limit.conf文件吧!追加两行配置如下,并重启OS

[root@server-tong-1 ~]# tail -n3 /etc/security/limits.conf apache hard nofile 1048576apache soft nofile 1048576# End of file[root@server-tong-1 ~]# 

5. 用2中的方法查看修改是否成功。

完!

[httpd][daily] 查看并修改httpd的最大fd打开个数limit

原文地址:https://www.cnblogs.com/hugetong/p/10095524.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved