Linux Neo4j 警告:最多允许打开 1024 个文件,建议最少 40 000 个。请参阅 Neo4j 手册
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20924596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Neo4j WARNING: Max 1024 open files allowed, minimum of 40 000 recommended. See the Neo4j manual
提问by Dave Kerber
I installed Neo4j on Ubuntu 12.04 using these instructions: http://www.neo4j.org/download/linux
我使用以下说明在 Ubuntu 12.04 上安装了 Neo4j:http: //www.neo4j.org/download/linux
wget -O - http://debian.neo4j.org/neotechnology.gpg.key | apt-key add -
echo 'deb http://debian.neo4j.org/repo stable/' > /etc/apt/sources.list.d/neo4j.list
apt-get update
apt-get install neo4j
I made sure to have the right jdk:
我确保拥有正确的 jdk:
root@precise64:~# java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
And when I startup neo4j I get this error:
当我启动 neo4j 时,出现此错误:
WARNING: Max 1024 open files allowed, minimum of 40 000 recommended. See the Neo4j manual.
警告:最多允许打开 1024 个文件,建议最少 40 000 个。请参阅 Neo4j 手册。
So I follow the instructions here: http://docs.neo4j.org/chunked/1.6.2/configuration-linux-notes.html
所以我按照这里的说明操作:http: //docs.neo4j.org/chunked/1.6.2/configuration-linux-notes.html
And add these contents to /etc/security/limits.conf
并将这些内容添加到 /etc/security/limits.conf
neo4j soft nofile 40000
neo4j hard nofile 40000
And uncomment this line in /etc/pam.d/su
并取消注释这一行 /etc/pam.d/su
session required pam_limits.so
After I restart the server I validate the new limit
重新启动服务器后,我验证了新限制
neo4j@precise64:~$ ulimit -n
40000
Then I restart my server. I still get the same error when starting up.
然后我重新启动我的服务器。启动时我仍然遇到同样的错误。
root@precise64:~# service neo4j-service start
WARNING: Max 1024 open files allowed, minimum of 40 000 recommended. See the Neo4j manual.
Using additional JVM arguments: -server -XX:+DisableExplicitGC -Dorg.neo4j.server.properties=conf/neo4j-server.properties -Djava.util.logging.config.file=conf/logging.properties -Dlog4j.configuration=file:conf/log4j.properties -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
Starting Neo4j Server...WARNING: not changing user
process [3161]... waiting for server to be ready....... OK.
http://localhost:7474/ is ready.
Even though the service is running as the neo4j user:
即使服务以 neo4j 用户身份运行:
root@precise64:~# ps -ef | grep 3161
neo4j 3161 1 2 17:43 pts/0 00:00:10 /usr/bin/java -cp /var/lib/neo4j/lib/concurrentlinkedhashmap-lru-1.3.1.jar:/var/lib/neo4j/lib/geronimo-jta_1.1_spec-1.1.1.jar:/var/lib/neo4j/lib/lucene-core-3.6.2.jar:/var/lib/neo4j/lib/neo4j-cypher-2.0.0.jar:/var/lib/neo4j/lib/neo4j-cypher-commons-2.0.0.jar:/var/lib/neo4j/lib/neo4j-cypher-compiler-1.9-2.0.0.jar:/var/lib/neo4j/lib/neo4j-cypher-compiler-2.0-2.0.0.jar:/var/lib/neo4j/lib/neo4j-graph-algo-2.0.0.jar:/var/lib/neo4j/lib/neo4j-graph-matching-2.0.0.jar:/var/lib/neo4j/lib/neo4j-jmx-2.0.0.jar:/var/lib/neo4j/lib/neo4j-kernel-2.0.0.jar:/var/lib/neo4j/lib/neo4j-lucene-index-2.0.0.jar:/var/lib/neo4j/lib/neo4j-shell-2.0.0.jar:/var/lib/neo4j/lib/neo4j-udc-2.0.0.jar:/var/lib/neo4j/lib/org.apache.servicemix.bundles.jline-0.9.94_1.jar:/var/lib/neo4j/lib/parboiled-core-1.1.6.jar:/var/lib/neo4j/lib/parboiled-scala_2.10-1.1.6.jar:/var/lib/neo4j/lib/scala-library-2.10.3.jar:/var/lib/neo4j/lib/server-api-2.0.0.jar:/var/lib/neo4j/system/lib/asm-3.1.jar:/var/lib/neo4j/system/lib/bcprov-jdk16-140.jar:/var/lib/neo4j/system/lib/commons-beanutils-1.8.0.jar:/var/lib/neo4j/system/lib/commons-beanutils-core-1.8.0.jar:/var/lib/neo4j/system/lib/commons-collections-3.2.1.jar:/var/lib/neo4j/system/lib/commons-compiler-2.6.1.jar:/var/lib/neo4j/system/lib/commons-configuration-1.6.jar:/var/lib/neo4j/system/lib/commons-digester-1.8.1.jar:/var/lib/neo4j/system/lib/commons-io-1.4.jar:/var/lib/neo4j/system/lib/commons-lang-2.4.jar:/var/lib/neo4j/system/lib/commons-logging-1.1.1.jar:/var/lib/neo4j/system/lib/Hymanson-core-asl-1.9.7.jar:/var/lib/neo4j/system/lib/Hymanson-jaxrs-1.9.7.jar:/var/lib/neo4j/system/lib/Hymanson-mapper-asl-1.9.7.jar:/var/lib/neo4j/system/lib/janino-2.6.1.jar:/var/lib/neo4j/system/lib/javax.servlet-3.0.0.v201112011016.jar:/var/lib/neo4j/system/lib/jcl-over-slf4j-1.6.1.jar:/var/lib/neo4j/system/lib/jersey-core-1.9.jar:/var/lib/neo4j/system/lib/jersey-multipart-1.9.jar:/var/lib/neo4j/system/lib/jersey-server-1.9.jar:/var/lib/neo4j/system/lib/jetty-http-9.0.5.v20130815.jar:/var/lib/neo4j/system/lib/jetty-io-9.0.5.v20130815.jar:/var/lib/neo4j/system/lib/jetty-security-9.0.5.v20130815.jar:/var/lib/neo4j/system/lib/jetty-server-9.0.5.v20130815.jar:/var/lib/neo4j/system/lib/jetty-servlet-9.0.5.v20130815.jar:/var/lib/neo4j/system/lib/jetty-util-9.0.5.v20130815.jar:/var/lib/neo4j/system/lib/jetty-webapp-9.0.5.v20130815.jar:/var/lib/neo4j/system/lib/jetty-xml-9.0.5.v20130815.jar:/var/lib/neo4j/system/lib/jsr311-api-1.1.2.r612.jar:/var/lib/neo4j/system/lib/logback-access-1.0.9.jar:/var/lib/neo4j/system/lib/logback-classic-1.0.9.jar:/var/lib/neo4j/system/lib/logback-core-1.0.9.jar:/var/lib/neo4j/system/lib/mimepull-1.6.jar:/var/lib/neo4j/system/lib/neo4j-browser-2.0.0.jar:/var/lib/neo4j/system/lib/neo4j-server-2.0.0-static-web.jar:/var/lib/neo4j/system/lib/neo4j-server-2.0.0.jar:/var/lib/neo4j/system/lib/rhino-1.7R3.jar:/var/lib/neo4j/system/lib/rrd4j-2.0.7.jar:/var/lib/neo4j/system/lib/slf4j-api-1.6.2.jar:/var/lib/neo4j/conf/ -server -XX:+DisableExplicitGC -Dorg.neo4j.server.properties=conf/neo4j-server.properties -Djava.util.logging.config.file=conf/logging.properties -Dlog4j.configuration=file:conf/log4j.properties -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Dneo4j.home=/var/lib/neo4j -Dneo4j.instance=/var/lib/neo4j -Dfile.encoding=UTF-8 org.neo4j.server.Bootstrapper
root 3238 2056 0 17:49 pts/0 00:00:00 grep --color=auto 3161
So I think that maybe starting the service as root is the issue, so I shut it down and start it up as the neo4j user.
所以我认为可能以 root 身份启动服务是问题所在,所以我关闭它并以 neo4j 用户身份启动它。
root@precise64:~# service neo4j-service stop
root@precise64:~# su - neo4j
neo4j@precise64:~$ service neo4j-service start
Using additional JVM arguments: -server -XX:+DisableExplicitGC - Dorg.neo4j.server.properties=conf/neo4j-server.properties -Djava.util.logging.config.file=conf/logging.properties -Dlog4j.configuration=file:conf/log4j.properties -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
Starting Neo4j Server...WARNING: not changing user
process [3435]... waiting for server to be ready....... OK.
http://localhost:7474/ is ready.
cp: cannot create regular file `/var/run/neo4j.pid': Permission denied
And it fails because the pid file cannot be created. Which I assume means this is not the correct approach, but I go ahead and edit /etc/init.d/neo4j-service
to change the location of the pid file to the home folder of the neo4j user:
它失败了,因为无法创建 pid 文件。我认为这意味着这不是正确的方法,但我继续编辑/etc/init.d/neo4j-service
以将 pid 文件的位置更改为 neo4j 用户的主文件夹:
#PIDFILE=/var/run/$NAME.pid
PIDFILE=/var/lib/neo4j/$Name.pid
And then things startup without error when I run the service as the Neo4j user.
然后,当我以 Neo4j 用户身份运行该服务时,一切正常启动。
So, my question is: What is the intended behavior? Should starting the service as root work as long as the neo4j user has the correct ulimit permissions, or do I need to modify the startup script/permissions to allow the neo4j user to create it's PID file?
所以,我的问题是:预期的行为是什么?只要neo4j用户具有正确的ulimit权限,是否应该以root身份启动服务,或者我是否需要修改启动脚本/权限以允许neo4j用户创建它的PID文件?
回答by Israel
You need to add the following entries into the /etc/security/limits.conf file
您需要将以下条目添加到 /etc/security/limits.conf 文件中
root soft nofile 40000
root hard nofile 40000
You need to start the service as root or using sudo
您需要以 root 身份或使用 sudo 启动服务
When you do that, the user that ends up starting the service is the root user.
当您这样做时,最终启动服务的用户是 root 用户。
If you dont have an entry in the file for the root user, then it would not work.
如果您在文件中没有 root 用户的条目,那么它将不起作用。
So, you just need to add those entries in the file and then reboot your server.
因此,您只需要在文件中添加这些条目,然后重新启动服务器。
I had the same problem and that is how I was able to resolve it.
我遇到了同样的问题,这就是我能够解决它的方式。
回答by Tomasz Swider
In the /etc/security/limits.conf file you need to set the limits for the user as whom you will run the neo4j server so if the user you want to use is root, then use root but it is probably bad idea, the settings:
在 /etc/security/limits.conf 文件中,您需要为将运行 neo4j 服务器的用户设置限制,因此如果您要使用的用户是 root,则使用 root,但这可能是个坏主意,设置:
neo4j soft nofile 40000
neo4j hard nofile 40000
would work if you where to add neo4j user, I had some problems with that so i just set these to my default user which is 'bob'.
如果你在哪里添加neo4j用户会起作用,我遇到了一些问题,所以我只是将这些设置为我的默认用户“bob”。
bob soft nofile 40000
bob hard nofile 40000
and then I just started the neo4j logged in as bob.
然后我刚刚启动了以 bob 身份登录的 neo4j。
回答by Cleb
The solutions posted by @israel and by @Tomasz Swider did not work for me (I am running Ubuntu 14.04). However, I could get rid of this warning by modifying the file /etc/init.d/neo4j-service
as suggested by @zwol in the comments below the question:
@israel 和@Tomasz Swider 发布的解决方案对我不起作用(我正在运行 Ubuntu 14.04)。但是,我可以/etc/init.d/neo4j-service
按照@zwol 在问题下方评论中的建议修改文件来消除此警告:
I added the line ulimit -n 40000
to the do_start()
method in this file. In my case this method then looks as follows:
我将这一行添加到此文件中ulimit -n 40000
的do_start()
方法中。在我的情况下,此方法如下所示:
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
ulimit -n 40000
start-stop-daemon --chuid ${NEO_USER} --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --chuid ${NEO_USER} --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
}
When I then start the service by using the command
当我然后使用命令启动服务时
sudo service neo4j-service start
it starts without the warning and returns the following message:
它开始时没有警告并返回以下消息:
Starting Neo4j Server...WARNING: not changing user
process [9921]... waiting for server to be ready...... OK.
http://localhost:7474/ is ready.
I am not sure whether that is the way to go but as written above, that was the only solution that has worked for me so far to get rid of this warning.
我不确定这是否是要走的路,但如上所述,这是迄今为止唯一对我有用的解决方案,可以消除此警告。
EDIT:
编辑:
Have not tested it, but seems there is now an easier solution available: see @Schrodinger's'Cat's answer.
尚未对其进行测试,但似乎现在有一个更简单的解决方案可用:请参阅 @Schrodinger's'Cat's answer。
回答by Tobias Gassmann
I applied the changes as suggested in previous answers
我按照以前的答案中的建议应用了更改
root soft nofile 40000
root hard nofile 40000
neo4j soft nofile 40000
neo4j hard nofile 40000
to
到
/etc/security/limits.conf
/etc/security/limits.conf
Nevertheless I still got the warning about only 1024 open files being allowed. The command
尽管如此,我仍然收到关于只允许打开 1024 个文件的警告。命令
ulimit -a
did show only 1024 open files allowed.
确实显示只允许 1024 个打开的文件。
The trick was to log out of the server, then log back in.In the new session the values of the new limits-configuration were applied and I could
诀窍是注销服务器,然后重新登录。在新会话中,应用了新限制配置的值,我可以
service neo4j-server restart
with 40.000 open files allowed.
允许打开 40.000 个文件。
回答by Schrodinger's'Cat
As mentioned in this issue commentand fixed by this commit, since Neo4J 3.1,
正如此问题评论中所述并由此提交修复,自 Neo4J 3.1 以来,
you can add a line in
/etc/default/neo4j
:NEO4J_ULIMIT_NOFILE=60000
to set the ulimit setting (60000 open files) for the service.
你可以添加一行
/etc/default/neo4j
:NEO4J_ULIMIT_NOFILE=60000
为服务设置 ulimit 设置(60000 个打开文件)。
There is no need anymore to use /etc/security/limits.conf
on debian to set the number of open files.
不再需要/etc/security/limits.conf
在 debian上使用来设置打开文件的数量。
回答by Victoria Stuart
This worked for me on Arch Linux (x86_64), where prior to these modifications ulimit -n
was 1024
):
这在 Arch Linux (x86_64) 上对我有用,在这些修改之前ulimit -n
是1024
):
Edit
/etc/pam.d/su
, add:session required pam_limits.so
Edit both
/etc/systemd/system.conf
/etc/systemd/user.conf
add to each (whatever value you desire: I chose 100,000):
DefaultLimitNOFILE=100000
Reboot.
$ ulimit -n 100000
编辑
/etc/pam.d/su
,添加:会话需要 pam_limits.so
编辑两者
/etc/systemd/system.conf
/etc/systemd/user.conf
添加到每个(无论您想要什么值:我选择了 100,000):
DefaultLimitNOFILE=100000
重启。
$ ulimit -n 100000
Based on
基于
回答by Vineeth
You can set the hard limits in /etc/security/limits.conf and restart the server to make it into effect.
您可以在 /etc/security/limits.conf 中设置硬限制并重新启动服务器使其生效。
But with current session, you can run
但是使用当前会话,您可以运行
ulimit -n 40000
ulimit -n 40000
回答by LetsNoSQL
Just check once the current value from below command ulimit -n and ulimit -a
只需从下面的命令ulimit -n 和 ulimit -a检查当前值
And you can edit the value on path below /etc/security/limit.conf
您可以编辑/etc/security/limit.conf下面路径上的值