Skip to content

Neo4j Setup Guide

Zhaosong Zhu edited this page Mar 24, 2021 · 10 revisions

Follow this guide to set up your Neo4j environment for this class.

Run these commands on your Jupyter notebook instance:

  1. Start up your Jupyter notebook instance and open a terminal window. Run the following commands in the terminal:

  2. Install OpenJDK: echo 'deb http://ftp.debian.org/debian stretch-backports main' | sudo tee /etc/apt/sources.list.d/stretch-backports.list
    sudo apt update
    sudo apt install openjdk-11-jdk
    java -version

Expected output:
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Debian-1bpo91)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Debian-1bpo91, mixed mode, sharing)

  1. Get Neo4j binaries: gsutil cp gs://cs327e-open-access/neo4j-community-4.1.3-unix.tar.gz .
    tar -xvf neo4j-community-4.1.3-unix.tar.gz

  2. Start Neo4j:
    /home/jupyter/neo4j-community-4.1.3/bin/neo4j console

Expected output:
Starting Neo4j.
WARNING: Max 4096 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
2020-10-13 01:35:16.929+0000 INFO Starting...
...
2020-10-13 01:35:25.300+0000 INFO Started.

Before running steps 5 and 6, open up a new terminal in your notebook. Then, run the following commands in the new terminal without closing the first one off.

  1. Set DB Password: /home/jupyter/neo4j-community-4.1.3/bin/neo4j-admin set-initial-password neo4j

  2. Test Database Connection: /home/jupyter/neo4j-community-4.1.3/bin/cypher-shell -u neo4j -p neo4j

Expected output:
Connected to Neo4j 4.1.0 at neo4j://localhost:7687 as user neo4j.
Type :help for a list of available commands or :exit to exit the shell.
Note that Cypher queries must end with a semicolon.

If your connection failed, troubleshoot and resolve before continuing.

After you set a new password, make sure you change the content following "-p" to your password in step 6 for future connections.

The following section is optional. If you want to be able to visually explore your Neo4j database using a GUI, follow the next few steps. They will need to be run on your laptop or desktop computer. Note: these steps have been tested on OSX, but not Windows. Warning: If you are a Windows user, you may run into some issues.

  1. Set up SSH tunnel for accessing Neo4j Browser:
  • Install the Cloud SDK for your OS. Use the interactive installer from here.
  • Open a terminal (OSX) or command-line window (Windows) and run gcloud init. Go through the prompts by entering your project_id and authenticating with your gmail account.
  • Set these 3 environment variables:
    export PROJECT_ID={your_project_id} (e.g. cs327e-fa2020)
    export ZONE={your_zone} (e.g. us-central1-a)
    
export INSTANCE_NAME=<your_jupyter_instance> (e.g. notebook)

Note: The export command won't work on Windows. On Windows, you'll need to use setx instead as follows:

setx PROJECT_ID "{your_project_id}"
setx ZONE "{your_zone}"
setx INSTANCE_NAME "{your_jupyter_instance}"

  • Set up SSH tunnel:
    gcloud compute ssh --project $PROJECT_ID --zone $ZONE $INSTANCE_NAME -- -L 7474:localhost:7474 -L 7687:localhost:7687


If you get any errors, stop and debug.

Very important: each time you restart your Jupyter notebook instance, you'll also need to start up Neo4j and set your SSH tunnel.

Clone this wiki locally