elasticsearch 报错too many open files

本文详细介绍了如何在Ubuntu系统中永久调整ulimit参数,特别是关于打开文件的最大数量。通过编辑/etc/security/limits.conf和/etc/pam.d/common-session文件,可以为特定用户或超级用户设置nofile参数,以增加可同时打开的文件数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://posidev.com/blog/2009/06/04/set-ulimit-parameters-on-ubuntu/

Set ulimit parameters on ubuntu

13 Replies

By default the number of open files  pro user in Ubuntu 8.04   is 1024. In my case this number was  too small so I have to increase it.This is done with the  ulimit command:

$ulimit -a   # see all the kernel parameters
$ulimit -n   #see the number of open files
$ulimit -n 9000  #  set the number open files to 9000

The problem with this way is that the ulimit parameter is only set currently  for this command terminal and user.If you open a new tab and type again ulimit -a you will see that the number of open files is 1024.This means that after a reboot you’ll need to set the parameter again.

First, in order to set this options automatically  you have to edit the etc/security/limits.conffile.

$sudo gedit /etc/security/limits.conf    #open the file in gedit

The # means that this part is commented.The wildcard * means  for all users.We need to set the nofile option meaning maximum number of open files.If you want to change the number of files of user, you should add this line in the limits.conf:

user  soft  nofile 9000

user  hard  nofile 65000

If  you want to set the nofile only for superuser you just write root instead of user.

root soft  nofile 9000

root hard  nofile 65000

Second you have to add a line in the /etc/pam.d/common-session file:

$ sudo gedit /etc/pam.d/common-session #open the file in gedit

Then add the line:

session required pam_limits.so

Now after rebooting you can see in the terminal with ulimit -a the change.

The option with wildcard *didn’t work for me , because I used root accout to run my programms and wildcard option doesn’t affect the superuser.

Remark: Using the same steps you should be able to set and change other parameters ( core file size, max user processes, stack size ….) from the ulimit options.

References:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值