概述

在linux系统使用过程中,默认的系统设置足够使用,但是对于一些高并发高性能的程序会有瓶颈存在,这些限制主要通过ulimit查看和修改。

环境

centos:CentOS  release 7.0 (Final)或以上版本

ulimit查看

通过命令查看当前账户的限定设置。

ulimit -a

core file size          (blocks, -c) unlimited

data seg size           (kbytes, -d) unlimited

scheduling priority             (-e) 0

file size               (blocks, -f) unlimited

pending signals                 (-i) unlimited

max locked memory       (kbytes, -l) unlimited

max memory size         (kbytes, -m) unlimited

open files                      (-n) 65536

pipe size            (512 bytes, -p) 8

POSIX message queues     (bytes, -q) unlimited

real-time priority              (-r) 0

stack size              (kbytes, -s) 8192

cpu time               (seconds, -t) unlimited

max user processes              (-u) 65536

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

其中,比较常用的几个是。

“core file size”(coredump记录文件大小,默认为0不记录)。

“open files”(进程打开文件最大数量,默认1024,网络连接较多时会存在瓶颈)。

“max user processes”(用户最大进程数,多进程程序修改)。

设定

ulimit资源设定的修改分硬限制和软限制,软限制无法超过硬限制的上限,硬限制设定需要修改系统配置文件。

格式和说明都在配置文件中有清晰的描述。

vi /etc/security/limits.conf

#Each line describes a limit for a user in the form:

#

#<domain>        <type>  <item>  <value>

#

#Where:

#<domain> can be:

#        - a user name

#        - a group name, with @group syntax

#        - the wildcard *, for default entry

#        - the wildcard %, can be also used with %group syntax,

#                 for maxlogin limit

#

#<type> can have the two values:

#        - "soft" for enforcing the soft limits

#        - "hard" for enforcing hard limits

#

#<item> can be one of the following:

#        - core - limits the core file size (KB)

#        - data - max data size (KB)

#        - fsize - maximum filesize (KB)

#        - memlock - max locked-in-memory address space (KB)

#        - nofile - max number of open file descriptors

#        - rss - max resident set size (KB)

#        - stack - max stack size (KB)

#        - cpu - max CPU time (MIN)

#        - nproc - max number of processes

#        - as - address space limit (KB)

#        - maxlogins - max number of logins for this user

#        - maxsyslogins - max number of logins on the system

#        - priority - the priority to run user process with

#        - locks - max number of file locks the user can hold

#        - sigpending - max number of pending signals

#        - msgqueue - max memory used by POSIX message queues (bytes)

#        - nice - max nice priority allowed to raise to values: [-20, 19]

#        - rtprio - max realtime priority

#

#<domain>      <type>  <item>         <value>

* soft core unlimited

* hard core unlimited

* soft data unlimited

* hard data unlimited

* soft fsize unlimited

* hard fsize unlimited

* soft sigpending unlimited

* hard sigpending unlimited

* soft nofile 65536

* hard nofile 65536

* soft msgqueue unlimited

* hard msgqueue unlimited

* soft nproc 65536

* hard nproc 65536

* soft locks unlimited

* hard locks unlimited

* soft memlock unlimited

* hard memlock unlimited

修改账户启动执行脚本。

vi ./bash_profile

ulimit -c unlimited

ulimit -d unlimited

ulimit -f unlimited

ulimit -i unlimited

ulimit -n 65536

ulimit -q unlimited

ulimit -u 65536

ulimit -x unlimited

ulimit -l unlimited

总结

实际使用过程中,需要根据服务器运行的程序放开资源的限制。

空空如常

求真得真

centos7系统资源限制整理的更多相关文章

  1. CentOS7 常用命名整理

    前言: 总是为了一点命令去查搜索引擎,今天简单整理了一下常用的一些命名: 一.网络配置相关 0.修改 IP&DNS 信息 # vi /etc/sysconfig/network-scripts ...

  2. Centos6、Centos7防火墙基本操作整理

    Centos7: 查看防火墙状态: firewall-cmd --state 开启防火墙: systemctl start firewalld.service 关闭防火墙(重启失效): systemc ...

  3. CentOS6与CentOS7的几点区别

    重新安装了一个CentOS7,顺便整理一下与自己之前用的CentOS6的区别 CentOS6以下简称c6  CentOS7以下简称c7 1.关于文件系统: c6 6.x使用EXT4,EXT4单个文件系 ...

  4. redis批量灌库

    需求:将批量数据灌入redis中 如果通过代码形式将数据灌入redis中,效率比较低,以下将根据redis的特性进行快速的批量灌库 环境:centos7 将数据整理成规定格式的文件,比如: SET k ...

  5. Centos7搭建php+mysql环境(整理篇)

    终于将mysql+php环境搭建成功,将之前的整理一下,环境:centos7,本机IP:192.168.1.24,数据库用户名及密码都设为root,测试文件路径:/var/www/html 1.取消c ...

  6. CentOS7开放端口以及常用的使用命令记录整理

    CentOS7与以前常用的CentOS6还是有一些不同之处的,比如在设置开放端口的时候稍许有些不同,常用的iptables命令已经被firewalld代替.这几天正好有在CentOS7系统中玩Seaf ...

  7. centos7上安装与配置Tomcat7(整理篇)

    1.检查tomcat7是否已经安装 rpm -qa | grep tomcat ps -ef | grep tomcat 第一条命令查看是用rpm安装过tomcat,由于我们倾向于安装解压版的tomc ...

  8. expresscache和primocache加速资料整理-centos7缓存加速

    expresscache和primocachehttp://www.360doc.com/content/16/0111/17/256680_527142090.shtml 安装expresscach ...

  9. 直接从硬盘安装centos7网址整理

    1.https://blog.csdn.net/happy_joker/article/details/52822025 注意:(1)第3步-->Linux引导安装-->软件选择--> ...

随机推荐

  1. Dubbo源码(一) - SPI使用

    为什么学SPI Dubbo 的可扩展性是基于 SPI 去实现的,而且Dubbo所有的组件都是通过 SPI 机制加载. 什么是SPI SPI 全称为 (Service Provider Interfac ...

  2. 出现 Expected 0 arguments but found 1 的bug原因

    问题:在给FileInputStream传入参数时报错 原以为是导错了包,结果试了几次都不行,最后才发现是项目名和这个方法名重复了,修改项目名就可以了! 红线出只是异常,抛出即可解决

  3. 乘风破浪,遇见未来新能源汽车(Electric Vehicle)之特斯拉提车必须知道的十个流程

    订车 线下门店或者官网可以咨询和下单,一般来说,订金就是1000,还算可以接受. 订单账号 特斯拉账号是以邮箱为区分的,而不是手机号,我们下单的时候需要提供一个邮箱用来注册特斯拉账号. 注意了,敲黑板 ...

  4. YII事件EVENT示例

    模型中/** * 在初始化时进行事件绑定 */ public function init() { $this->on(self::EVENT_HELLO,[$this,'sendMail']); ...

  5. 浩若烟海事半功倍|利用Docker容器技术构建自动化分布式web测试集群Selenium Grid

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_195 "世界上有那么多城市,城市里有那么多的酒馆,可她,却偏偏走进了我的-",这是电影<卡萨布拉卡> ...

  6. NodeJS & Dapr Javascript SDK 官方使用指南

    Dapr 是一个可移植的.事件驱动的运行时,它使任何开发人员能够轻松构建出弹性的.无状态和有状态的应用程序,并可运行在云平台或边缘计算中,它同时也支持多种编程语言和开发框架.Dapr 确保开发人员专注 ...

  7. LuoguP1456 Monkey King (左偏树)

    struct LeftTree{ int l,r,val,dis; }t[N]; int fa[N]; inline int Find(int x){ return x == fa[x] ? x : ...

  8. Luogu3594 [POI2015]WIL-Wilcze doły (双端队列)

    单调性显然,双端队列队列维护严格单调递减手写双端队列真的可恶. #include <iostream> #include <cstdio> #include <cstri ...

  9. Linux 04 用户文件

    参考源 https://www.bilibili.com/video/BV187411y7hF?spm_id_from=333.999.0.0 版本 本文章基于 CentOS 7.6 概述 完成用户管 ...

  10. Excel 插入嵌入式图表和独立图表的方法

    描述 嵌入式图表:是一种与当前工作表相同位置的图表,且悬浮在表格之上,不受表格限制,因此称之为嵌入式图表. 独立图表:是独立于当前工作表的图表,打印时,需要单独将其打印出来. 插入独立图表的图文教程: ...