Skip to content

Neo4J helper repository to run Neo4j with docker-compose

License

Notifications You must be signed in to change notification settings

Linkurious/docker-neo4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dockerized repository

Usage

Clone

To use this repo, you must first clone it locally

git clone [email protected]:Linkurious/docker-neo4j.git
cd ./docker-neo4j

Configure

Configure variables in .env. See .env.example for template. Reasonable defaults are provided. Simply use them when working localy.

ln -s .env.example .env
ln -s .env.neo4j.v4.example .env.neo4j.v4.dev

Start Neo4j

Run with docker-compose Neo4j v4

docker-compose up -d

Neo4j v5

docker-compose -f docker-compose.v5.yml -f docker-compose.override.yml up -d

Start Neo4j cluster

Neo4j v4

ln -s .env.neo4j.v4.example .env.neo4j.v4.dev
docker-compose -f docker-compose.cluster.v4.yml -f docker-compose.cluster.override.yml up -d

Neo4j v5

ln -s .env.neo4j.v5.example .env.neo4j.v5.dev
docker-compose -f docker-compose.cluster.v5.yml -f docker-compose.cluster.override.yml up -d

Browse database when working localy

Go to http://localhost:7474 and connect with the following parameters:

  • Connect URL: bolt://localhost:7687
  • Database: leave empty
  • Authentication type: Username / Password
  • Username: neo4j
  • Password: neo3j

Neo4j v3 restore

docker-compose -f docker-compose.yml -f docker-compose.shell.yml run --rm neo4j bash

From dev env:

docker-compose -f docker-compose.yml  -f docker-compose.override.yml -f docker-compose.shell.yml run --rm neo4j bash

Backup and restore (Neo4j V4)

see https://neo4j.com/docs/operations-manual/current/backup/

When working localy, docker-compose.override.yml adds a local bind mount to the /backups folder.

Backups can be downloaded from Nexus. They have to be decompressed in the ./backups bind mounted folder.

Create an online backup (command to be executed in the context of the neo4j container, with docker-compose exec neo4j):

neo4j-admin backup --backup-dir /backups --database crunchbase-1.0.0

Restore/create from dataset:

neo4j-admin restore --from /datasets/4.2.0/crunchbase --database crunchbase-1.0.0  --verbose

Restore from backup:

neo4j-admin restore --from /backups/4.2.0/crunchbase --database crunchbase-1.0.0 --verbose

in v3.5.x

neo4j-admin restore --from /backups/3.5.15/fincrime-1.0.0/ --database graph.db

On first creation of a db, you will have to:

:use system
CREATE DATABASE `crunchbase-1.0.0` WAIT;

You can then check that the db has succesfully been restored with:

:use crunchbase-1.0.0
match (n) return n limit 10

Offline load

neo4j-admin load --from=/datasets/crunch.3.5.15  --database=crunchbase-1.0.0

and create the database via cypher-shell (the credential are specified in the .env.neo4j.dev at the root of you repository) :

cypher-shell
CREATE DATABASE crunchbase;

Plugins

Apoc

see https://neo4j.com/labs/apoc/4.4/installation/

Download the appropriate version of apoc plugin and drop it in the plugins folder:

curl -L https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.4.0.11/apoc-4.4.0.11-all.jar -o plugins/apoc-4.4.0.11-all.jar

Warning: Check the matching version for your version of Neo4j

Aura

load db

From a shell, stoped database :

bin/neo4j-admin push-to-cloud --bolt-uri neo4j+s://XXXXX.databases.neo4j.io --database=fincrime-1.0.0 --overwrite

Nexus datasets

Retrieve backup

We provide a script automating retrieving a backup from a given instance running in K8s:

./scripts/backup.sh

Manual upload for large datasets

export dataset_name=fincrime-sales
export dataset_version=1.0.0
curl -L -v --user [email protected]:${USER_PWD} --upload-file ${dataset_name}-${dataset_version}.backup https://nexus3.linkurious.net/repository/datasets/com/linkurious/neo4j/5.24.21/${dataset_name}/${dataset_name}-${dataset_version}.backup

Download dataset

export dataset_name=fincrime-sales
export dataset_version=1.0.0
curl -L -v --user [email protected]:${USER_PWD} https://nexus3.linkurious.net/repository/datasets/com/linkurious/neo4j/4.2.4/${dataset_name}/${dataset_name}-${dataset_version}.tgz