Skip to content

Instantly share code, notes, and snippets.

@jalakoo
Last active September 2, 2023 07:20
Show Gist options
  • Save jalakoo/7b854f9c60c237f2d6f8c9fd5ca1356f to your computer and use it in GitHub Desktop.
Save jalakoo/7b854f9c60c237f2d6f8c9fd5ca1356f to your computer and use it in GitHub Desktop.
neo4j-5-install.md

Neo4j + Raspberry Pi Install Instructions

These steps tested using Raspberry Pi Imager 1.7.4 loading Debian Bullseye with Raspberry Pi Desktop (2023-02-21) onto a 2019 Rasbperry Pi 4 model B. All command examples are for running from a CLI/terminal.

Java

Java is required to run a Neo4j instance on a pi. JDK version 17+ is recommended when using Neo4j v5.5.0+

To check your current version (if any):

java -version

Install Java

Run the following commands from your pi to install Java:

sudo apt update
sudo apt install default-jdk
sudo apt install openjdk-17-jdk

Check that java is installed:

java -version

Install Neo4j

Install anywhere on the home

To download the Community Edition:

wget -O neo4j-community-5.5.0-unix.tar.gz 'https://neo4j.com/artifact.php?name=neo4j-community-5.5.0-unix.tar.gz'
tar -xf neo4j-community-5.5.0-unix.tar.gz
cd neo4j-community-5.5.0

Or the Enterprise Edition:

wget -O neo4j-enterprise-5.5.0-unix.tar.gz 'https://neo4j.com/artifact.php?name=neo4j-enterprise-5.5.0-unix.tar.gz'
tar -xf neo4j-enterprise-5.5.0-unix.tar.gz
cd neo4j-enterprise-5.5.0

License Agreement

If you are using the Enterprise addition, accepting the licensing terms is required. To read and approve, run either of these commands:

neo4j-admin server license --accept-commercial
neo4j-admin server license --accept-evaluation

See the licensing page for more details on the different Enterprise licenses.

Running

To start a Neo4j server on the pi:

export NEO4J_HOME=~/neo4j-enterprise-5.5.0
export PATH=$NEO4J_HOME/bin:$PATH
neo4j start

A database instance will now be accessible locally on the pi.

Stopping

neo4j stop

Configure

To remotely access the database, modify the database's neo4j.conf file. Be sure the database has been stopped prior to modifying. Example of doing this using nano:

sudo nano /conf/neo4j.conf

Uncomment the line: server.default_listen_address=0.0.0.0 then restart the database.

Connecting

The database is now remotely accessible, default port 7474. To access remotely from another computer on the same network use the pattern: <pi_username>@<pi_hostname>.local:7474 Adding the port number may not always be necessary. Example address for a default new pi build: pi@raspberrypi.local

Password

The default username is neo4j and password is neo4j. A new password is required after first accessing a new database. This is most easily done through a browser.

Neo4j Browser

To access, open up Chromium on the pi and go to the following address:

http://localhost:7474

If accessing remotely, open any browser and use the pattern from above, example:

http://pi@raspberrpi.local:7474

Neo4j Desktop

if you have the Neo4j Desktop already installed do the following steps:

  1. Add a new Remote connection
  2. Assign any name, like Raspi
  3. Make sure the Connect URL uses the pattern above, like: neo4j://pi@raspberrypi.local

Client Drivers

A client driver can also be used to connect and interact with the database

Autostart

To have the database automatically start with each restart of the pi, configure systemctl.

  1. Copy Neo4j into the /opt/ folder.
sudo cp -r neo4j-enterprise-5.5.0 /opt/
  1. Update Permissions Create a symlink, create a user, and update folder ownership
sudo ln -s /opt/neo4j-enterprise-5.5.0 /opt/neo4j
sudo groupadd neo4j
sudo useradd -g neo4j neo4j -s /bin/bash
sudo chown -R neo4j /opt/neo4j-enterprise-5.5.0

  1. Create a new file in the systemctl folder. Example using nano:
sudo nano /lib/systemd/system/neo4j.service

Add the following to that file:

[Unit]
Description=Neo4j Graph Database
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/opt/neo4j/bin/neo4j console
Restart=on-abnormal
User=neo4j
Group=neo4j
Environment="NEO4J_CONF=/opt/neo4j/conf" "NEO4J_HOME=/opt/neo4j"
LimitNOFILE=60000
TimeoutSec=120

[Install]
WantedBy=multi-user.target
  1. Configure systemctl: Reload for systemctl to pickup new service:
systemctl daemon-reload
  1. Enable for restart:
systemctl enable neo4j
  1. Wrap up Restart the pi:
sudo reboot now

Check the status:

systemctl status neo4j

Which should print out something like the following:

Mar 07 14:47:42 raspi neo4j[959]: 2023-03-07 22:47:42.696+0000 INFO  ======== Neo4j 5.5.0 ========
Mar 07 14:47:42 raspi neo4j[959]: 2023-03-07 22:47:42.809+0000 INFO  This instance is ServerId{3ae0c69a} (3ab0c69a-d64d-4c89-aa09-db48ce1709ff)
Mar 07 14:48:07 raspi neo4j[959]: 2023-03-07 22:48:07.216+0000 INFO  Sending metrics to CSV file at /opt/neo4j/metrics
Mar 07 14:48:07 raspi neo4j[959]: 2023-03-07 22:48:07.412+0000 INFO  Bolt enabled on 0.0.0.0:7687.
Mar 07 14:48:07 raspi neo4j[959]: 2023-03-07 22:48:07.449+0000 INFO  Bolt (Routing) enabled on 0.0.0.0:7688.
Mar 07 14:48:11 raspi neo4j[959]: 2023-03-07 22:48:11.535+0000 INFO  Remote interface available at http://localhost:7474/
Mar 07 14:48:11 raspi neo4j[959]: 2023-03-07 22:48:11.549+0000 INFO  id: 27073DD2DC1399FACF4F04E0F140F41978C5BD69E7FAE1F857944E9C6E295A97
Mar 07 14:48:11 raspi neo4j[959]: 2023-03-07 22:48:11.551+0000 INFO  name: system
Mar 07 14:48:11 raspi neo4j[959]: 2023-03-07 22:48:11.553+0000 INFO  creationDate: 2023-03-07T01:28:31.845Z
Mar 07 14:48:11 raspi neo4j[959]: 2023-03-07 22:48:11.554+0000 INFO  Started.

CTRL+C to close this status output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment