Skip to content

Neo4j Setup Guide

Shirley Cohen edited this page Sep 5, 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.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-post-Debian-1deb10u2)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-post-Debian-1deb10u2, 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. Add neo4j to your PATH by adding this line to your .bash_profile:

export PATH=$PATH:/home/jupyter/neo4j-community-4.1.3/bin

  1. Run source .bash_profile to reload your PATH.

  2. Start Neo4j:
    neo4j console

Expected output:
Starting Neo4j.
WARNING: Max 4096 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
2021-03-26 15:07:21.740+0000 INFO Starting...
2021-03-26 15:07:23.896+0000 INFO ======== Neo4j 4.1.3 ========
2021-03-26 15:07:25.570+0000 INFO Initializing system graph model for component 'security-users' with version -1 and status UNINITIALIZED
2021-03-26 15:07:25.577+0000 INFO Setting up initial user from defaults: neo4j
2021-03-26 15:07:25.577+0000 INFO Creating new user 'neo4j' (passwordChangeRequired=true, suspended=false)
2021-03-26 15:07:25.590+0000 INFO Setting version for 'security-users' to 2
2021-03-26 15:07:25.595+0000 INFO After initialization of system graph model component 'security-users' have version 2 and status CURRENT
2021-03-26 15:07:25.601+0000 INFO Performing postInitialization step for component 'security-users' with version 2 and status CURRENT
2021-03-26 15:07:25.913+0000 INFO Bolt enabled on localhost:7687.
2021-03-26 15:07:26.927+0000 INFO Remote interface available at http://localhost:7474/
2021-03-26 15:07:26.928+0000 INFO Started.

Before running steps 7 and 8, 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:
    neo4j-admin set-initial-password neo4j

  2. Test Database Connection:
    cypher-shell -u neo4j -p neo4j

When prompted to change your password, enter a new password. Make sure you remember it.

Expected output:
(base) jupyter@notebook:~$ /home/jupyter/neo4j-community-4.1.3/bin/cypher-shell -u neo4j -p neo4j
Password change required
new password: ******
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.
neo4j@neo4j>
neo4j@neo4j> :exit

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


Expected output:
(venv) $ gcloud compute ssh --project $PROJECT_ID --zone $ZONE $INSTANCE_NAME -- -L 7474:localhost:7474 -L 7687:localhost:7687

Updating project ssh metadata...⠶Updated [https://www.googleapis.com/compute/v1/projects/cs327e-sp2021]. 


Updating project ssh metadata...done.


Waiting for SSH key to propagate.

Warning: Permanently added 'compute.314732067029641664' (ECDSA) to the list of known hosts.

======================================

Welcome to the Google Deep Learning VM

======================================


Version: common-cpu.mnightly-2021-01-20-debian-10-test

Based on: Debian GNU/Linux 10 (buster) (GNU/Linux 4.19.0-13-cloud-amd64 x86_64\n)


Resources:

* Google Deep Learning Platform StackOverflow: https://stackoverflow.com/questions/tagged/google-dl-platform

* Google Cloud Documentation: https://cloud.google.com/deep-learning-vm

* Google Group: https://groups.google.com/forum/#!forum/google-dl-platform


To reinstall Nvidia driver (if needed) run:

sudo /opt/deeplearning/install-driver.sh

Linux notebook 4.19.0-13-cloud-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64


The programs included with the Debian GNU/Linux system are free software;

the exact distribution terms for each program are described in the
 individual files in /usr/share/doc/*/copyright.
`

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
 permitted by applicable law.

scohen@notebook:~$


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