neo4j / neo4j

Graphs for Everyone
http://neo4j.com
GNU General Public License v3.0
13.22k stars 2.38k forks source link

[3.0] Neo4j process is not creating pid file #7086

Closed eranhazout closed 8 years ago

eranhazout commented 8 years ago

I have noticed that a fresh install of neo4j enterprise is not creating pid file on /var/run/neo4j directory. Also if I'm creating this directory manually it's been deleted by neo4j stop procedure. The result is an instance of neo4j which is not controllable by neo4j bin file. This occurs after first reboot of the server and in order to stop neo4j I forced to kill -9 the process.

Neo4j Version: 3.0M03
Operating System: Ubuntu 14.04

Steps to reproduce

  1. apt-get install neo4j-enterprise
  2. reboot the server
  3. check running process - you will notice that neo4j is running by neo4j user
  4. try to stop neo4j by #service neo4j stop / start
  5. You will receive: /usr/share/neo4j/bin/neo4j: line 149: /var/run/neo4j/neo4j.pid: No such file or directory

    Expected behavior

neo4j start procedure should create neo4j.pid file on upstart neo4j stop procedure should delete neo4j.pid

Actual behavior

neo4j start procedure is not creating neo4j.pid file on upstart

eranhazout commented 8 years ago

The only solution I have found for now is to modify the /etc/init.d/neo4j file to use root as user for daemon: [ -n "${NEO_USER}" ] || NEO_USER=root

spacecowboy commented 8 years ago

Would you mind trying to reproduce this issue on 3.0.0?

Also, could the permissions in /var/run/neo4j be such that the user neo4j is not authorized to create files in that location?

eranhazout commented 8 years ago

I will try with 3.0.0 later today and update you. Yes, the /var/run directory is on user root. but neo4j is trying to create a directory under /var/run as this: /var/run/neo4j/neo4j.pid So I created the /var/run/neo4j manually but the stop script is deleting this directory. is it ok to run neo4j as root user? and disadvantages or security risks?

Thanks

eranhazout commented 8 years ago

Where can I find 3.0.0?

spacecowboy commented 8 years ago

@eranhazout http://debian.neo4j.org/

spacecowboy commented 8 years ago

To avoid running as root (which is not recommended), you can add this to the start of the do_start() method in /etc/init.d/neo4j:

  # Make sure that /var/run/neo4j exists
  [ -d "/var/run/${NAME}" ] || mkdir -p "/var/run/${NAME}"

  # And that it has correct permissions
  if [ "${NEO_USER}" != "root" ]; then
    chown "${NEO_USER}" "/var/run/${NAME}"
  fi

That way, the directory is created if missing on each startup, which should solve your issue. We'll update the script to do this as well.

eranhazout commented 8 years ago

Yes, it fix the problem. Thanks

benbc commented 8 years ago

This will be fixed in 3.0.2. In the meantime, an alternative workaround is to manually create and chown /var/run/neo4j after a reboot.

Baptiste-Garcin commented 7 years ago

Hi,

I am using neo4j 3.2.1 and I have exactly the same issue...

jmvbxx commented 7 years ago

Same as @Baptiste-Garcin with the identical issue. Installed 3.2.1 on a virgin 16.04 server

root@ip-172-xx-xx-113:/home/ubuntu# uname -a
Linux ip-172-xx-xx-113 4.4.0-1020-aws #29-Ubuntu SMP Wed Jun 14 15:54:52 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
root@ip-172-xx-xx-113:/home/ubuntu# /usr/bin/neo4j start
Active database: graph.db
Directories in use:
  home:         /var/lib/neo4j
  config:       /etc/neo4j
  logs:         /var/log/neo4j
  plugins:      /var/lib/neo4j/plugins
  import:       /var/lib/neo4j/import
  data:         /var/lib/neo4j/data
  certificates: /var/lib/neo4j/certificates
  run:          /var/run/neo4j
Starting Neo4j.
WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
/usr/share/neo4j/bin/neo4j: line 411: /var/run/neo4j/neo4j.pid: No such file or directory

Suggestions?

Baptiste-Garcin commented 7 years ago

Hi,

I struggled during hours with permission and manual install. At the end, a simple apt-get install neo4j / sudo service neo4j start worked well

I am pretty sure using apt did'nt work the first time. Hope it somehow helps...

jexp commented 7 years ago

I think this is related to the use of neo4j start instead of service neo4j start or systemctl start neo4j ?

@spacecowboy would it be possible to have neo4j start output an error message that points to the correct way of starting the server on linux? And perhaps highlight this more in the documentation?

spacecowboy commented 7 years ago

@Baptiste-Garcin @jmvbxx @jexp

If you have installed neo4j via the debian package (or RPM), stop running neo4j start.

The correct way to starting/stopping neo4j in a package install is by using service neo4j start or systemctl start neo4j.

When neo4j is running using systemd (neo4j 3.1.0 and above) no pid file is created and no /var/run/neo4j directory is created because systemd handles all of the backgrounding busy work for us and it does it way better.

This is also why you'll have to use journalctl -u neo4j to look at the log and there is no /var/log/neo4j/neo4j.log file anymore.

jexp commented 7 years ago

@spacecowboy pointed to this in the docs:

https://neo4j.com/docs/operations-manual/3.2/installation/linux/systemd/

jmouka commented 7 years ago

I was having an issues trying to launch neo4j using service neo4j start (neo4j 3.2.1, Ubuntu 16.04, installed using apt-get). Checking journalctl -u neo4jit reported "/var/log/neo4j/debug.log (Permission denied)". Changing the folder's group to neo4j and making it group writable seems to have solved it.

graham-macleod commented 7 years ago

The way I resolved this was to manually create the /var/run/neo4j directory and chgrp to neo4j.

Baschdl commented 6 years ago

@spacecowboy Couldn't you build in @jmouka's solution in the setup process?

chirag912 commented 6 years ago

@spacecowboy Im, having a very similar issue. This is my etc/neo4j/neo4j.conf data

*****

Neo4j configuration

#

For more details and a complete list of settings, please see

https://neo4j.com/docs/operations-manual/current/reference/configuration-settings/

*****

The name of the database to mount

dbms.active_database=graph.db

Paths of directories in the installation.

dbms.directories.data=/var/lib/neo4j/data dbms.directories.plugins=/var/lib/neo4j/plugins dbms.directories.certificates=/var/lib/neo4j/certificates dbms.directories.logs=/var/log/neo4j dbms.directories.lib=/usr/share/neo4j/lib dbms.directories.run=/var/run/neo4j dbms.directories.metrics=/var/lib/neo4j/metrics

This setting constrains all LOAD CSV import files to be under the import directory. Remove or comment it out to

allow files to be loaded from anywhere in the filesystem; this introduces possible security problems. See the

LOAD CSV section of the manual for details.

dbms.directories.import=/var/lib/neo4j/import

Whether requests to Neo4j are authenticated.

To disable authentication, uncomment this line

dbms.security.auth_enabled=false

Enable this to be able to upgrade a store from an older version.

dbms.allow_upgrade=true

Java Heap Size: by default the Java heap size is dynamically

calculated based on available system resources.

Uncomment these lines to set specific initial and maximum

heap size.

dbms.memory.heap.initial_size=512m

dbms.memory.heap.max_size=512m

screen shot 2018-03-29 at 3 06 50 am

This is the error that i get as soon as i click on connect.

Ok, the Neo4j is installed on a open stack server. And im creating a ssh channel like this

ssh -L :7474:127.0.0.1:7474 ubuntu@208.75.00.001 -v -v

from my mac os terminal.

the firewall on the remote server is off as well.

I have tried many things. Please any help here would be really appreciated.

cooperka commented 6 years ago

I'm running neo4j in a Docker container and none of the above workarounds helped me (there is no neo4j user on my system).

Running sudo chmod -R 777 ~/neo4j did the trick for now, though I still can't figure out why it needs these high permissions. Neither 770 or 766 are good enough for logging, apparently.

immerlernen commented 6 years ago

I've read through this (and other) posts many times and got things to work once, but had to uninstall so am now starting from scratch. I'm running Ubuntu 17.10 and have followed all installation steps painstakingly. Undoubtedly my naivete with the ubuntu interface is part of the issue, but after 3-4 hours I'm pretty much begging for help on this.

  1. There is no neo4j.pid file. Last time I remember having to install this manually (can someone point me to instructions to do this in a locked folder?)
  2. The system happily reports that neo4j is running... yet localhost:7474 says nada (this happens with service start neo4j, sudo chmod -R 777 ~/neo4j, sudo neo4j start... et al)

Thank you!

Until figuring out the long term solution I did a manual install from the tarball. Not elegant, so I really look forward to learning the best way to do this - and maybe having a stable, consistent and well documented way to install this software in the future.

ardan7779 commented 6 years ago

I have use the @spacecowboy tricks, but still have an error while starting neo4j on ubuntu (remote server)

systemctl restart neo4j ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to restart 'neo4j.service'. Multiple identities can be used for authentication:

  1. Ubuntu (ubuntu)
  2. neo4j Choose identity to authenticate as (1-2): 2 Password: ==== AUTHENTICATION COMPLETE ===

But, while i check status of neo4j, it have not active yet.

ardan7779@serverx:/$ neo4j status Neo4j is not running

VictorAlonsoCM commented 5 years ago

Optional solution: Go and edit the next file:

cd /usr/share/neo4j/conf
vim neo4j.conf

uncomment the line 9 dbms.active_database=graph.db This should works, if you have problems with the database connection.

purplebyteone commented 4 years ago

tarting Neo4j. WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual. ./bin/neo4j: line 451: /usr/share/neo4j/run/neo4j.pid: No such file or directory ./bin/neo4j: line 450: /usr/share/neo4j/logs/neo4j.log: No such file or directory

purplebyteone commented 4 years ago

udo service neo4j start Failed to start neo4j.service: Unit neo4j.service not found.

purplebyteone commented 4 years ago

Created manually folders. sudo neo4j start Active database: graph.db Directories in use: home: /usr/share/neo4j config: /usr/share/neo4j/conf logs: /usr/share/neo4j/logs plugins: /usr/share/neo4j/plugins import: /usr/share/neo4j/import data: /usr/share/neo4j/data certificates: /usr/share/neo4j/certificates run: /usr/share/neo4j/run Starting Neo4j. WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual. Started neo4j (pid 4394). It is available at http://localhost:7474/ There may be a short delay until the server is ready. See /usr/share/neo4j/logs/neo4j.log for current status. kali@kali:~/Desktop/htb/StartingPoint/Pathfinde$ cat /usr/share/neo4j/logs/neo4j.log nohup: ignoring input 2020-07-19 16:40:19.282+0000 INFO ======== Neo4j 3.5.3 ======== 2020-07-19 16:40:19.313+0000 INFO Starting... 2020-07-19 16:40:29.697+0000 INFO Bolt enabled on 127.0.0.1:7687. kali@kali:~/Desktop/htb/StartingPoint/Pathfinde$

purplebyteone commented 4 years ago

systemctl start neo4j Failed to start neo4j.service: Unit neo4j.service not found.