打赏

Ubuntu16.04下Neo4j图数据库官网安装部署步骤(图文详解)(博主推荐)

 

 

 不多说,直接上干货!

 

 

 

说在前面的话

   首先,查看下你的操作系统的版本。 

root@zhouls-virtual-machine:~# cat /etc/issue
Ubuntu 16.04.1 LTS \n \l

root@zhouls-virtual-machine:~#

 

 

 

  Neo4j 是一个NoSQL的图形数据库(Graph Database)。Neo4j使用图(graph)相关的概念来描述数据模型,把数据保存为图中的节点以及节点之间的关系。很多应用中数据之间的关系,可以很直接地使用图中节点和关系的概念来建模。对于这样的应用,使用 Neo4j 来存储数据会非常的自然,要优于使用关系数据库。

 

 

 

官方文档对Neo4j的介绍如下所示

  Neo4j is the world’s leading graph database. It is built from the ground up to be a graph database, meaning that its architecture is designed for optimizing fast management, storage, and traversal of nodes and relationships. Therefore, relationships are said to be first class citizens in Neo4j. An operation known in the relational database world as a join exhibits performance which degrades exponentially with the number of relationships. The corresponding action in Neo4j is performed as navigation from one node to another; an operation whose performance is linear.

 

 

 

 

  Neo4j分社区版(Community Edition)和企业版(Enterprise Edition),社区版本为免费版本。目前的最新版本为Neo4j 3.2。

 

 

https://neo4j.com/docs/developer-manual/3.2/

 https://neo4j.com/docs/operations-manual/3.2/

https://neo4j.com/docs/developer-manual/3.2/cypher/

 

 

System requirements

  Neo4j的安装对硬件、系统等有一些要求,例如CPU、Memory、Disk、Filesystem、Software等

 

CPU

  关于CPU,最低要求是Itel Core i3 推荐使用Intel Core i7 或 IBM POWER 8

 

Memory

  关于Memory,最低要求是2GB, 推荐是16-32GB 或更多。 越大的内存允许处理越大的图,但必须正确配置,以免破垃圾收集坏性操作。

 

Disk

  除了Disk的容量,Disk的性能对Neoj4的影响非常大,Neo4j的工作负载倾向于随机读。选择平均寻址时间低的存储,例如SSD

  最低要求 10GB SATA

  推荐配置 SSD w/SATA

 

FileSystem

  最低要求 ext4(或类似的)

  推荐配置 ext4、ZFS

 

Software

  Java

  必须安装OpenJDK 8 或 Oracle Java 8

 

Operation Sytem

  Linux(Ubuntu, Debian) ,但是我的测试环境为Red Hat Enterprise Linux Server release 6.6,暂时还没有发现什么问题。

  Architectures

  X86 或 OpenPower(POWER8)

 

 

 

 

 

 

 

Ubuntu16.04下Neo4j图数据库官网安装部署步骤

  第一步: 检查上面System Requirement,安装JDK 8,并卸载ubuntu里自带的openjdk。

 

root@zhouls-virtual-machine:~# java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-5-jre-headless
 * openjdk-8-jre-headless
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-9-jre-headless
Try: apt install <selected package>
root@zhouls-virtual-machine:~# sudo apt-get remove openjdk* 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'openjdk-9-jre-headless' for glob 'openjdk*'
Note, selecting 'openjdk-8-jdk' for glob 'openjdk*'
Note, selecting 'openjdk-8-jre' for glob 'openjdk*'
Note, selecting 'openjdk-6-jdk' for glob 'openjdk*'
Note, selecting 'openjdk-6-jre' for glob 'openjdk*'
Note, selecting 'openjdk-9-demo' for glob 'openjdk*'
Note, selecting 'openjdk-6-jre-headless' for glob 'openjdk*'
Note, selecting 'openjdk-8-demo' for glob 'openjdk*'
Note, selecting 'openjdk-8-jre-dcevm' for glob 'openjdk*'
Note, selecting 'openjdk-8-jdk-headless' for glob 'openjdk*'
Note, selecting 'openjdk-9-dbg' for glob 'openjdk*'
Note, selecting 'openjdk-7-jre-headless' for glob 'openjdk*'
Note, selecting 'openjdk-9-doc' for glob 'openjdk*'
Note, selecting 'openjdk-8-jre-zero' for glob 'openjdk*'
Note, selecting 'openjdk-8-source' for glob 'openjdk*'
Note, selecting 'openjdk-jre' for glob 'openjdk*'
Note, selecting 'openjdk-9-jdk' for glob 'openjdk*'
Note, selecting 'openjdk-9-jre' for glob 'openjdk*'
Note, selecting 'openjdk-7-jdk' for glob 'openjdk*'
Note, selecting 'openjdk-7-jre' for glob 'openjdk*'
Note, selecting 'openjdk-9-jdk-headless' for glob 'openjdk*'
Note, selecting 'openjdk-8-jre-headless' for glob 'openjdk*'
Note, selecting 'openjdk-9-source' for glob 'openjdk*'
Note, selecting 'openjdk-8-jre-jamvm' for glob 'openjdk*'
Note, selecting 'openjdk-8-dbg' for glob 'openjdk*'
Note, selecting 'openjdk-8-doc' for glob 'openjdk*'
Package 'openjdk-6-jdk' is not installed, so not removed
Package 'openjdk-7-jre-headless' is not installed, so not removed
Package 'openjdk-6-jre-headless' is not installed, so not removed
Package 'openjdk-7-jre' is not installed, so not removed
Package 'openjdk-6-jre' is not installed, so not removed
Package 'openjdk-7-jdk' is not installed, so not removed
Package 'openjdk-jre' is not installed, so not removed
Package 'openjdk-8-jre-dcevm' is not installed, so not removed
Package 'openjdk-9-dbg' is not installed, so not removed
Package 'openjdk-9-demo' is not installed, so not removed
Package 'openjdk-9-doc' is not installed, so not removed
Package 'openjdk-9-jdk' is not installed, so not removed
Package 'openjdk-9-jdk-headless' is not installed, so not removed
Package 'openjdk-9-jre' is not installed, so not removed
Package 'openjdk-9-jre-headless' is not installed, so not removed
Package 'openjdk-9-source' is not installed, so not removed
Package 'openjdk-8-dbg' is not installed, so not removed
Package 'openjdk-8-demo' is not installed, so not removed
Package 'openjdk-8-doc' is not installed, so not removed
Package 'openjdk-8-jdk' is not installed, so not removed
Package 'openjdk-8-jdk-headless' is not installed, so not removed
Package 'openjdk-8-jre' is not installed, so not removed
Package 'openjdk-8-jre-headless' is not installed, so not removed
Package 'openjdk-8-jre-jamvm' is not installed, so not removed
Package 'openjdk-8-source' is not installed, so not removed
Package 'openjdk-8-jre-zero' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 401 not upgraded.
root@zhouls-virtual-machine:~# 

 

 

 

 

下载 Java

  Java 8 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 

  

  我暂时,传到/home/zhouls/Downloads下

 

 

 

 

 

 

   我将 java 放在目录/usr/local/目录下,路径和命令为:

 

root@zhouls-virtual-machine:/usr/local# ls
bin  etc  games  include  lib  man  sbin  share  src
root@zhouls-virtual-machine:/usr/local# mkdir app
root@zhouls-virtual-machine:/usr/local# cd app/
root@zhouls-virtual-machine:/usr/local/app# pwd
/usr/local/app
root@zhouls-virtual-machine:/usr/local/app# ls
root@zhouls-virtual-machine:/usr/local/app# cp /home/zhouls/Downloads/jdk-8u60-linux-x64.tar.gz .
root@zhouls-virtual-machine:/usr/local/app# ls
jdk-8u60-linux-x64.tar.gz
root@zhouls-virtual-machine:/usr/local/app# 

 

 

 

 

root@zhouls-virtual-machine:/usr/local/app# ls
jdk-8u60-linux-x64.tar.gz
root@zhouls-virtual-machine:/usr/local/app# tar -zxvf jdk-8u60-linux-x64.tar.gz  

 

 

 

 

  为了,兼容去其余的版本,我这里使用软连接。

 

root@zhouls-virtual-machine:/usr/local/app# ls
jdk1.8.0_60  jdk-8u60-linux-x64.tar.gz
root@zhouls-virtual-machine:/usr/local/app# rm jdk-8u60-linux-x64.tar.gz 
root@zhouls-virtual-machine:/usr/local/app# ll
total 12
drwxr-xr-x  3 root root 4096 6月   2 15:03 ./
drwxr-xr-x 11 root root 4096 6月   2 14:58 ../
drwxr-xr-x  8 uucp  143 4096 8月   5  2015 jdk1.8.0_60/
root@zhouls-virtual-machine:/usr/local/app# ln -s jdk1.8.0_60/ jdk
root@zhouls-virtual-machine:/usr/local/app# ll
total 12
drwxr-xr-x  3 root root 4096 6月   2 15:04 ./
drwxr-xr-x 11 root root 4096 6月   2 14:58 ../
lrwxrwxrwx  1 root root   12 6月   2 15:04 jdk -> jdk1.8.0_60//
drwxr-xr-x  8 uucp  143 4096 8月   5  2015 jdk1.8.0_60/
root@zhouls-virtual-machine:/usr/local/app# chown -R root:root jdk1.8.0_60/
root@zhouls-virtual-machine:/usr/local/app# ll
total 12
drwxr-xr-x  3 root root 4096 6月   2 15:04 ./
drwxr-xr-x 11 root root 4096 6月   2 14:58 ../
lrwxrwxrwx  1 root root   12 6月   2 15:04 jdk -> jdk1.8.0_60//
drwxr-xr-x  8 root root 4096 8月   5  2015 jdk1.8.0_60/
root@zhouls-virtual-machine:/usr/local/app# 

 

 

 

    

  至于为什么这样来做,请移步

大数据各子项目的环境搭建之建立与删除软连接(博主推荐)

 

   

 

编辑/etc/profile文件,添加下面配置信息,然后执行source /etc/profile命令使之生效。

 

root@zhouls-virtual-machine:/usr/local/app# vim /etc/profile

 

 

#java
export JAVA_HOME=/usr/local/app/jdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin

 

 

 

 

 

root@zhouls-virtual-machine:/usr/local/app# vim /etc/profile
root@zhouls-virtual-machine:/usr/local/app# source /etc/profile
root@zhouls-virtual-machine:/usr/local/app# java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
root@zhouls-virtual-machine:/usr/local/app# 

 

 

 

   下载Neo4j 3.1的安装包

  去官方网址注册下载即可。选择特定的版本。下载地址 https://neo4j.com/download/

  选择“Download Communit Edtion”社区版

 

 

  在“Other OS Download”中选择 Linux 版(因为,我一般喜欢用tar.gz方式来安装,当然,大家也可以用其他方式来安装)

 

  它会自动下载到你的本地。

https://neo4j.com/artifact.php?name=neo4j-community-3.2.0-unix.tar.gz

 

 

 

 

 

 

 

   我这里,暂时是放在/home/zhouls/Downloads下

root@zhouls-virtual-machine:/usr/local/app# ls
jdk  jdk1.8.0_60
root@zhouls-virtual-machine:/usr/local/app# cp /home/zhouls/Downloads/neo4j-community-3.2.0-unix.tar.gz .
root@zhouls-virtual-machine:/usr/local/app# ls
jdk  jdk1.8.0_60  neo4j-community-3.2.0-unix.tar.gz
root@zhouls-virtual-machine:/usr/local/app# 

 

 

 

 

root@zhouls-virtual-machine:/usr/local/app# ls
jdk  jdk1.8.0_60  neo4j-community-3.2.0-unix.tar.gz
root@zhouls-virtual-machine:/usr/local/app# tar -zxvf neo4j-community-3.2.0-unix.tar.gz 

 

 

 

 

root@zhouls-virtual-machine:/usr/local/app# ls
jdk  jdk1.8.0_60  neo4j-community-3.2.0  neo4j-community-3.2.0-unix.tar.gz
root@zhouls-virtual-machine:/usr/local/app# rm neo4j-community-3.2.0-unix.tar.gz 
root@zhouls-virtual-machine:/usr/local/app# ll
total 16
drwxr-xr-x  4 root    root    4096 6月   2 15:40 ./
drwxr-xr-x 11 root    root    4096 6月   2 14:58 ../
lrwxrwxrwx  1 root    root      12 6月   2 15:04 jdk -> jdk1.8.0_60//
drwxr-xr-x  8 root    root    4096 8月   5  2015 jdk1.8.0_60/
drwxr-xr-x 10 dnsmasq nogroup 4096 5月   9 17:22 neo4j-community-3.2.0/
root@zhouls-virtual-machine:/usr/local/app# chown -R root:root neo4j-community-3.2.0/
root@zhouls-virtual-machine:/usr/local/app# ln -s neo4j-community-3.2.0/ neo4j
root@zhouls-virtual-machine:/usr/local/app# ll
total 16
drwxr-xr-x  4 root root 4096 6月   2 15:41 ./
drwxr-xr-x 11 root root 4096 6月   2 14:58 ../
lrwxrwxrwx  1 root root   12 6月   2 15:04 jdk -> jdk1.8.0_60//
drwxr-xr-x  8 root root 4096 8月   5  2015 jdk1.8.0_60/
lrwxrwxrwx  1 root root   22 6月   2 15:41 neo4j -> neo4j-community-3.2.0//
drwxr-xr-x 10 root root 4096 5月   9 17:22 neo4j-community-3.2.0/
root@zhouls-virtual-machine:/usr/local/app# 

 

 

 

 

  配置neo4j的环境变量

root@zhouls-virtual-machine:/usr/local/app# vim /etc/profile

 

 

 

 

#neo4j
export NEO4J_HOME=/usr/local/app/neo4j
export PATH=$PATH:$NEO4J_HOME/bin

 

 

 

 

 

root@zhouls-virtual-machine:/usr/local/app# vim /etc/profile
root@zhouls-virtual-machine:/usr/local/app# source /etc/profile
root@zhouls-virtual-machine:/usr/local/app# 

 

 

 

 

neo4j的配置文件(图文详解)

 

 

修改conf/neo4j.conf配置文件,将dbms.connectors.default_listen_address=0.0.0.0注释字符去掉

  如果不设置Neo4j的配置文件,只能从本机访问Neo4J的web控制台(http://localhost:7474/) Neo4j的控制文件一般位于<neo4jhome>/conf/neo4j.conf,例如我测试环境为/usr/local/app/neo4j/conf

修改前:#org.neo4j.server.webserver.address=0.0.0.0

修改后:org.neo4j.server.webserver.address=0.0.0.0

 

 

 

 

 

启动 Neo4j

root@zhouls-virtual-machine:/usr/local/app/neo4j/conf# neo4j  start
Active database: graph.db
Directories in use:
  home:         /usr/local/app/neo4j
  config:       /usr/local/app/neo4j/conf
  logs:         /usr/local/app/neo4j/logs
  plugins:      /usr/local/app/neo4j/plugins
  import:       /usr/local/app/neo4j/import
  data:         /usr/local/app/neo4j/data
  certificates: /usr/local/app/neo4j/certificates
  run:          /usr/local/app/neo4j/run
Starting Neo4j.
WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
Started neo4j (pid 7279). It is available at http://0.0.0.0:7474/
There may be a short delay until the server is ready.
See /usr/local/app/neo4j/logs/neo4j.log for current status.
root@zhouls-virtual-machine:/usr/local/app/neo4j/conf# neo4j  status
Neo4j is running at pid 7279
root@zhouls-virtual-machine:/usr/local/app/neo4j/conf# 

  此时一切正常。

 

 

 

 

 

  或者

bin/neo4j console 

 

root@zhouls-virtual-machine:/usr/local/app/neo4j# ls
bin           conf  import  LICENSES.txt  logs        plugins     run
certificates  data  lib     LICENSE.txt   NOTICE.txt  README.txt  UPGRADE.txt
root@zhouls-virtual-machine:/usr/local/app/neo4j# bin/neo4j console
Active database: graph.db
Directories in use:
  home:         /usr/local/app/neo4j
  config:       /usr/local/app/neo4j/conf
  logs:         /usr/local/app/neo4j/logs
  plugins:      /usr/local/app/neo4j/plugins
  import:       /usr/local/app/neo4j/import
  data:         /usr/local/app/neo4j/data
  certificates: /usr/local/app/neo4j/certificates
  run:          /usr/local/app/neo4j/run
Starting Neo4j.
WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
2017-06-02 08:45:20.269+0000 INFO  ======== Neo4j 3.2.0 ========
2017-06-02 08:45:22.614+0000 INFO  Starting...
2017-06-02 08:45:27.000+0000 INFO  Bolt enabled on 0.0.0.0:7687.
2017-06-02 08:45:50.131+0000 INFO  Started.
2017-06-02 08:45:57.150+0000 INFO  Remote interface available at http://localhost:7474/

 

 

 

 

 

 

打开 neo4j的 Web 端

  根据启动时的提示,在浏览器中打开:http://localhost:7474/ 

 

   第一次登陆会提示你输入初始化密码并提醒你修改密码。默认的密码为neo4j. 如果允许远程访问,切记修改初始化密码。安全非常重要。

 

 

 

 

 

  默认值都是neo4j
  更改新密码为123456。

  即我的用户名是neo4j,密码是123456。

 

 

 

 

 

 

 

可以点击页面上的“Start Learning”进行初步的学习 Neo4j。

至此,Neo4j 已经在 Ubuntu 上安装好了。

 

posted @ 2017-06-02 14:20  大数据和AI躺过的坑  阅读(7394)  评论(1编辑  收藏  举报