Neo4j is graph database written in Java. As such it can be run on our private JVM products under regular user on shared cPanel-based server.
In this tutorial we will set it up on our basic product Tomcat which has enough resources for demonstrating setup but for production you will need to upgrade at least JVM heap. See Neo4j system requirements for production.
Default configuration is made for runnng Neo4j as root on a VPS or dedicated server. A few changes are required to run it as regular user. Instead of systemctl-based system service Neo4j can be started from /etc/rc.local using autostart (on server boot) feature provided by host to user’s JVM. Simply make sure you have local alias command
js that starts Neo4j (
neo4j start) and it will be run while server boots.
As Neo4j will start embedded server, it does not need the default application server. You may do one of the following:
- order a new account for it (if you still need your application server)
- run it instead of your application server.
Installing and configuring Neo4j as regular user
Download, unzip, create easy access link, update environment variables and config file.
wget --content-disposition 'https://neo4j.com/artifact.php?name=neo4j-community-3.2.3-unix.tar.gz' tar xzf neo4j-community-3.2.3-unix.tar.gz ln -s neo4j-community-3.2.3 neo4j cat>>~/.bashrc<<EOF export NEO4J_HOME=/home/neo4j/neo4j export JAVA_HOME=/opt/jdk1.8.0_73 export PATH=\$PATH:\$NEO4J_HOME/bin:\$JAVA_HOME/bin EOF source ~/.bashrc
Now you need to update configuration settings specific to shared server in
- Adjust JVM heap to match you package heap limit.
sed -ri 's/^#?dbms.memory.heap.initial_size=.*/dbms.memory.heap.initial_size=128m/' $NEO4J_HOME/conf/neo4j.conf sed -ri 's/^#?dbms.memory.heap.max_size=.*/dbms.memory.heap.max_size=128m/' $NEO4J_HOME/conf/neo4j.conf
- You need to stay within account limits on shared server. Setting
dbms.memory.pagecache.sizeto heap size will do.
sed -ri 's/^#?dbms.memory.pagecache.size=.*/dbms.memory.pagecache.size=128m/' $NEO4J_HOME/conf/neo4j.conf
- If you need to connect from remote locations, we need to make Neo4j listen on all IPs and accept non-local connections. With default configuration Neo4j only accepts local connections.
sed -ri 's/^#?#dbms.connectors.default_listen_address=.*/dbms.connectors.default_listen_address=0.0.0.0/' $NEO4J_HOME/conf/neo4j.conf
- Get 2 (or 3 if you want to enable https connector) ports from support or reuse the ports of your tomcat that will be shut down to make room for Neo4j. Lets assume the ports are: 11088 for bolt, 11089 for HTTP and 11090 for HTTPS.
sed -ri 's/^#?dbms.connector.bolt.listen_address=.*/dbms.connector.bolt.listen_address=:11088/' $NEO4J_HOME/conf/neo4j.conf sed -ri 's/^#?dbms.connector.http.listen_address=.*/dbms.connector.http.listen_address=:11089/' $NEO4J_HOME/conf/neo4j.conf sed -ri 's/^#?dbms.connector.https.listen_address=.*/dbms.connector.https.listen_address=:11090/' $NEO4J_HOME/conf/neo4j.conf
In production setup you will probably also need to configure a commercial (or not self-signed) SSL certificate.
The binary is now in your
PATH so you can call it just by typing
neo4j with one of the following parameters: console, start, stop, restart, status, version.
[email protected] [~]# neo4j start Active database: graph.db Directories in use: home: /home/neo4j/neo4j config: /home/neo4j/neo4j/conf logs: /home/neo4j/neo4j/logs plugins: /home/neo4j/neo4j/plugins import: /home/neo4j/neo4j/import data: /home/neo4j/neo4j/data certificates: /home/neo4j/neo4j/certificates run: /home/neo4j/neo4j/run Starting Neo4j. WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual. Started neo4j (pid 13736). It is available at http://0.0.0.0:11089/ There may be a short delay until the server is ready. See /home/neo4j/neo4j/logs/neo4j.log for current status.
Use default credentials. User and password are ‘neo4j’.
You will then be asked to set a new password.
Then you can create first graph as prompted with the ‘Hello World’ example.
Example graph representation follows.
Idle system with 2 example nodes uses 26MB of JVM heap.
Feel free to post your comments and contact us if you have any questions related to hosting Neo4j or any other Java app.