一、问题描述

修改 /etc/security/limits.conf ,重启之后不生效

内容如下:

* soft nofile
* hard nofile
root soft nofile
root hard nofile
* soft nproc
* hard nproc
root soft nproc
root hard nproc

二、解决问题

根据网上资料的说法有几种

1. 修改 /etc/ssh/sshd_config

开启这2项

UsePAM yes
UseLogin yes

2. 以下几个文件

/etc/pam.d/login
/etc/pam.d/su
/etc/pam.d/sshd

确保开启了pam_limits.so

session    required   pam_limits.so

3. 重启系统

注意:修改了/etc/security/limits.conf ,必须要重启,才能生效。

以上几个,都测试了一下,open files没有生效!max user processes倒是生效了

root@ubuntu:~# 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

最后终于找到原因了,是因为 内核参数没有配置

# 编辑配置文件
vi /etc/sysctl.conf fs.nr_open = # 重新加载
sysctl -p

再次重启,效果如下:

root@ubuntu:~# 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) 2048576
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

本文参考链接:

https://blog.51cto.com/jonyisme/1919075

Ubuntu /etc/security/limits.conf 不生效问题的更多相关文章

  1. CentOS 6 修改/etc/security/limits.conf不生效办法

    我们使用CentOS系统,在部署新的服务经常会遇到 打开最大文件数限制 too many open files的警告,通常我们只需要修改/etc/security/limits.conf该文件,增加两 ...

  2. /etc/security/limits.conf不生效

    总结下来发现要使limits.conf生效,需要在  /etc/ssh/sshd_config  配置中 设置 UsePAM  yes UseLogin yes    #这个保证其他的用户也能修改设置 ...

  3. linux资源使用配置文件 /etc/security/limits.conf和ulimit

    limits.conf文件实际上是linux PAM中pam_limits.so的配置文件,而且只针对于单个会话. limits.conf的格式如下: <domain> <type& ...

  4. 理解RHEL上安装oracle的配置参数 :/etc/security/limits.conf, /etc/profile, /etc/pam.d/login

    无论安装什么版本的Oracle,在安装之前,都需要配置 /etc/pam.d/login   /etc/profile   /etc/security/limits.conf这三个文件 那这三个文件究 ...

  5. too many open file /etc/security/limits.conf

      当出现too mang open file 时更改/etc/profile中的ulimit -n 65536 ,查看   然后ssh进去,或者退出之后重新登录使之生效                ...

  6. /etc/security/limits.conf

    ulimit 命令用来限制系统用户对 shell 资源的访问,但只是临时生效,想要永久生效需要配置 /etc/security/limits.conf 文件,语法及常见配置如下: [root@loca ...

  7. Linux资源使用配置文件 /etc/security/limits.conf

    Linux资源使用配置文件 /etc/security/limits.conf http://www.linuxidc.com/Linux/2012-05/59489.htm Linux就这个范儿P5 ...

  8. 转载:/etc/security/limits.conf 控制文件描述符,进程数,栈大小

    原文地址:http://ilikedo.iteye.com/blog/1554822 linux下安装Oracle 一般都会修改/etc/security/limits.conf这个文件,但是这里面的 ...

  9. [转载]/etc/security/limits.conf解释及应用

    limits.conf的格式如下: username|@groupname type resource limit username|@groupname:设置需要被限制的用户名,组名前面加@和用户名 ...

随机推荐

  1. Zotero使用教程(2)-数据备份

    小书匠 这篇文章的目标是让你无论是 换系统,重新安装zotero等都可以还原回你的文献库,而且整个过程基本是自动完成的. 这部分解决下面的两种情况: 1.zotero有自己既定的一套存储方式,不是一般 ...

  2. hbase 由于zookeeper问题导致连接失败问题

    问题现象: 使用hbase shell 连接报如下问题: 2019-10-09 10:37:18,855 ERROR [main] zookeeper.RecoverableZooKeeper: Zo ...

  3. 【NQG】Paragraph-level Neural Question Generation with Maxout Pointer and Gated Self-attention Networks论文笔记

    这篇文章主要处理了在问题生成(Question Generation,QG)中,长文本(多为段落)在seq2seq模型中表现不佳的问题.长文本在生成高质量问题方面不可或缺. 1. Introducti ...

  4. Cookie和Session原理

    由于HTTP是无状态的协议,客户程序每次都去web页面,都打开到web服务器的单独的连接,并且不维护客户的上下文信息.如果需要维护上下文信息,比如用户登录系统后,每次都能够知道操作的是此登录用户,而不 ...

  5. 【CNN】--- 卷积过程中RGB与灰度的区别

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/hacker_Dem_br/article/ ...

  6. 经典批处理实现自动关机(BAT)

    经典批处理实现自动关机1.BAT @ECHO offTITLE 自动关机程序 作者:廖晓青 :startCLSCOLOR 1frem 使用COLOR命令对控制台输出颜色进行更改MODE con: CO ...

  7. jmeter BeanShell断言(四)

    Bean Shell常用内置变量 JMeter在它的BeanShell中内置了变量,用户可以通过这些变量与JMeter进行交互,其中主要的变量及其使用方法如下: log:写入信息到jmeber.log ...

  8. JVM探究之 —— OOM异常

    在Java虚拟机规范的描述中,除了程序计数器外,虚拟机内存的其他几个运行时区域都有发生OutOfMemoryError(下文称OOM)异常的可能.本节探究主要基于jdk1.8的内存结构. 1. Jav ...

  9. Mxnet:以全连接层为例子自定义新的操作(层)

    https://blog.csdn.net/a350203223/article/details/77449630 在使用深度学习平台时,光会使用其中已定义好的操作有时候是满足不了实际使用的,一般需要 ...

  10. elementUI-tree组件 懒加载

    <el-tree ref="tree" :data="menu.treeData" :props="menu.defaultProps" ...