linux常用初始化脚本

调整打开文件数限制

不做调整,默认只能打开1024,输入 ulimit -a 查看 【open files】 会看到配置值 1024;

步骤1:临时整体修改生效:

sudo sysctl -w fs.file-max=2097152
sudo sysctl -w fs.nr_open=1048576

步骤2:持久化修改生效: vim /etc/sysctl.conf

增加如下内容:

fs.file-max = 2097152
fs.nr_open = 1048576

然后执行:sudo sysctl -p

步骤3:让systemd管理部分生效,vim /etc/security/limits.d/99-custom-nofile.conf

新增如下内容:

*          soft    nofile          65535
*          hard    nofile          65535

root       soft    nofile          65535
root       hard    nofile          65535