概述

在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. Rails_via牛客网

    题目 链接:https://ac.nowcoder.com/acm/contest/28537/D 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言 ...

  2. 微信公众号授权登录后报redirect_uri参数错误的问题

      在进行微信公众号二次开发的时候,需要通过授权码模式来进行微信授权.比如,在进行登录的时候,用户点击了登录按钮,然后弹出一个授权框,用户点击同意后,就可以获取用户的OpenId等信息了.这篇文章主要 ...

  3. 配置Webpack Dev Server 实战操作方法步骤

    本文摘要:配置 Webpack Dev Server 可以解决本地开发前端应用时,手动执行 webpack 命令或 yarn build 命令,再去浏览器中访问 dist/index.html 的麻烦 ...

  4. 编译式安装MYSQL

    安装所需组件 实际上只需要这四个配置即可 升级boot开始 升级结束 重新执行cmake make && make install 启动mysql 发现启动失败 #####原因:这是由 ...

  5. 用JavaScript写一个进度条

    var porpressBar = document.getElementById('progressBar') var info = document.getElementById('info') ...

  6. 产品 | GreatSQL,打造更好的MGR生态

    欢迎来到 GreatSQL社区分享的MySQL技术文章,如有疑问或想学习的内容,可以在下方评论区留言,看到后会进行解答 GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 用 ...

  7. Qt 国际化翻译

    简介 Qt Linguist 提供了一套加速应用程序翻译和国际化的工具.Qt 使用单一的源码树和单一的应用程序二进制包就可同时支持多个语言和书写系统. 使用 QTranslator 来加载生成的 qm ...

  8. MySQL查询性能优化七种武器之索引潜水

    有读者可能会一脸懵逼? 啥是索引潜水? 你给起的名字的吗?有没有索引蛙泳? 这个名字还真不是我起的,今天要讲的知识点就叫索引潜水(Index dive). 先要从一件怪事说起: 我先造点数据复现一下问 ...

  9. benchmark性能测试

    目录 benchmark介绍 benchmark运行 benchmark运行参数 benchmark性能测试案例 benchmark介绍 基准测试主要是通过测试CPU和内存的效率问题,来评估被测试代码 ...

  10. 用HTTP服务的方式集成learned cardinality estimate方法进 Postgresql

    代码地址:postgresql-13.1-ml: Integration of CardEst Methods into PostgreSQL by HTTP Server (github.com) ...