Step4: Now, we need to work on Preparing the filesystem. As we planned want need to keep track of the logs and be able to reuse our data, we will need to give the Docker image some access to our filesystem. In our home folder [~], let’s create a Neo4j folder and two subfolders named logs and data. This below script will do it on a Linux platform: cd ~ mkdir neo4j cd neo4j mkdir logs mkdir data
Enter the above steps in a .sh script.
Step5: How to Run Neo4j in a Docker container ?: I need to run the below command;
sudo apt install docker.io
Now, we can run the below long command in a Terminal to run Docker with a Neo4j image.
sudo docker run –rm –publish=7474:7474 –publish=7687:7687 –volume=$HOME/neo4j/data:/data \ –volume=$HOME/neo4j/logs:/logs neo4j:3.1.2
This command triggered some downloading because our local Docker repository does not have the Neo4j image available in its 3.1.2 version yet.
Ports used by Neo4j are 7474, 7473, and 7687, for the protocols http, https, and bolt, respectively . In the parameters part, you can see–volume twice. Its use is to link the folder on the local filesystem to the container filesystem.
Step6: Providing the port numbers given as parameters were not in use, the Terminal should display something like this:
Now, it denotes our Docker container started for Neo4j.
This informs us that Neo4j is expecting us to connect on port 7474 as usual. So let us fire our browser and browse to the very same URL we saw earlier, http://localhost:7474, and go graphing! (Make sure our data will be persisted on disk.)
Step7: now, How to stop Docker running your image ?
In order to stop Docker , you need to pass not the name (of the image) but the identifier of the running container (based on the image).
So, in another Terminal, let us type as follows to know the status of containers: docker ps
This will list all the containers running, in our case, only one. So we look at the first column, container_id, and use it as a parameter: docker stop container_id
You can watch the terminal screen. Docker container stopped as it should be stopped with this command.
For typical installation procedure of neo4j visit my blog:
In continuation of my previous blogs on DevOps tools. In this blog I would like to demonstrate on “Installation of Neo4j 3.2.6 Graph database on Ubuntu” with screen outputs for each command.
Installation of Neo4j for ubuntu
Assuming you have the Ubuntu cloud machine setup and following this session.
Step1: Install JDK
We need to install JDK before installing Neo4j.
add-apt-repository ppa:webupd8team/java
================================>
vskumar@ubuntu:~$ sudo add-apt-repository ppa:webupd8team/java
Oracle Java (JDK) Installer (automatically downloads and installs Oracle JDK7 / JDK8 / JDK9). There are no actual Java files in this PPA.
Ubuntu 16.10 Yakkety Yak is no longer supported by Canonical (and thus, Launchpad and this PPA). The PPA supports Ubuntu 17.10, 17.04, 16.04, 14.04 and 12.04.
gpg: keyring `/tmp/tmp_l64cwdq/secring.gpg’ created
gpg: keyring `/tmp/tmp_l64cwdq/pubring.gpg’ created
gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp_l64cwdq/trustdb.gpg: trustdb created
gpg: key EEA14886: public key “Launchpad VLC” imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
vskumar@ubuntu:~$ ^C
vskumar@ubuntu:~$
==============================>
Now, we can update the Ubuntu packages as below:
=============== Let us update as below =====>
vskumar@ubuntu:~$ sudo apt-get -f install
Reading package lists… Done
Building dependency tree
Reading state information… Done
Correcting dependencies… Done
The following packages were automatically installed and are no longer required:
bridge-utils containerd runc ubuntu-fan
Use ‘sudo apt autoremove’ to remove them.
The following additional packages will be installed:
linux-headers-4.10.0-42-generic linux-headers-generic-hwe-16.04
The following NEW packages will be installed:
linux-headers-4.10.0-42-generic
The following packages will be upgraded:
linux-headers-generic-hwe-16.04
1 upgraded, 1 newly installed, 0 to remove and 145 not upgraded.
6 not fully installed or removed.
Need to get 682 kB of archives.
After this operation, 7,550 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.10.0-42-generic amd64 4.10.0-42.46~16.04.1 [680 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-generic-hwe-16.04 amd64 4.10.0.42.44 [2,330 B]
Fetched 682 kB in 1s (494 kB/s)
Selecting previously unselected package linux-headers-4.10.0-42-generic.
(Reading database … 235799 files and directories currently installed.)
Preparing to unpack …/linux-headers-4.10.0-42-generic_4.10.0-42.46~16.04.1_amd64.deb …
Unpacking linux-headers-4.10.0-42-generic (4.10.0-42.46~16.04.1) …
Preparing to unpack …/linux-headers-generic-hwe-16.04_4.10.0.42.44_amd64.deb …
Unpacking linux-headers-generic-hwe-16.04 (4.10.0.42.44) over (4.10.0.40.42) …
Setting up rsync (3.1.1-3ubuntu1.1) …
Setting up linux-image-4.10.0-42-generic (4.10.0-42.46~16.04.1) …
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
update-initramfs: Generating /boot/initrd.img-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
Generating grub configuration file …
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.10.0-42-generic
Found initrd image: /boot/initrd.img-4.10.0-42-generic
Found linux image: /boot/vmlinuz-4.10.0-40-generic
Found initrd image: /boot/initrd.img-4.10.0-40-generic
Found linux image: /boot/vmlinuz-4.10.0-28-generic
Found initrd image: /boot/initrd.img-4.10.0-28-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
Setting up linux-image-extra-4.10.0-42-generic (4.10.0-42.46~16.04.1) …
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
update-initramfs: Generating /boot/initrd.img-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.10.0-42-generic /boot/vmlinuz-4.10.0-42-generic
Generating grub configuration file …
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.10.0-42-generic
Found initrd image: /boot/initrd.img-4.10.0-42-generic
Found linux image: /boot/vmlinuz-4.10.0-40-generic
Found initrd image: /boot/initrd.img-4.10.0-40-generic
Found linux image: /boot/vmlinuz-4.10.0-28-generic
Found initrd image: /boot/initrd.img-4.10.0-28-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
Setting up linux-image-generic-hwe-16.04 (4.10.0.42.44) …
Setting up linux-headers-4.10.0-42 (4.10.0-42.46~16.04.1) …
Setting up linux-headers-4.10.0-42-generic (4.10.0-42.46~16.04.1) …
Setting up linux-headers-generic-hwe-16.04 (4.10.0.42.44) …
Setting up linux-generic-hwe-16.04 (4.10.0.42.44) …
vskumar@ubuntu:~$
==================================>
Now, we need to install JDK9.
sudo apt install oracle-java9-installer
[Note: I have already installed JDK 9 in my VM before writing this blog. Hence the output is not copied].
Once the JDK is installed in your machine, check the java version as below:
$ java –version
=============================>
vskumar@ubuntu:~$
vskumar@ubuntu:~$ pwd
/home/vskumar
vskumar@ubuntu:~$ java –version
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
vskumar@ubuntu:~$
=============================>
Once the JDK is confirmed as above steps.
Now, let us start building the Neo4j setup as below steps:
Then move the below directory and check its validation:
sudo mv /tmp/neo4j.list /etc/apt/sources.list.d
================>
vskumar@ubuntu:~$
vskumar@ubuntu:~$ sudo mv /tmp/neo4j.list /etc/apt/sources.list.d
vskumar@ubuntu:~$ ls /etc/apt/sources.list.d
docker.list webupd8team-ubuntu-java-xenial.list
docker.list.save webupd8team-ubuntu-java-xenial.list.save
neo4j.list
vskumar@ubuntu:~$ ls -l /etc/apt/sources.list.d
total 20
-rw-r–r– 1 root root 70 Dec 8 04:08 docker.list
-rw-r–r– 1 root root 70 Dec 8 04:08 docker.list.save
-rw-rw-r– 1 vskumar vskumar 41 Dec 8 08:18 neo4j.list
-rw-r–r– 1 root root 207 Dec 8 04:08 webupd8team-ubuntu-java-xenial.list
-rw-r–r– 1 root root 136 Dec 8 04:08 webupd8team-ubuntu-java-xenial.list.save
vskumar@ubuntu:~$ cd /etc
vskumar@ubuntu:/etc$ cd apt
vskumar@ubuntu:/etc/apt$ cd sources
bash: cd: sources: No such file or directory
vskumar@ubuntu:/etc/apt$ cd sources.list.d
vskumar@ubuntu:/etc/apt/sources.list.d$ pwd
/etc/apt/sources.list.d
vskumar@ubuntu:/etc/apt/sources.list.d$ ls
docker.list webupd8team-ubuntu-java-xenial.list
docker.list.save webupd8team-ubuntu-java-xenial.list.save
neo4j.list
vskumar@ubuntu:/etc/apt/sources.list.d$
=============================>
Now, we need to update all dependencies by :
sudo apt-get update //
===================== You will see the huge output =======>
Once its done with ‘ok’ prompt, follow below step.
Now, let us install neo4j using
sudo apt-get install neo4j=3.2.6
==== See the below output =====>
vskumar@ubuntu:/etc/apt/sources.list.d$
vskumar@ubuntu:/etc/apt/sources.list.d$ sudo apt-get install neo4j=3.2.6
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
bridge-utils containerd linux-headers-4.10.0-28
linux-headers-4.10.0-28-generic linux-image-4.10.0-28-generic
linux-image-extra-4.10.0-28-generic runc ubuntu-fan
Use ‘sudo apt autoremove’ to remove them.
The following additional packages will be installed:
cypher-shell daemon
The following NEW packages will be installed:
cypher-shell daemon neo4j
0 upgraded, 3 newly installed, 0 to remove and 126 not upgraded.
Need to get 76.0 MB/76.9 MB of archives.
After this operation, 88.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://debian.neo4j.org/repo stable/ neo4j 3.2.6 [76.0 MB]
Fetched 76.0 MB in 1min 34s (801 kB/s)
Selecting previously unselected package daemon.
(Reading database … 252587 files and directories currently installed.)
Preparing to unpack …/daemon_0.6.4-1_amd64.deb …
Unpacking daemon (0.6.4-1) …
Selecting previously unselected package cypher-shell.
Preparing to unpack …/cypher-shell_1.1.2-1_all.deb …
Unpacking cypher-shell (1.1.2-1) …
Selecting previously unselected package neo4j.
Preparing to unpack …/archives/neo4j_3.2.6_all.deb …
Unpacking neo4j (3.2.6) …
Processing triggers for man-db (2.7.5-1) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
Setting up daemon (0.6.4-1) …
Setting up cypher-shell (1.1.2-1) …
Setting up neo4j (3.2.6) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
vskumar@ubuntu:/etc/apt/sources.list.d$
====================>
After completing installation process we need to restart neo4j service using the below command.
$sudo service neo4j restart
====================>
vskumar@ubuntu:/etc/apt/sources.list.d$ sudo service neo4j restart
vskumar@ubuntu:/etc/apt/sources.list.d$ sudo service neo4j status
● neo4j.service – Neo4j Graph Database
Loaded: loaded (/lib/systemd/system/neo4j.service; disabled; vendor preset: e
Active: active (running) since Fri 2017-12-08 08:46:14 PST; 7s ago
Main PID: 30856 (java)
Tasks: 8
Memory: 70.6M
CPU: 2.756s
CGroup: /system.slice/neo4j.service
└─30856 /usr/bin/java -cp /var/lib/neo4j/plugins:/etc/neo4j:/usr/shar
Dec 08 08:46:21 ubuntu neo4j[30856]: Directories in use:
Dec 08 08:46:21 ubuntu neo4j[30856]: home: /var/lib/neo4j
Dec 08 08:46:21 ubuntu neo4j[30856]: config: /etc/neo4j
Dec 08 08:46:21 ubuntu neo4j[30856]: logs: /var/log/neo4j
Dec 08 08:46:21 ubuntu neo4j[30856]: plugins: /var/lib/neo4j/plugins
Dec 08 08:46:21 ubuntu neo4j[30856]: import: /var/lib/neo4j/import
Dec 08 08:46:21 ubuntu neo4j[30856]: data: /var/lib/neo4j/data
Dec 08 08:46:21 ubuntu neo4j[30856]: certificates: /var/lib/neo4j/certificates
Dec 08 08:46:21 ubuntu neo4j[30856]: run: /var/run/neo4j
Dec 08 08:46:21 ubuntu neo4j[30856]: Starting Neo4j.