Linux下图形数据库Neo4j单机安装
Neo4j数据库简介
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.1。官方网址为https://neo4j.com/ Neo4j的相关文档URL地址如下
https://neo4j.com/docs/developer-manual/3.1/
https://neo4j.com/docs/operations-manual/3.1/
https://neo4j.com/docs/developer-manual/3.1/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)
Neo4j安装步骤:
下面简单介绍Linux下Neo4j 3.1的安装步骤,安装测试环境为Red Hat Enterprise Linux Server release 6.6, Debian下安装具体参考文档,这里不做介绍。
1:下载Neo4j 3.1的安装包,去官方网址注册下载即可。选择特定的版本。下载地址 https://neo4j.com/download/
2:检查上面System Requirement,安装JDK 8
[root@gettestlnx03 ~]# rpm -qa | grep gcj
libgcj-devel-4.4.7-11.el6.x86_64
libgcj-4.4.7-11.el6.x86_64
java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
[root@gettestlnx03 ~]# rpm -ivh /tmp/jdk-8u121-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk1.8.0_121 ########################################### [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
[root@gettestlnx03 ~]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
[root@gettestlnx03 ~]#
编辑/etc/profile文件,添加下面配置信息,然后执行source /etc/profile命令使之生效。
export JAVA_HOME=/usr/java/jdk1.8.0_121/
export CLASSPATH=/usr/java/jdk1.8.0_121/lib
export PATH=$AVA_HOME/bin:$PATH
3:创建一个用户neo4j,用来管理Neo4j 。当然这不是必须的。也可以是其它账号或root账号。
[root@gettestlnx03 ~]# /usr/sbin/groupadd nosql
[root@gettestlnx03 ~]# /usr/sbin/useradd -G nosql neo4j
4:然后切换到neo4j账户下,解压neo4j-community-3.1.1-unix.tar.gz包
[root@gettestlnx03 ~]# su - neo4j
[neo4j@gettestlnx03 ~]$ tar -zxvf /tmp/neo4j-community-3.1.1-unix.tar.gz -C /home/neo4j/
配置.bash_profile文件,增加下面一行,并使之生效。
[root@gettestlnx03 neo4j]# su - neo4j
[neo4j@gettestlnx03 ~]$ vi .bash_profile
export PATH=/home/neo4j/neo4j-community-3.1.1/bin:$PATH #新增一行
[neo4j@gettestlnx03 ~]$ source .bash_profile
另外,修改配置文件/etc/security/limits.conf ,增加下面配置。
neo4j soft nofile 40000
neo4j hard nofile 40000
The usual default of 1024 is often not enough. This is especially true when many indexes are used or a
server installation sees too many connections. Network sockets count against the limit as well. Users
are therefore encouraged to increase the limit to a healthy value of 40 000 or more, depending on
usage patterns. It is possible to set the limit with the ulimit command, but only for the root user, and
it only affects the current session. To set the value system wide, follow the instructions for your
platform.
编辑/etc/pam.d/su 在配置文件里面增加选项。
session optional pam_xauth.so
Neo4j服务关闭启动
Neo4j服务的启动、关闭如下所示
[neo4j@gettestlnx03 ~]$ neo4j start
Starting Neo4j.
Started neo4j (pid 2605). By default, it is available at http://localhost:7474/
There may be a short delay until the server is ready.
See /home/neo4j/neo4j-community-3.1.1/logs/neo4j.log for current status.
[neo4j@gettestlnx03 ~]$ neo4j status
Neo4j is running at pid 2605
[neo4j@gettestlnx03 ~]$ neo4j stop
Stopping Neo4j.. stopped
[neo4j@gettestlnx03 ~]$
如果不设置Neo4j的配置文件,只能从本机访问Neo4J的web控制台(http://localhost:7474/) Neo4j的控制文件一般位于<neo4jhome>/conf/neo4j.conf,例如我测试环境为/home/neo4j/neo4j-community-3.1.1/conf
Neo4j的配置文件将单独再做详细介绍。如果我们需要远程访问Neo4j的Web控制台,我们需要修改neo4j.conf配置文件的参数,如下截图所示:
当然,还需要配置iptables,开放7474端口号,否则你还是无法远程访问Web控制台。
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7474 -j ACCEPT
然后你就可以从远程http://xxx.xxx.xxx.xxx:7474 访问Neo4j的Web控制台了, 第一次登陆会提示你输入初始化密码并提醒你修改密码。默认的密码为neo4j. 如果允许远程访问,切记修改初始化密码。安全非常重要。
简单的测试案例
我们先创建一个简单的父子关系图。用来简单演示一下图形数据库的使用。如下所示。
[neo4j@gettestlnx03 bin]$ ./cypher-shell
username: neo4j
password: **********
Connected to Neo4j 3.1.1 at bolt://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> CREATE (A {id:1,name:'张飞'}), (B {id:2,name:'张小二'}), (C {id:3,name:'张三'}), (D {id:4,name:'张凯'}),(E {id:5,name:'张雨'}),(A)-[:Son]->(B),(A)-[:Son]->(C),(B)-[:Son]->(D),(C)-[:Son]->(E);
Added 5 nodes, Created 4 relationships, Set 10 properties
neo4j> START n=node(*) RETURN n;
n
({name: "张飞", id: 1})
({name: "张小二", id: 2})
({name: "张三", id: 3})
({name: "张凯", id: 4})
({name: "张雨", id: 5})
neo4j>

如果你在Web控制台执行命令,就能得到如下一个图形关系。如下所示。
参考资料:
https://neo4j.com/docs/developer-manual/3.1/
Linux下图形数据库Neo4j单机安装的更多相关文章
- Linux下apache+phppgadmin+postgresql安装配置
Linux下apache+phppgadmin+postgresql安装配置 操作系统:CentOS 安装包:httpd(首选yum), php(包括php以及php-pgsql,php-mbstri ...
- Linux下的网络远程安装
Linux下的网络远程安装 1.用RHEL6.5光盘安装第一台服务器 2.在第一台服务器上配置YUM服务器 先创建一个挂载 #mount #umount /dev/cdrom #mkdir /mnt/ ...
- Linux下指定版本编译安装LAMP
说明: 操作系统:CentOS 6.5 64位 需求: 编译安装LAMP运行环境 各软件版本如下: MySQL:mysql-5.1.73 Apache:httpd-2.2.31 PHP:php-5.2 ...
- 【转】Linux下XenServer管理工具安装
转载文章 - Linux下XenServer管理工具安装 Xen-Server 6.5 虚拟机安装Linux系统 vmware安装ubuntu12.04嵌套安装xen server(实现嵌套虚拟化) ...
- linux下.run文件的安装与卸载
linux下.run文件的安装与卸载 .run文件的安装很简单,只需要为该文件增加可执行属性,即可执行安装 以 virtualbox 的安装文件 virtualbox-3.1.6-59338-Li ...
- Linux下rar unrar的安装
Linux下rar unrar的安装: 以3.8.0版本为例,如果是64位平台,执行以下命令,也可以去官方网站:)下载最新版: wget http://www.rarlab.com/rar/rarli ...
- 【转】Linux下Android ADB驱动安装详解
原文网址:http://blog.csdn.net/zhenwenxian/article/details/5901350 Linux下Android ADB驱动安装详解 概述 最近由于内置的合作商比 ...
- Linux下的Oracle 11gr2安装完成的的自启动操作。
Linux下的Oracle在安装结束后是处于运行状态的.重启机器后,Oracle不会像在Windows下那样将Oracle添加到Windows服务,在linux下需要手动启动Orcle服务 以orac ...
- Linux下查看MySQL的安装路径
Linux下查看mysql.apache是否安装,并卸载. 指令 ps -ef|grep mysql 得出结果 root ? :: /bin/sh /usr/ ...
随机推荐
- C++版 - 剑指offer 面试题5:从尾到头打印链表 题解
面试题5:从尾到头打印链表 提交网址: http://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13&tq ...
- 【EF6学习笔记】(七)读取关联数据
本篇参考原文链接:Reading Related Data 本章主要讲述加载显示关联数据: 数据加载分为以下三种 Lazy loading 这种加载方式在于需要用到这个导航属性数据的时候,才会去数据库 ...
- MongoDB 生产环境笔记
目录 MongoDB 生产环境笔记 一.vm.zone_reclaim_mode 参数 二.添加 swap 分区 三.设置 swappiness 参数 四.内核和文件系统版本 五.禁用 Transpa ...
- Java 容器源码分析之 TreeMap
TreeMap 是一种基于红黑树实现的 Key-Value 结构.在使用集合视图在 HashMap 中迭代时,是不能保证迭代顺序的: LinkedHashMap 使用了双向链表,保证按照插入顺序或者访 ...
- 使用Python进行并发编程
让计算机程序并发的运行是一个经常被讨论的话题,今天我想讨论一下Python下的各种并发方式. 并发方式 线程(Thread) 多线程几乎是每一个程序猿在使用每一种语言时都会首先想到用于解决并发的工具( ...
- 为Spring Cloud Config插上管理的翅膀
最近一致在更新Spring Cloud Config的相关内容,主要也是为这篇埋个伏笔,相信不少调研过Spring Cloud Config的用户都会吐槽它的管理能力太弱.因此,就有了下面为讲推荐的这 ...
- 了解golang的可变参数(... parameters),这一篇就够了
在实际开发中,总有一些函数的参数个数是在编码过程中无法确定的,比如我们最常用的fmt.Printf和fmt.Println: fmt.Printf("一共有%v行%v列\n", r ...
- [转]Illuminate Database
本文转自:https://github.com/illuminate/database Illuminate Database The Illuminate Database component is ...
- 【转载】 Sqlserver查看数据库死锁的SQL语句
在Sqlsever数据库中,有时候操作数据库过程中会进行锁表操作,在锁表操作的过程中,有时候会出现死锁的情况出现,这时候可以使用SQL语句来查询数据库死锁情况,主要通过系统数据库Master数据库来查 ...
- C#线程安全类型
1.IProducerConsumerCollection (线程安全接口) 此接口的所有实现必须都启用此接口的所有成员,若要从多个线程同时使用. using System; using System ...




