一、问题描述

修改 /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. vue-cli3 ios10白屏问题解决思路

    在出现了这个问题之后先不要盲目的去瞎试,根据网上的方法试了个遍也没解决问题 先看报的是什么错,再针对的解决问题 首先出现的报错是 SyntaxError: Unexpected token '*'  ...

  2. GoCN每日新闻(2019-10-01)

    GoCN每日新闻(2019-10-01) GoCN每日新闻(2019-10-01) 1. 我依然爱着 GOPATH https://divan.dev/posts/gopath/ 2. Go 代码注释 ...

  3. django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applie

    Traceback (most recent call last): File "manage.py", line 15, in <module> execute_fr ...

  4. 程序日志-应用程序-特定 权限设置并未向在应用程序容器 不可用 SID (不可用)中运行的地址 LocalHost (使用 LRPC) 中的用户 NT AUTHORITY\SYSTEM SID (S-1-5-18)授予针对 CLSID 为 {D63B10C5-BB46-4990-A94F-E40B9D520

    应用程序-特定 权限设置并未向在应用程序容器 不可用 SID (不可用)中运行的地址 LocalHost (使用 LRPC) 中的用户 NT AUTHORITY\SYSTEM SID (S-1-5-1 ...

  5. Android 系统属性-SystemProperties详解***

    创建与修改android属性用Systemproperties.set(name, value),获取android属性用Systemproperties.get(name),需要注意的是androi ...

  6. Linux零拷贝技术 直接 io

    Linux零拷贝技术 .https://kknews.cc/code/2yeazxe.html   https://zhuanlan.zhihu.com/p/76640160 https://clou ...

  7. Qt编写气体安全管理系统27-设备调试

    一.前言 设备调试核心就是将整个系统中的所有打印数据统一显示到一个模块上,一般都会将硬件通信的收发数据和对应的解析信号发出来或者qdebug出来,这个在调试阶段非常有用,可以具体追踪问题出在哪,哪个数 ...

  8. clipboard 在 vue 项目中,on 事件监听回调多次执行

    clipboard 定义一个全局变量 import ClipboardJS from "clipboard"; if(clipboard){ clipboard.destroy() ...

  9. python:使用多线程同时执行多个函数

    使用多线程同时执行多个函数 import time import os import threading def open_calc(): with open('test.txt', 'r') as ...

  10. 【视频开发】 ffmpeg支持的硬解码接口

    To enable DXVA2, use the --enable-dxva2 ffmpeg configure switch. To test decoding, use the following ...