概述
软硬极限
极限分为软性和硬性。
The hard limit is the maximum value that is allowed for the soft limit. Any changes to the hard limit require root access.
The soft limit is the value that Linux uses to limit the system resources for running processes. The soft limit cannot be greater than the hard limit.
通过 ulimit 命令,用户可更改软极限
ulimit命令作用对象
由于 ulimit 命令影响当前 shell 环境,所以它将作为 shell 常规内置命令提供。如果在独立的命令执行环境中调用该命令,则不影响调用者环境的文件大小极限。
关于用户和系统资源极限的更多信息,请参见 AIX 5L Version 5.2 Technical Reference: Base Operating System and Extensions Volume 1 中的 getrlimit、setrlimit 或 vlimit子例程。
参数
-a
列出所有当前资源极限。
-c
以 512 字节块为单位,指定核心转储的大小。
-d
以 K 字节为单位指定数据区域的大小。
-f
使用 Limit 参数时设定文件大小极限(以块计),或者在未指定参数时报告文件大小极限。缺省值为 -f 标志。
-H
指定设置某个给定资源的硬极限。如果用户拥有 root 用户权限,可以增大硬极限。任何用户均可减少硬极限。
-m
以 K 字节为单位指定物理存储器的大小。
-n
指定一个进程可以拥有的文件描述符的数量的极限。
-s
以 K 字节为单位指定堆栈的大小。
-S
指定为给定的资源设置软极限。软极限可增大到硬极限的值。如果 -H 和 -S 标志均未指定,极限适用于以上二者。
-t
指定每个进程所使用的秒数。
ulimit -a
命令
To review the hard ulimit settings, enter the following command:
ulimit -aH
user1@host1 ˜$ ulimit -aH core file size (blocks, -c) unlimited data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 100000 max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 100000 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) unlimited cpu time (seconds, -t) unlimited max user processes (-u) 257262 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
To review the soft ulimit, enter the following command:
ulimit -aS
Command output similar to the following example is displayed:
user1@host1 ˜$ ulimit -aS core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 100000 max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 100000 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 10240 cpu time (seconds, -t) unlimited max user processes (-u) 257262 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
字段含义
- fsize 用户创建的文件大小限制。此定义值(512字节为单位)为该用户可以生成的最大文件的大小。
- core 生成的core文件大小的限制(512字节为单位)。
- cpu 用户进程可用cpu的限定值(以秒为单位)。普通用户只能将此值减小,root可以将此值增大。这里要注意的是进程使用CPU的时间取决于AIX Kernel(核心程序)进程调度算法,该值在此仅做参考。
- data 进程数据段大小的限定值(以字节为单位)。
- stack 进程**堆栈段大小的限定值(以字节**为单位)。
- rss 进程常驻内存段的限定值(以字节为单位)。AIX核心并不参考此限定。
- nofiles 进程中打开文件的最大数量。
修改limit
修改文件
change the hard and soft ulimit settings for InfoSphere Streams administrators that belong to the @streamsadmin user group.
On RHEL and CentOS, edit the /etc/security/limits.d/91-nofile.conf file as shown in the following example:
@streamsadmin - nofile open-files-value
@streamsadmin hard nproc max-user-processes-value @streamsadmin soft nproc max-user-processes-value
@streamsadmin hard stack unlimited @streamsadmin soft stack 20480
ulimit临时修改
ulimit -c unlimited #-c:core file size
修改核心转储文件允许的大小为无限制