Standalone Neo4j Server Setup on Ubuntu 14.04

These are my notes from installing Neo4j 2.1.6 on Ubuntu 14.04.

Server Installation

To install a standalone Neo4j server (the High Availability option is not included in the community version) do the following:

sudo apt-get update && sudo apt-get install python-software-properties

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update && sudo apt-get install oracle-java7-installer

wget -O - http://debian.neo4j.org/neotechnology.gpg.key >> key.pgp
sudo apt-key add key.pgp
echo 'deb http://debian.neo4j.org/repo stable/' | sudo tee -a /etc/apt/sources.list.d/neo4j.list > /dev/null
sudo apt-get update && sudo apt-get install neo4j

You can restart the service like this

sudo service neo4j-service restart

To allow external connections to the server, edit this configuration file

sudo nano /etc/neo4j/neo4j-server.properties 

uncommenting the following line:

org.neo4j.server.webserver.address=0.0.0.0

and restarting the service. You should be able to access the webserver in your browser on port 7474.

When you restart your service you’ll notice this warning:

WARNING: Max 1024 open files allowed, minimum of 40 000 recommended. See the Neo4j manual.

To fix this, edit this file

sudo nano /etc/security/limits.conf

and add these two entries:

root    soft    nofile  40000
root    hard    nofile  40000
neo4j   soft    nofile  40000
neo4j   hard    nofile  40000
panos   soft    nofile  40000
panos   hard    nofile  40000

I add an entry for all three users root, neo4j and panos, but you actually just need the one that you’ll use when you restart the service. Then edit

sudo nano /etc/pam.d/su

uncomment this line

session    required   pam_limits.so 

and restart your server (your machine not the service).

Now if you do

sudo service neo4j-service restart

the warning should have disappeared.

Deleting the entire graph

Your server can hold only a single graph/database. You can delete the data in neo4j and start from scratch by deleting everything in the data directory

sudo rm -rf /var/lib/neo4j/data/*
sudo service neo4j-service restart

Switching databases

You can keep multiple graphs in different folders on your file systems but you can only use one of them at a time per Neo4j server. For example, create a new folder

sudo mkdir -p /data/neo4j/graph1

and change the owner to be user neo4j

sudo chown neo4j /data/neo4j/graph1/

To switch between databases edit this configuration file

sudo nano /etc/neo4j/neo4j.properties

and change this line to point to the new path

org.neo4j.server.database.location=/data/neo4j/graph1/

Now restart the server

sudo service neo4j-service restart

and you will have a fresh database. You can easily check the location of the current database used from within the Neo4j browser, just open the top tab on the left hand-side bar.

Database location from within the Neo4j Browser

 

comments powered by Disqus