How to increase Neo4j's maximum file open limi

2019-01-08 05:21发布

Currently ulimit -n shows 10000. I want to increase it to 40000. I've edited "/etc/sysctl.conf" and put fs.file-max=40000. I've also edited /etc/security/limits.conf and updated hard and soft values. But still ulimit shows 10000. After making all these changes I rebooted my laptop. I've access to root password.

usr_name@usr_name-lap:/etc$ /sbin/sysctl fs.file-max
fs.file-max = 500000

Added following lines in /etc/security/limits.conf -

*     soft    nofile          40000
*     hard    nofile          40000

I also added following line in /etc/pam.d/su-

session    required   pam_limits.so

I've tried every possible way as given on other forums, but I can reach up to a maximum limit of 10000, not beyond that. What can be the issue?

I'm making this change because neo4j throws maximum open file limits reached error.

10条回答
The star\"
2楼-- · 2019-01-08 05:42

1) Check sysctl file-max limit:

$ cat /proc/sys/fs/file-max

If the limit is lower than your desired value, open the sysctl.conf and add this line at the end of file:

fs.file-max = 65536

Finally, apply sysctl limits:

$ sysctl -p 

2) Edit /etc/security/limits.conf and add below the mentioned

* soft     nproc          65535    
* hard     nproc          65535   
* soft     nofile         65535   
* hard     nofile         65535

These limits won't apply for root user, if you want to change root limits you have to do that explicitly:

root soft     nofile         65535   
root hard     nofile         65535
...

3) Reboot system or add following line to the end of /etc/pam.d/common-session:

session required pam_limits.so

Logout and login again.

4) Check soft limits:

$ ulimit -a

and hard limits:

$ ulimit -Ha
....

open files                      (-n) 65535

Reference : http://ithubinfo.blogspot.in/2013/07/how-to-increase-ulimit-open-file-and.html

查看更多
在下西门庆
3楼-- · 2019-01-08 05:42

You could alter the init script for neo4j to do a ulimit -n 40000 before running neo4j.

However, I can't help but feel you are barking up the wrong tree. Does neo4j legitimately need more than 10,000 open file descriptors? This sounds very much like a bug in neo4j or the way you are using it. I would try to address that.

查看更多
SAY GOODBYE
4楼-- · 2019-01-08 05:44

I am using Debian but this solution should work fine with Ubuntu.
You have to add a line in the neo4j-service script.
Here is what I have done :

nano /etc/init.d/neo4j-service
Add « ulimit –n 40000 » just before the start-stop-daemon line in the do_start section

Note that I am using version 2.0 Enterprise edition. Hope this will help you.

查看更多
该账号已被封号
5楼-- · 2019-01-08 05:47

What you are doing will not work for root user. Maybe you are running your services as root and hence you don't get to see the change.

To increase the ulimit for root user you should replace the * by root. * does not apply for root user. Rest is the same as you did. I will re-quote it here.

Add the following lines to the file: /etc/security/limits.conf

root soft  nofile 40000

root hard  nofile 40000

And then add following line in the file: /etc/pam.d/common-session

session required pam_limits.so

This will update the ulimit for root user. As mentioned in comments, you may don't even have to reboot to see the change.

查看更多
登录 后发表回答