Centos 7.6 永久生效 最大进程数、打开文件数 Ulimit -a

1.通过命令ulimit -a查看当前系统

[root@db01 ~18:50:18]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@db01 ~18:50:24]# 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) 3805
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) 3805
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

2.通过命令ulimit -n 查看打开文件数量

[root@db01 ~18:55:50]# ulimit -n
1024

3.修改配置文件

#1.cat /etc/security/limits.conf|grep 204800

* soft nofile 204800
* hard nofile 204800
* soft nproc 204800
* hard nproc 204800

在limits.conf最后面加下以上文件

其中:

*             代表针对所有用户 
noproc     是代表最大进程数 
nofile     是代表最大文件打开数

#2.cd /etc/security/limits.d,在20-nproc.conf文件尾部添加以下两行保存退出

[root@db01 /etc/security/limits.d19:04:58]# cat 20-nproc.conf |grep 204800
* soft nproc 204800
* hard nproc 204800

 4.配置生效

1.断开xshell链接,重新链接
查看

[root@db01 ~19:07:40]# ulimit -n
204800
[root@db01 ~19:07:46]# 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) 3805
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 204800
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) 204800
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

 

2.重启虚拟机

reboot

 

posted @ 2022-10-15 19:12  Linux运维-Friend  阅读(189)  评论(0编辑  收藏  举报