zoukankan      html  css  js  c++  java
  • ulimit


    [root@ansible ~]# help ulimit ulimit: ulimit [-SHacdefilmnpqrstuvx] [限制] 修改 shell 资源限制。 在允许此类控制的系统上,提供对于 shell 及其创建的进程所可用的 资源的控制。 选项: -S 使用 `soft'(软)资源限制 -H 使用 `hard'(硬)资源限制 -a 所有当前限制都被报告 -b 套接字缓存尺寸 -c 创建的核文件的最大尺寸 -d 一个进程的数据区的最大尺寸 -e 最高的调度优先级(`nice') -f 有 shell 及其子进程可以写的最大文件尺寸 -i 最多的可以挂起的信号数 -l 一个进程可以锁定的最大内存尺寸 -m 最大的内存进驻尺寸 -n 最多的打开的文件描述符个数 -p 管道缓冲区尺寸 -q POSIX 信息队列的最大字节数 -r 实时调度的最大优先级 -s 最大栈尺寸 -t 最大的CPU时间,以秒为单位 -u 最大用户进程数 -v 虚拟内存尺寸 -x 最大的锁数量 如果提供了 LIMIT 变量,则它为指定资源的新的值;特别的 LIMIT 值为 `soft'、`hard'和`unlimited',分别表示当前的软限制,硬限制和无限制。 否则打印指定资源的当前限制值,不带选项则假定为 -f 取值都是1024字节为单位,除了 -t 以秒为单位,-p 以512字节为单位, -u 以无范围的进程数量。 退出状态: 返回成功,除非使用了无效的选项或者错误发生. # 查看当前系统限制信息 [root@ansb ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 7218 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 65535 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited # 查看当前系统文件文件描述符 [root@ansb ~]# ulimit -n 1024 #设置软硬链接文件描述符,临时生效,永久生效需要写道配置文件中,参考ulimit配置文件信息修改 [root@ansb ~]# ulimit -SHn 65535 [root@ansb ~]# ulimit -n 65535 # 查看当前系统进程数据限制 [root@ansb ~]# ulimit -u 65535 查看ulimit配置文件信息,路径:/etc/security/limits.conf [root@ansb ~]# vim /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 0 #* hard rss 10000 #@student hard nproc 20 #@faculty soft nproc 20 #@faculty hard nproc 50 #ftp hard nproc 0 #@student - maxlogins 4 # End of file ***修改配置文件使其永久生效

    [root@ansb ~]# cat >> /etc/security/limits.d/20-nproc.conf <<EOF
    > * soft nofile 65535
    > * hard nofile 65535
    > * soft nproc 65535
    > * hard nproc 65535
    > EOF

    [root@ansb ~]# tailf -4 /etc/security/limits.d/20-nproc.conf 
    * soft nofile 65535
    * hard nofile 65535
    * hard nproc 65535
    * soft nproc 65535

    注意:
    1.cemtos6 需修改的文件路径为 /etc/security/limits.d/90-nproc.conf
    2.centos7 需修改的文件路径为 /etc/security/limits.d/20-nproc.conf

     

    # 修改后,重新打开一个shell 窗口即可查看即可生效,不需要重启服务器
    [root@ansb ~]# ulimit -a
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 7218
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 65535
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 8192
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) 65535
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    

      

     

  • 相关阅读:
    glibcxx升级
    content security policy directive
    创建AD域用户,并用之在客户端操作远程桌面
    windows安装ad域
    Python切片
    Python字符串格式化
    一段比较有意思的C++代码
    MySql数据库导入新的表里面 php操作,网站文章批量导入到新网站
    [P6672] [清华集训2016] 你的生命已如风中残烛 题解
    软件测试基础之测试分类
  • 原文地址:https://www.cnblogs.com/zhouzhiguo/p/15644083.html
Copyright © 2011-2022 走看看