第一种,配置文件修改。
修改所有 linux 用户的环境变量文件:
vi /etc/profile
ulimit -u 10000
ulimit -n 4096
或进入对应用户的配置文件:
vi ~/.bash_profile
添加同上
第二种,ulimits.conf配置文件修改。
vi /etc/security/limits.conf
进入后上面有详细的英文注解。
1、 /etc/security/limits.conf 中增加这些
e3base soft core 65536
e3base hard core 65536
e3base soft nofile 1048576
e3base hard nofile 1048576
e3base soft stack 262144
e3base hard stack 262144
e3base soft nproc 65536
e3base hard nproc 65536
root soft core 65536
root hard core 65536
root soft nofile 1048576
root hard nofile 1048576
root soft stack 262144
root hard stack 262144
root soft nproc 65536
2、如果limit.conf里面已经存在如下字样* ,并且1步骤更改不生效,将*字样注释掉
* hard stack 262144
* soft nproc 65536
3、如果执行1、2步骤还没有生效那么进入 /etc/security/limits.d/对应的文件
cb项目:/etc/security/limits.d/20-nproc.conf
添加文件内容:
e3base soft core 65536
e3base hard core 65536
e3base soft nofile 1048576
e3base hard nofile 1048576
e3base soft stack 262144
e3base hard stack 262144
e3base soft nproc 65536
e3base hard nproc 65536
root soft core 65536
root hard core 65536
root soft nofile 1048576
root hard nofile 1048576
root soft stack 262144
root hard stack 262144
root soft nproc 65536
4、更新后执行 ulimit -a查看是否生效
以上更改需要重新登录后生效
本文介绍了如何在Linux系统中让ulimit参数永久生效的两种方法:一是通过编辑/etc/profile或~/.bash_profile文件,二是修改/etc/security/limits.conf文件,并在必要时调整/etc/security/limits.d/下的相关文件。详细步骤包括增加配置项、注释原有内容以及检查设置是否生效。

2080

被折叠的 条评论
为什么被折叠?



