[httpd][daily] 查看并修改httpd的最大fd打开个数limit
重要提示: 请直接阅读步骤(6),如果不生效,再回头阅读(1)-(5)。
如题:
修改这个文件就行了:/etc/security/limits.conf
查看当前配置的方法:
1. 找到httpd的pid(中间那三个apache的)
[root@server-tong- ~]# ps -ef |grep httpd
root : ? :: /usr/sbin/httpd -DFOREGROUND
apache : ? :: /usr/sbin/httpd -DFOREGROUND
apache : ? :: /usr/sbin/httpd -DFOREGROUND
apache : ? :: /usr/sbin/httpd -DFOREGROUND
apache : ? :: /usr/sbin/httpd -DFOREGROUND
root : pts/ :: grep --color=auto httpd
2. 查看这几个进程当前使用的值
[root@server-tong- ~]# cat /proc//limits
Limit 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 unlimited bytes
Max core file size unlimited bytes
Max resident set unlimited unlimited bytes
Max processes processes
Max open files files
Max locked memory bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals signals
Max msgqueue size bytes
Max nice priority
Max realtime priority
Max realtime timeout unlimited unlimited us
3. 查看系统允许修改的最大值,以及用户名
[root@server-tong- ~]# cat /etc/shadow |grep apa
apache:!!:::::::
[root@server-tong- ~]# cat /proc/sys/fs/nr_open
查到,limit可以使用的最大值是1048576,用户名是apache
另外,需要提到的一点,我曾经尝试直接将这个值设置成unlimited, 结果导致了root无法登录。【大哭~~】,后来想办法进去之后,查看到报错如下:【tag:修改limit.conf之后 ssh失败 root无法登录 OS无法登录】
Dec :: server-tong- login: pam_limits(login:session): Could not set limit for 'nofile': Operation not permitted
Dec :: server-tong- login: pam_unix(login:session): session opened for user root by LOGIN(uid=)
Dec :: server-tong- login: Permission denied
Dec :: server-tong- login: pam_limits(login:session): Could not set limit for 'nofile': Operation not permitted
Dec :: server-tong- login: pam_unix(login:session): session opened for user root by LOGIN(uid=)
Dec :: server-tong- login: Permission denied
Dec :: server-tong- login: pam_limits(login:session): Could not set limit for 'nofile': Operation not permitted
Dec :: server-tong- login: pam_unix(login:session): session opened for user root by LOGIN(uid=)
Dec :: server-tong- login: Permission denied
Dec :: server-tong- login: pam_unix(login:auth): check pass; user unknown
Dec :: server-tong- login: pam_unix(login:auth): authentication failure; logname=LOGIN uid= euid= tty=tty1 ruser= rhost=
Dec :: server-tong- login: FAILED LOGIN FROM tty1 FOR (unknown), User not known to the underlying authentication module
Dec :: server-tong- login: pam_limits(login:session): Could not set limit for 'nofile': Operation not permitted
Dec :: server-tong- login: pam_unix(login:session): session opened for user root by LOGIN(uid=)
Dec :: server-tong- login: Permission denied
Dec :: server-tong- crond[]: pam_limits(crond:session): Could not set limit for 'nofile': Operation not permitted
Dec :: server-tong- crond[]: pam_limits(crond:session): Could not set limit for 'nofile': Operation not permitted
Dec :: server-tong- sshd[]: Received signal ; terminating.
4. 准备就绪后,我们现在来修改limit.conf文件吧!追加两行配置如下,并重启OS
[root@server-tong- ~]# tail -n3 /etc/security/limits.conf
apache hard nofile
apache soft nofile
# End of file
[root@server-tong- ~]#
5. 用2中的方法查看修改是否成功。
结果,令人尴尬的是,这个修改并不好使。。。。。
为什么呢? 因为我使用systemctl来管理httpd服务的启动的。所以当使用systemctl来start的时候,并不生效。但是手动执行/usr/bin/httpd是生效的。
这个时候我们需要步骤六,来搞定这一切
6. 修改 httpd.service文件
在 [Service] 章节增加如下一行:
LimitNOFILE=
重启服务。
详见:https://fredrikaverpil.github.io/2016/04/27/systemd-and-resource-limits/
更值得注意的一件事情是什么呢?
这里边,1到5的步骤都是可以省略的,直接改第六步就可以生效了。
完!
[httpd][daily] 查看并修改httpd的最大fd打开个数limit的更多相关文章
- 修改httpd端口
修改httpd端口 默认httpd端口为80,现在改成800 修改两个地方: 1.修改配置文件httpd.conf listen 把80改成需要的端口 2.修改配置文件httpd-vhosts.con ...
- CentOS时间的查看与修改
[http://www.centoscn.com/CentOS/help/2014/0805/3430.html] 1.查看.修改Linux时区与时间 一.linux时区的查看与修改 1,查看当前时区 ...
- 【转】linux查看及修改文件权限以及相关
linux查看及修改文件权限以及相关 查看文件权限的语句: 在终端输入: ls -l xxx.xxx (xxx.xxx是文件名) 那么就会出现相类似的信息,主要都是这些: -rw-rw-r-- 一共有 ...
- linux文件权限查看及修改(实用)
查看Linux文件的权限:ls -l 文件名称 查看linux文件夹的权限:ls -ld 文件夹名称(所在目录) 修改文件及文件夹权限: sudo chmod -(代表类型)×××(所有者)×××(组 ...
- JavaWeb 学习006-4个页面,5条sql语句(添加、查看、修改、删除)
今天遇到的问题: 1. 在list页面上添加信息时候,跳转到doAdd页面后,点击保存按钮,能够跳转回list页面,但是新增的信息不能显示出来,就像是没有执行添加操作一样. 这是什么问题? ①是不是到 ...
- linux查看和修改当前系统时间
一.查看和修改Linux的时区 1. 查看当前时区 命令 : "date -R" 2. 修改设置Linux服务器时区 方法 A 命令 : "tzselect" ...
- MySQL系列:查看并修改当前数据库的编码
MySQL中,数据库的编码是一个相当重要的问题,有时候我们需要查看一下当前数据库的编码,甚至需要修改一下数据库编码. 查看当前数据库编码的SQL语句为: mysql> use xxx ...
- java笔记--查看和修改线程名称
查看和修改线程名称 --如果朋友您想转载本文章请注明转载地址"http://www.cnblogs.com/XHJT/p/3893797.html "谢谢-- java是一种允许 ...
- java笔记--查看和修改线程的优先级
查看和修改线程的优先级 java中每一个线程都有优先级属性,在默认情况下,新建的线程的优先级与创建该线程的线程优先级相同.每当线程调度器选择要运行的线程时,通常选择优先级较高的线程. 注:线程的优先级 ...
随机推荐
- 【大话QT之十二】基于CTK Plugin Framework的插件版本号动态升级
应用需求: 某些场景下我们可能面临这种问题,在执行着的应用程序不能终止的情况下,升级某个功能(或添,或减.或改动).在不採用CTK Plugin Framework插件系统架构的情况下这将是非常困难的 ...
- R文本挖掘之jiebaR包
library(jiebaRD)library(jiebaR) ##调入分词的库cutter <- worker()mydata =read.csv(file.choose(),fileEnc ...
- VMVare 虚拟机使用桥接模式
VMVare 虚拟机使用桥接模式,和物理机使用同一个物理网卡,和物理主机使用同一个段的ip. 1.VMware 编辑 > 虚拟网络编辑器 2.更改配置 3.编辑名称为VMnet0 的网络(如果 ...
- Xcode No account for team "". Add a new account in the Accounts preference pane or verify that your accounts have valid credentials.
问题背景 Xcode报错误信息:No account for team "QMP96B5DPW". Add a new account in the Accounts prefer ...
- Spring Framework 5.x 学习专栏
Spring Framework 5.0 入门篇 Spring构建REST Web Service 消费一个RESTful Web Service 事务管理 Spring使用JDBC访问关系数据 任务 ...
- Win10 calc.exe 无法打开计算器的解决方法
先将所有程序关闭,以管理员身份运行 Windows PowerShell,之后输入以下命令 Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage - ...
- 移动开发常用meta设置
<!-- 视图窗口,移动端特属的标签. --> <meta name="viewport" content="width=device-width,in ...
- C++数值类型与string的相互转换
转自:https://www.cnblogs.com/johngu/p/7878029.html 1.数值类型转换为string 1.1使用函数模板+ostringstream 使用函数模板将基本数据 ...
- 解决Warning Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
系统:Ubuntu 16.04 LTS 环境:vscode+java extension pack打开了一个gradle的java项目:另外,用一个terminal启动了groovysh 报错: gr ...
- pyCoreImage Learn
目录 PyCoreImage 安装 高斯模糊滤镜的例子 使用详细步骤说明 常见操作 滤镜操作 打印所有的滤镜列表 打印某个滤镜的详细信息 使用 zoomBlur 滤镜 使用 mono 滤镜 使用叠加率 ...