Centos ulimit设置
1.三处配置
1. 系统编译时默认设置文件(centos7新增)
服务配置 /etc/systemd/system.conf
用户配置 /etc/systemd/user.conf
2. PAM模块配置文件
/etc/security/limits.conf
EXAMPLES
These are some example lines which might be specified in /etc/security/limits.conf.
* soft core 0
* hard nofile 512
@student hard nproc 20
@faculty soft nproc 20
@faculty hard nproc 50
ftp hard nproc 0
@student - maxlogins 4
:123 hard cpu 5000
@500: soft cpu 10000
600:700 hard locks 10
第一列用户和组名:*表示通配所有用户;@表示组名;:表示uid或者gid;
第二列资源值类型:hard的值只能由root用户增加,其root权限用户和进程可以减少;soft的值,非root用户和进程可以修改;
第三列是资源类型:nofile为打开文件数,nproc为运行进程数,maxlogins为登录次数cpu、ram等等
第四列是资源数值:大于0的数值
非root用户的默认最大进程数配置文件/etc/security/limits.d/20-nproc.conf内容如下:
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 4096
root soft nproc unlimited
3.profile配置文件
系统默认配置文件(ulimit命令设置) /etc/profile 和 /etc/bashrc
用户家目录下的配置文件 bash_profile 和 .bashrc
用户shell或者服务启动脚本内运行 ulimit -n 10240
4.验证非root权限用户不能增加hard值(以nofile为例) 如果ulimit运行在非root用户的shell下,只能修改比当前值小,大的会报错
[tomcat@localhost ~]$ ulimit -n
4096
[tomcat@localhost ~]$ ulimit -n 8192
-bash: ulimit: open files: cannot modify limit: Operation not permitted
2.优先级
第一优先级:最后一次ulimit命令设置
第二优先级:/etc/security/limits.d/
第三优先级:/etc/security/limits.conf
系统优先级:/etc/systemd/system.conf 、user.conf
所谓系统优先级,即不受一二三优先级的影响,针对系统服务和用户服务的配置
3.系统服务配置举例
假设系统内的apache需要设置打开文件为20000
建立apache服务的配置文件的目录
mkdir -p /etc/systemd/system/httpd.service.d/
创建如下apache的独立配置文件
cat /etc/systemd/system/httpd.service.d/limits.conf
[Service]
LimitNOFILE=20000 #操作系统级别对每个用户创建的进程数的限制
LimitNPROC=20000 #每个进程可以打开的文件数的限制
systemd重读新的配置文件
systemctl daemon-reload
systemctl restart httpd
4.系统配置举例
centos7
[root@centos7 infra]# cat /etc/security/limits.d/20-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning. #* soft nproc 4096
#root soft nproc unlimited
* soft nofile 102400
* hard nofile 102400
root soft nofile 102400
root hard nofile 102400
* soft nproc 102400
* hard nproc 102400
root soft core unlimited
centos6
[root@centos6 infra]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning. #* soft nproc 1024
#root soft nproc unlimited * soft nofile 100001
* hard nofile 100002
* soft nproc 100001
* hard nproc 100002
* soft core unlimited
* hard core unlimited
Centos ulimit设置的更多相关文章
- 如何在 CentOS 中设置 NTP 服务器
网络时间协议(NTP)用来同步网络上不同主机的系统时间.你管理的所有主机都可以和一个指定的被称为 NTP 服务器的时间服务器同步它们的时间.而另一方面,一个 NTP 服务器会将它的时间和任意公共 NT ...
- VMware于CentOS网络设置
VMware于CentOS网络设置 底: 笔记本电脑有两块网卡: 1. 网卡连接公司内网,仅仅配置了内网ip和子网掩码. 2. 无线网卡.连接4g无线路由器.dhcp自己主动配置. 问题: 在VMwa ...
- CentOS 网络设置修改 指定IP地址 DNS 网关(转)
CentOS 网络设置修改 指定IP地址 DNS 网关(实测 笔记) 环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G) 系统版本:Centos-6.5-x86_64 ...
- CentOS 网络设置
CentOS 网络设置有两种方式配置网络可以连接外网: 自动分配与手动设置Ip 一,自动分配ip: 新装的centos6.0,用ifconfig只显示ifcfg-lo的信息,可以用ifup eth0的 ...
- linux centos 如何设置swap大小?
linux centos 如何设置swap大小? swap的值都是安装系统的时候设置好的,一般设置为内存的两倍大小.使用过程中发现swap值过小只能添加.用free -m 命令查看当前swap大小 使 ...
- yum命令安装软件时,出现--centos 7 安装apache 出现 Could not resolve host: mirrorlist.centos.org; 未知的错误"--CentOS网络设置 couldn't resolve host 'mirrorlist.centos.org问题解决
CentOS网络设置 couldn't resolve host 'mirrorlist.centos.org问题解决 今天在虚拟机上安装完CentOS6.5之后,首次使用时yum命令安装软件时,出现 ...
- centos 基础设置
centos 6 关闭防火墙 查看防火墙是否开启 service iptables status 停止防火墙 service iptables stop 禁止开机自启动防火墙 chkconfig ip ...
- CentOS中设置Windows共享文件夹
在CentOS中设置Samba可实现和Windows共享文件夹.常见的需求:1)用户能够在Windows机器上通过共享文件夹访问远程Linux服务器上自己的主目录:2)用户能够在Windows机器上访 ...
- Centos 7设置静态IP,修改时区,关闭防火墙
Centos 7设置静态IP # vi /etc/sysconfig/network-scripts/ifcfg-enxxx BOOTPROTO="static" ...... I ...
随机推荐
- [刷题] PTA 02-线性结构3 Reversing Linked List
链表逆序 1 #include<iostream> 2 #include<stdio.h> 3 #include<algorithm> 4 using namesp ...
- systemctl服务------字符和图像界面切换systemctl set-default multi-user.target systemctl isolate multi-user.target #当前立即进入字符模式 [root@room4pc09 桌面]# systemctl isolate graphical.target #当前立即进入图形模式
查看服务运行状态 [root@room4pc09 桌面]# systemctl status crond #查看服务运行状态 ● crond.service - Command Scheduler L ...
- QT学习笔记(一)——Helloworld
QT学习笔记(一)--Helloworld 一.调试的基本方法: Log调试法 --在代码中加入一定的打印语句 --打印程序状态和关键变量的值 断点调试法: --在开发环境中的对应代码行加上断点 -- ...
- zabbix监控之邮件报警通知
zabbix官网的操作指南:https://www.zabbix.com/documentation/4.0/zh/manual 首先我们需要创建一个需要被监控的主机,并设置相应的监控项.当监控项收集 ...
- origin2018去掉demo水印
消除demo字样 有的origin破解完成后,使用没问题,但导出的图有demo水印.其实不需要重装,只需要下载一个补丁即可解决. 1. 把下载到的origin.exe复制到安装文件夹 2. 双击执行一 ...
- linux route命令的使用详解-(转自小C爱学习)
route命令用于显示和操作IP路由表.要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或者同时位于两个网络的网关来实现.在Linux系统中,设置路由通常是 为了解决以下问题:该Linu ...
- JS轮播图(网易云轮播图)
JS 轮播图 写在前面 最聪明的人是最不愿浪费时间的人.--但丁 实现功能 图片自动切换 鼠标移入停止自动播放,显示按钮 点击按钮,实现前后翻 鼠标移入小圆圈,可以跳转到对应图片 点击左右两侧图片部分 ...
- uboot通过NFS挂载ubuntu根文件系统
由于工作需要,在做app开发或系统移植时,经常需要编辑系统后重新烧写异常麻烦.通过NFS挂载根文件系统就不需要每次更改系统后再进行编译和烧写,等开发完成后一次烧写即可完成. 一.准备材料 可以根据自己 ...
- Lua在Windows下的安装、配置、运行
Lua在Windows下的安装.配置.运行 本文链接:https://blog.csdn.net/ChinarCSDN/article/details/78667262 展开 # Windows下安装 ...
- GO学习-(1) why go?
为什么你应该学习Go语言? 终于等到你!Go语言--让你用写Python代码的开发效率编写C语言代码. 为什么互联网世界需要Go语言 世界上已经有太多太多的编程语言了,为什么又出来一个Go语言? 硬件 ...