问题描述
我按照以下说明在Ubuntu 12.04上安装了Neo4j: http://www.neo4j.org/download/linux
I installed Neo4j on Ubuntu 12.04 using these instructions: 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
我确保拥有正确的jdk:
I made sure to have the right 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)
当我启动neo4j时,出现此错误:
And when I startup neo4j I get this error:
因此,我按照此处的说明进行操作: http://docs.neo4j.org/chunked/1.6.2/configuration-linux-notes.html
So I follow the instructions here: http://docs.neo4j.org/chunked/1.6.2/configuration-linux-notes.html
并将这些内容添加到/etc/security/limits.conf
neo4j soft nofile 40000
neo4j hard nofile 40000
然后取消注释/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.
即使该服务以neo4j用户身份运行:
Even though the service is running as the neo4j user:
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/jackson-core-asl-1.9.7.jar:/var/lib/neo4j/system/lib/jackson-jaxrs-1.9.7.jar:/var/lib/neo4j/system/lib/jackson-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
所以我认为也许是作为root用户启动服务的问题,所以我将其关闭并以neo4j用户身份启动它.
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@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
它失败,因为无法创建pid文件.我认为这不是正确的方法,但是我继续编辑/etc/init.d/neo4j-service
将pid文件的位置更改为neo4j用户的主文件夹:
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:
#PIDFILE=/var/run/$NAME.pid
PIDFILE=/var/lib/neo4j/$Name.pid
然后,当我以Neo4j用户身份运行该服务时,一切启动都没有错误.
And then things startup without error when I run the service as the Neo4j user.
所以,我的问题是:预期的行为是什么?只要neo4j用户具有正确的ulimit权限,是否应该以root身份启动服务,还是我需要修改启动脚本/权限以允许neo4j用户创建其PID文件?
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?
推荐答案
您需要将以下条目添加到/etc/security/limits.conf文件中
You need to add the following entries into the /etc/security/limits.conf file
root soft nofile 40000
root hard nofile 40000
您需要以root用户或使用sudo来启动服务
You need to start the service as root or using sudo
执行此操作时,最终启动该服务的用户是root用户.
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.
因此,您只需要在文件中添加这些条目,然后重新启动服务器即可.
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.
这篇关于Neo4j警告:允许最多打开1024个文件,建议最少40000个.参见Neo4j手册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!