Reader small image

You're reading from  Learning Neo4j 3.x - Second Edition

Product typeBook
Published inOct 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781786466143
Edition2nd Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Jerome Baton
Jerome Baton
author image
Jerome Baton

Jérôme Baton started hacking computers at the age of skin problems, gaming first then continued his trip by self-learning Basic on Amstrad CPC, peaking on coding a full screen horizontal starfield, and messing the interlace of the video controller so that sprites appeared twice as high in horizontal beat'em up games. Disks were three inches for 178 Kb then. Then, for gaming reasons, he switched to Commodore Amiga and its fantastic AMOS Basic. Later caught by seriousness and studies, he wrote Turbo Pascal, C, COBOL, Visual C++, and Java on PCs and mainframes at university, and even Logo in high school. Then, Java happened and he became a consultant, mostly on backend code of websites in many different businesses. Jérôme authored several articles in French on Neo4j, JBoss Forge, an Arduino workshop for Devoxx4Kids, and reviewed kilos of books on Android. He has a weakness for wordplay, puns, spoonerisms, and Neo4j that relieves him from join(t) pains. Jérôme also has the joy to teach in French universities, currently at I.U.T de Paris, Université Paris V - René Descartes (Neo4j, Android), and Université de Troyes (Neo4j), where he does his best to enterTRain the students. When not programming, Jérôme enjoys photography, doing electronics, everything DIY, understanding how things work, trying to be clever or funny on Twitter, and spends a lot of time trying to understand his kids and life in general.
Read more about Jerome Baton

Right arrow

Chapter 16. Tips and Tricks

I am going to list a few tips and tricks to work efficiently on Neo4j.

Reset password


Even on a development machine that I use everyday, I may have forgotten the clever password I set up for the user Neo4j, as I have several versions installed on my machine.

The solution is to stop your server, then change the directory to the data/dbms subfolder, and remove the file named auth.

Check for other hosts

To know what hosts are running on your local network, with SSH access enabled, I offer you this little script:

#!/bin/bash

port=22
for ordi in `nmap -sn 192.168.0.1-100 /25 | egrep "scan report" | awk '{print $5}'`
do 
   echo Found IP $ordi on network.
   echo --------------------------------------
done
echo Now trying them for port $port , sorry for the timeout on successful connections
echo
for ordi in `nmap -sn 192.168.0.1-100 /25 | egrep "scan report" | awk '{print $5}'`
do
   echo Trying $ordi on port $port
   cat < /dev/tcp/$ordi/$port
   echo --------------------------------------
done

You may need to adapt this to change the IP range. Unix super users...

Enabling SSH on a Raspberry Pi


When I installed the latest distribution on an SD card as the operating system for a brand new Raspberry Pi, unfortunately, I had no television to plug it to. Too bad, for it makes it impossible to run the usual setup. Worse, the Pi was running, doing nothing, and was inaccessible.

Fortunately, remote access is possible by enabling SSH, which is already installed.

When you have burnt the ISO to the SD card, two drives appear. One is the future root filesystem of your Pi, and the second named boot is where you must create an empty file named ssh (no extension).

There you go; plug a network cable and it is online. You can now log into it via SSH and run raspi-config.

Note

Earlier versions of Raspian had SSH enabled by default. Maybe the distribution you use has it. Anyway, you know what to do now.

Creating guides for the Neo4j browser


When you are in a situation where you need to display data to users but cannot create an application for that, an option to consider is to create guides, locally hosted so that your users just need to click on the queries to get the results. There is no risk if they have the reader role.

The first obvious option is to look at a guide and see how the source is structured. The second option is to look at the project neo4j guides available at https://github.com/neo4j-contrib/neo4j-guides

This project proposes to convert a document in the asciidoc format to an HTML guide.

Here is a starter guide:

 == Learning Neo4j
:author: Jerome BATON
:twitter: wadael

=== Guides

Guides are very useful to quickly propose read-only queries to users.
See the arrows, I wrote no distinct source for that. Click it please
=== Add pictures

You can add pictures with this code
[source, text]
----
image::https://neo4j.com/wp-content/themes/neo4jweb/assets/images/neo4j-logo-2015...

Data backup and restore


Depending on the version you are using, the way to backup and restore your data will be different.

Community version

To back up your data of a community version server, only cold backup (offline) is possible.

A first way, very basic, but not to say DIY, is: first stop your server, then copy the whole $NEO_HOME/data folder to a secure storage. Then restart your server.

To restore backup data, stop your server, replace the $NEO_HOME/data folder with your backup, and restart your server. 

Another way is to use the neo4j-admin utility program, installed with the server in $NEO_HOME/bin:

neo4j-admin dump --to=file --database=optionnalDBName

The to parameter should be a path to a file. The database parameter is optional and only needed if you have more than one database and want to dump a database other than graph.db.

To restore this dump of data, the command is as follows:

neo4j-admin load from=file

Enterprise version

The Enterprise version comes with an enriched version utility...

Tools


Let's have a look at a few of the tools.

Cypher-shell

Cypher-shell is a command-line tool that comes with the default installation of Neo4j.

You will find it in the $NEO_HOME/bin folder. As already stated, it allows you to run Cypher queries interactively on a Neo4j server, such as the Neo4j browser:

Cypher-shell, interactive mode

It is also possible to use it in a unix-ian way, as the destination of a file. Suppose that we have a file named count.cy containing this query:

MATCH (n)
RETURN count(n);

We can use Cypher-shell like this:

Cypher-shell, in 'like a sysadmin' mode

Data integration tools

Talend (www.talend.com) is an open source software vendor that provides data integration, data management, enterprise application integration, and Big Data software and services. They have a very extensible, visual, and powerful development environment for all kinds of integration services that can be connected together in a workflow designer style environment.

MuleSoft (www.mulesoft.com), headquartered...

Community projects


These are projects definitely worth having a look at:

Online documentation


Neo4j Inc. provides a very good amount of documentation on its product; see https://neo4j.com/docs/.

The YouTube channel, https://www.youtube.com/c/neo4j, provides the videos of the graph connect events (and more).

Find the APOC userguide at https://neo4j-contrib.github.io/neo4j-apoc-procedures/.

Community


As open source users, we sometimes seek for help and sometimes offer our help. There is a Neo4j tag on StackOverflow, https://stackoverflow.com/questions/tagged/neo4j, for all the Neo4j questions.

There are several Slack channels; see https://neo4j.com/developer/slack/.

If you use Twitter, follow them all: @neo4j, @mesirii, @emileifrem, @rvanbruggen, @craigtaverner, @Aethelraed, @darthvader42, @tb_tomaz, @lyonwj, @maxdemarzi, @markhneedham, @BarrasaDV, @ryguyrg, @andres_taylor, @iansrobinson, @apcj, @jimwebber, (and maybe @wadael, too).

Graph Connect conferences and local meetups are a very good way to meet fellow graphistas, exchange tips, and push job offers.

More proverbs


To close this book on a lighter note but with wisdom anyway, here are some proverbs.

(As Lili said:) Trash in ! trash out ! Meaning if you do not put in the maximum care when you import data, you will get the data you deserve as query results!

Take care of the nulls, do not import numbers as strings, and use booleans when needed.

Everything is misplaced when you mistake latitude and longitude!

Having one's child's name on a book cover makes family happy!

The joy of learning calls for the joy to teach!

Authors love feedback!

 

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning Neo4j 3.x - Second Edition
Published in: Oct 2017Publisher: PacktISBN-13: 9781786466143
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Jerome Baton

Jérôme Baton started hacking computers at the age of skin problems, gaming first then continued his trip by self-learning Basic on Amstrad CPC, peaking on coding a full screen horizontal starfield, and messing the interlace of the video controller so that sprites appeared twice as high in horizontal beat'em up games. Disks were three inches for 178 Kb then. Then, for gaming reasons, he switched to Commodore Amiga and its fantastic AMOS Basic. Later caught by seriousness and studies, he wrote Turbo Pascal, C, COBOL, Visual C++, and Java on PCs and mainframes at university, and even Logo in high school. Then, Java happened and he became a consultant, mostly on backend code of websites in many different businesses. Jérôme authored several articles in French on Neo4j, JBoss Forge, an Arduino workshop for Devoxx4Kids, and reviewed kilos of books on Android. He has a weakness for wordplay, puns, spoonerisms, and Neo4j that relieves him from join(t) pains. Jérôme also has the joy to teach in French universities, currently at I.U.T de Paris, Université Paris V - René Descartes (Neo4j, Android), and Université de Troyes (Neo4j), where he does his best to enterTRain the students. When not programming, Jérôme enjoys photography, doing electronics, everything DIY, understanding how things work, trying to be clever or funny on Twitter, and spends a lot of time trying to understand his kids and life in general.
Read more about Jerome Baton