• Ubuntu16.04下沙盒数据导入到 Neo4j 数据库(图文详解)


      不多说,直接上干货!

      参考博客

    http://blog.csdn.net/u012318074/article/details/72793914   (表示感谢)

       前期博客

    Neo4j沙盒实验申请过程步骤(图文详解)

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

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

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

     这篇文章就来介绍一下我将 Neo4j 沙盒中的数据导入到自己的 Neo4j 数据库的方法。大家可以清楚的看到沙盒数据公开了很多,我这里,仅此network-management

     

       使用 github 上的源数据:https://github.com/neo4j-contrib/sandbox-guides

    Neo4j browser guides for sandbox instances

    Available Use Cases

    • us-elections-2016
    • blank-sandbox

    Render / deploy guides for a use case

    1. Clone this repo git clone git@github.com:neo4j-contrib/sandbox-guides.git

    2. cd sandbox-guides

    3. git submodule init

    4. git submodule update

    5. Edit {USE-CASE}/{GUIDE-NAME-HERE}.adoc

    6. {USE-CASE}/render.sh [publish]

    7. Open Neo4j Browser and run :play http://localhost:8001/{USE-CASE}

    第一步:克隆下载

    1. Clone this repo git clone git@github.com:neo4j-contrib/sandbox-guides.git

      选择一个要存放这个数据的文件夹,我存放的目录为/usr/local/app/neo4j-community-3.2.0/data/databases,使用 Git 方法下载文件,在目录下执行 

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases# git clone https://github.com/neo4j-contrib/sandbox-guides.git

    root@zhouls-virtual-machine:/usr/local/app# cd neo4j-community-3.2.0/
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0# 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-community-3.2.0# cd data/
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data# ls
    databases  dbms
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data# cd databases/
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases# ls
    graph.db
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases# git clone https://github.com/neo4j-contrib/sandbox-guides.git

     

       再次执行即可,这个很简单。

     

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases# git clone https://github.com/neo4j-contrib/sandbox-guides.git
    Cloning into 'sandbox-guides'...
    remote: Counting objects: 329, done.
    remote: Total 329 (delta 0), reused 0 (delta 0), pack-reused 329
    Receiving objects: 100% (329/329), 11.80 MiB | 35.00 KiB/s, done.
    Resolving deltas: 100% (105/105), done.
    Checking connectivity... done.
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases# ls
    graph.db  sandbox-guides

      第二步:切换到刚下载的sandbox-guides目录

      cd sandbox-guides

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases# pwd
    /usr/local/app/neo4j-community-3.2.0/data/databases
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases# ls
    graph.db  sandbox-guides
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases# cd sandbox-guides/
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# pwd
    /usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# ls
    blank-sandbox  neo4j-guides        README.md        trumpworld
    legis-graph    network-management  recommendations  us-elections-2016
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# 

      第三步: 初始化

    git submodule init

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# git submodule init 
    Submodule 'neo4j-guides' (https://github.com/neo4j-contrib/neo4j-guides.git) registered for path 'neo4j-guides'
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# 

       第四步:升级

    git submodule update

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# git submodule update
    Cloning into 'neo4j-guides'...
    remote: Counting objects: 163, done.
    remote: Total 163 (delta 0), reused 0 (delta 0), pack-reused 163
    Receiving objects: 100% (163/163), 156.09 KiB | 5.00 KiB/s, done.
    Resolving deltas: 100% (56/56), done.
    Checking connectivity... done.
    Submodule path 'neo4j-guides': checked out '89201c7651b679fb9a487169389ac39ec9cbc00f'
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# ls
    blank-sandbox  neo4j-guides        README.md        trumpworld
    legis-graph    network-management  recommendations  us-elections-2016
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# 

      第五步

      Edit {USE-CASE}/{GUIDE-NAME-HERE}.adoc

      这里,跳过

      第六步:执行脚本 

      {USE-CASE}/render.sh [publish]

      我这里主要是获取“network-management”数据,所以进入“network-management”文件夹,目录和命令为: 

       当然,大家也可以进入其他目录下,我这里仅以network-management为例。

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# ls
    blank-sandbox  neo4j-guides        README.md        trumpworld
    legis-graph    network-management  recommendations  us-elections-2016
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# cd network-management/
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management# pwd
    /usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management# ls
    img  network-management.adoc  network-management.cypher  render.sh
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management# ./render.sh

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management# ./render.sh
    Usage: sh render.sh [publish]
    ../neo4j-guides/run.sh: line 1: asciidoctor: command not found
    ../neo4j-guides/run.sh: line 1: gem: command not found
    Usage ./run.sh OR ./run.sh path/to/a_guide.adoc [guide.html] [+1 (header-offset)] [http://guide-host:port]
    rendering network-management.adoc to index.html
    asciidoctor network-management.adoc -T ../neo4j-guides/templates -a allow-uri-read -a experimental -a guides=http://localhost:8001/ -a current=http://localhost:8001/ -a img=http://localhost:8001//img -a leveloffset=+1 -a env-guide= -a guide= -o index.html
    ../neo4j-guides/run.sh: line 20: asciidoctor: command not found
    Starting Websever at localhost:8001/ Ctrl-c to stop
    ^CTraceback (most recent call last):
    File "../neo4j-guides/http-server.py", line 23, in <module>
    HTTPServer(('0.0.0.0', 8001), CORSRequestHandler).serve_forever()
    File "/usr/lib/python2.7/SocketServer.py", line 231, in serve_forever
    poll_interval)
    File "/usr/lib/python2.7/SocketServer.py", line 150, in _eintr_retry
    return func(*args)
    KeyboardInterrupt
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management#

      那么就根据提示信息安装“asciidoctor”和“tilt” 
      在新的命令窗口使用 root 权限执行

    apt-get install asciidoctor
    gem install tilt

     

     

     

    gem install thread_safe

      然后,再次执行。

     

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management# ./render.sh
    Usage: sh render.sh [publish]
    Asciidoctor 1.5.4 [http://asciidoctor.org]
    Runtime Environment (ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]) (lc:UTF-8 fs:UTF-8 in:- ex:UTF-8)
    Usage ./run.sh OR ./run.sh path/to/a_guide.adoc [guide.html] [+1 (header-offset)] [http://guide-host:port]
    rendering network-management.adoc to index.html
    asciidoctor network-management.adoc -T ../neo4j-guides/templates -a allow-uri-read -a experimental -a guides=http://localhost:8001/ -a current=http://localhost:8001/ -a img=http://localhost:8001//img -a leveloffset=+1 -a env-guide= -a guide= -o index.html
    asciidoctor: WARNING: network-management.adoc: line 12: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 38: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 50: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 88: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 152: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 173: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 274: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 302: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 402: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 436: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 452: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 488: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 576: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 671: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 683: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 722: section title out of sequence: expected level 1, got level 2
    asciidoctor: WARNING: network-management.adoc: line 733: section title out of sequence: expected level 1, got level 2
    2 Network Management - Introduction
    2 Modeling
    2 DataCenter
    2 Network Exploration: DataCenter and Zones
    2 Network Exploration: Racks
    2 Network Connectivity
    2 Machine types
    2 Machines
    2 Software: Operating Systems and Applications
    2 Software: Running on Machines
    2 Dependency Analysis
    2 Configuration Management
    3 Upgrade OS Version and its Dependencies for a Version Range
    2 IT-Monitoring and Governance
    2 Examples for graph based Network Management Solutions
    2 Monitoring Use-Cases
    3 For instance, minimal, average and maximal runtimes of software instances per type
    3 Data Transer Volume between Interfaces
    2 Resource Management Graph
    2 References
    Starting Websever at localhost:8001/ Ctrl-c to stop
    127.0.0.1 - - [03/Jun/2017 12:18:13] "GET / HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:13] "GET //img/Network-Management-Model.svg HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:13] "GET //img/network-schema-arrows.jpg HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:13] "GET //img/network-zones.jpg HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:13] "GET //img/network-rack.jpg HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:13] "GET //img/network-alternative-routes.jpg HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:13] "GET //img/network-8000-machines.jpg HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:14] "GET //img/network-rack-machines-type.jpg HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:14] "GET //img/network-software-arrows.jpg HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:14] "GET //img/network-software-machine.jpg HTTP/1.1" 200 -
    127.0.0.1 - - [03/Jun/2017 12:18:14] code 404, message File not found
    127.0.0.1 - - [03/Jun/2017 12:18:14] "GET /favicon.ico HTTP/1.1" 404 -
    127.0.0.1 - - [03/Jun/2017 12:18:14] code 404, message File not found
    127.0.0.1 - - [03/Jun/2017 12:18:14] "GET /favicon.ico HTTP/1.1" 404 -

      如果还是报错,可以根据提示信息进行处理。我这里是已经成功了。

      

      第七步:打开 web 界面 

    Open Neo4j Browser and run :play http://localhost:8001/{USE-CASE}

      当上一步启动完成后,在浏览器中打开http://localhost:8001/,正常情况下会出现 

       如果看到这个页面,表示说明介绍页面已经正常了,可能会出现乱码,这无所谓,后面会说明如何使用,到时就不会有乱码了。

      第八步:导入数据 

      这一步是关键,也是目的所在,也与 GitHub 上的步骤不同。 
      我在使用 Neo4j 页面导入的时候会报错,经查找通过 shell 方式导入数据就不会报错,于是采用以下方式: 
      在 Neo4j 安装目录的bin文件夹中进入cypher-shell,我的具体目录和命令为 

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0# pwd
    /usr/local/app/neo4j-community-3.2.0
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0# 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-community-3.2.0# cd bin/
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/bin# ls
    cypher-shell  neo4j  neo4j-admin  neo4j-import  neo4j-shell  tools
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/bin# ./cypher-shell 

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

       然后输入用户名和密码连接到 Neo4j 数据库。可以参考我上面的这篇博客。

     

       如果大家,遇到如下的问题,请移步

    Neo4j下执行cypher-shell时,Connection refused问题解决?

      大家,可以看看,沙盒数据里,所带的

     

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# ls
    blank-sandbox  neo4j-guides        README.md        trumpworld
    legis-graph    network-management  recommendations  us-elections-2016
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides# cd network-management/
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management# ls
    img  index.html  network-management.adoc  network-management.cypher  render.sh
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management# libreoffice network-management.cypher
    javaldx: Could not find a Java Runtime Environment!
    Warning: failed to read path from javaldx
    
    (soffice:58974): Gdk-WARNING **: gdk_window_set_icon_list: icons too large
    
    (soffice:58991): Gdk-WARNING **: gdk_window_set_icon_list: icons too large
    :1: parser error : Document is empty
    // Data Center
    ^
    :1: parser error : Document is empty
    // Data Center
    ^
    :1: parser error : Document is empty
    // Data Center
    ^

      然后复制/usr/local/app/neo4j-community-3.2.0/data/databases/sandbox-guides/network-management/network-management.cypher”这个文件里的全部内容到neo4j>,这样就可以顺利创建数据了

      按Ctrl +  c 复制,粘贴到neo4j>

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/bin# ls
    cypher-shell  neo4j  neo4j-admin  neo4j-import  neo4j-shell  tools
    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/bin# ./cypher-shell
    username: neo4j
    password: ******
    Connected to Neo4j 3.2.0 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> // Data Center
           
           CREATE (dc:DataCenter {name:"DC1",location:"Iceland, Rekjavik"})-[:CONTAINS]->(re:Router:Egress {name:"DC1-RE"})
           CREATE (re)-[:ROUTES]->(:Interface {ip:"10.0.0.254"});
    0 rows available after 24346 ms, consumed after another 15 ms
    Added 3 nodes, Created 2 relationships, Set 4 properties, Added 4 labels
    neo4j> 
    neo4j> // Zones
           // The datacenter consists of 4 zones, each of which has it's own separate `Network` `10.zone.*/16`, and it's own `Router`.
           
           
           WITH 4 AS zones
           MATCH (dc:DataCenter {name:"DC1"})-[:CONTAINS]->(re:Router:Egress)-[:ROUTES]->(rei:Interface)
           
           // for each zone
           WITH * UNWIND range(1,zones) AS zid
           
           // create zone network
           CREATE (nr:Network:Zone {ip:"10."+zid, size: 16, zone:zid})<-[:CONNECTS]-(rei)
           
           // create router in DC, connect it via an interface to the zone network
           CREATE (dc)-[:CONTAINS]->(r:Router {name:"DC1-R-"+zid, zone:zid})-[:ROUTES]->(ri:Interface {ip:nr.ip+".0.254"})-[:CONNECTS]->(nr);
    0 rows available after 41466 ms, consumed after another 0 ms
    Added 12 nodes, Created 16 relationships, Set 24 properties, Added 16 labels
    neo4j> 
    neo4j> 
    neo4j> // Racks
           
           WITH 10 as racks
           MATCH (dc:DataCenter {name:"DC1"})
           MATCH (nr:Network:Zone) // one per zone
           
           WITH * UNWIND range(1,racks) AS rackid
           
           CREATE (dc)-[:CONTAINS]->(rack:Rack {name:"DC1-RCK-"+nr.zone+"-"+rackid, rack:rackid, zone:nr.zone})-[:HOLDS]->(s:Switch {ip:nr.ip+"."+rackid, rack:rackid})-[:ROUTES]->(si:Interface {ip:s.ip+".254"})<-[:ROUTES]-(nr);
    0 rows available after 1065 ms, consumed after another 0 ms
    Added 120 nodes, Created 160 relationships, Set 240 properties, Added 120 labels
    neo4j> 
    neo4j> // Machine types
           
           // Similar to the machines you can rent on AWS we use machine types, for which we auto-create some reasonable capacities for CPU, RAM and DISK.
           
           WITH ["xs","s","m","l","xl","xxl"] as typeNames
           UNWIND range(0,size(typeNames)-1) as idx
           CREATE (t:Type {id:idx, cpu: toInt(2^idx), ram:toInt(4^idx), disk:toInt(5^idx), type: typeNames[idx]}) 
              SET t.name = typeNames[idx]+"-"+t.cpu + "/"+t.ram+"/"+t.disk
           RETURN t.name, t.id, t.cpu, t.ram, t.disk;
    +----------------------------------------------------+
    | t.name             | t.id | t.cpu | t.ram | t.disk |
    +----------------------------------------------------+
    | "xs-1/1/1"         | 0    | 1     | 1     | 1      |
    | "s-2/4/5"          | 1    | 2     | 4     | 5      |
    | "m-4/16/25"        | 2    | 4     | 16    | 25     |
    | "l-8/64/125"       | 3    | 8     | 64    | 125    |
    | "xl-16/256/625"    | 4    | 16    | 256   | 625    |
    | "xxl-32/1024/3125" | 5    | 32    | 1024  | 3125   |
    +----------------------------------------------------+
    
    6 rows available after 914 ms, consumed after another 1 ms
    Added 6 nodes, Set 36 properties, Added 6 labels
    neo4j> 
    neo4j> 
    neo4j> // Machines
           
           // Each Rack contains 200 machines of the types we just introduced, so that in total we get 8000 servers in our datacenter.
           // The distribution of the types is inverse to their capabilities.
           
           MATCH (t:Type)
           WITH collect(t) as types, 200 as machines
           
           MATCH (rack:Rack)-[:HOLDS]->(s:Switch)-[:ROUTES]->(si:Interface)
           
           UNWIND (range(1,machines)) AS machineid
           
           CREATE (rack)-[:HOLDS]->(m:Machine {id:rack.id * 1000 + machineid, name: rack.name + "-M-" +machineid })-[:ROUTES]->(i:Interface {ip:s.ip+"."+machineid})-[:CONNECTS]->(si)
           WITH m,types,size(types)-toInt(log(machines - machineid + 1)) -1 as idx
           WITH m, types[idx] as t
           CREATE (m)-[:TYPE]->(t);
    0 rows available after 12989 ms, consumed after another 0 ms
    Added 16000 nodes, Created 32000 relationships, Set 16000 properties, Added 16000 labels
    neo4j> 
    neo4j> 
    neo4j> // Create OS and Software
           
           // https://en.wikipedia.org/wiki/Red_Hat_Enterprise_Linux#Version_history 
           // https://wiki.ubuntu.com/Releases
           // https://en.wikipedia.org/wiki/Debian_version_history
           
           
           WITH
                [{name:"RHEL",versions:["7.1","7.2","7.3"]},{name:"Ubuntu",versions:["14.04","16.04","16.10","17.04"]},{name:"Debian",versions:["6-Squeeze","7-Wheezy","8-Jessie"]}] as osNames,
                [
                 {name:"java",versions:["8"]},
                 {name:"neo4j",ports:[7474,7473,7687],versions:["3.0","3.1"],dependencies:["java/8"]},
                 {name:"postgres",ports:[5432],versions:["9.4","9.5","9.6"]},
                 {name:"couchbase",ports:[8091,8092,11207,11209,11210,11211,11214,11215,18091,18092,4369],versions:["3.0","4.0","4.5","4.6"]},
                 {name:"elasticsearch",ports:[9200,9300,9500,9700],versions:["2.4","5.0","5.1","5.2"],dependencies:["java/8"]}
                ] as services,
                [{name:"webserver",ports:[80,443],dependencies:["postgres/9.4"]},
                 {name:"crm",ports:[80,443],dependencies:["java/8","neo4j/3.1"]},
                 {name:"cms",ports:[8080],dependencies:["php","webserver","couchbase"]},
                 {name:"webapp",ports:[8080],dependencies:["java","neo4j"]},
                 {name:"logstash",ports:[5000],dependencies:["elasticsearch/5.2"]}
                ] as applications
           
           UNWIND osNames + services + applications AS sw
           
           CREATE (s:Software) SET s = sw
           FOREACH (sw in filter(x IN osNames where x.name = sw.name) | SET s:OS)
           FOREACH (sw in filter(x IN services where x.name = sw.name) | SET s:Service)
           FOREACH (sw in filter(x IN applications where x.name = sw.name) | SET s:Application)
           
           FOREACH (idx in range(0,size(coalesce(sw.versions,[]))-2) | 
             MERGE (s)-[:VERSION]->(v0:Version {name:sw.versions[idx]})
             MERGE (s)-[:VERSION]->(v:Version {name:sw.versions[idx+1]})
             MERGE (v0)<-[:PREVIOUS]-(v)
           )
           WITH *
           UNWIND sw.dependencies as dep
           WITH *,split(dep,"/") as parts
           MERGE (d:Software {name:parts[0]})
           FOREACH (v IN case size(parts) when 1 then [] else [parts[1]] end |
              MERGE (d)-[:VERSION]->(:Version {name:v})
           )
           WITH *
           OPTIONAL MATCH (d)-[:VERSION]->(v:Version {name:parts[1]})
           WITH s, coalesce(v,d) as d
           MERGE (s)-[:DEPENDS_ON]->(d);
    0 rows available after 3500 ms, consumed after another 0 ms
    Added 38 nodes, Created 51 relationships, Set 62 properties, Added 51 labels
    neo4j> 
    neo4j> 
    neo4j> // Install Software
           
           create index on :Software(name);
    0 rows available after 494 ms, consumed after another 0 ms
    Added 1 indexes
    neo4j> 
    neo4j> WITH [(:Software:OS)-[:VERSION]->(v) | v] as osVersions
           MATCH (a:Application:Software)
           WITH osVersions, collect(a) as apps
           MATCH (m:Machine)-[:ROUTES]->(i:Interface)
           WITH m,i, osVersions[toInt(rand()*size(osVersions))] as os, apps[toInteger(rand()*size(apps))] as app
           CREATE (m)-[:RUNS]->(op:OS:Process {name:os.name, startTime:timestamp() - toInteger( (rand() * 10 + 5) *24*3600*1000)})-[:INSTANCE]->(os)
           CREATE (m)-[:RUNS]->(ap:Application:Process {name: app.name, pid: toInt(rand()*10000), startTime:timestamp() - toInteger(rand() * 10*24*3600*1000) })-[:INSTANCE]->(app)
           
           FOREACH (portNo in app.ports |
              MERGE (port:Port {port:portNo})<-[:EXPOSES]-(i)
              CREATE (ap)-[:LISTENS]->(port)
           )
           WITH *
           MATCH (app)-[:DEPENDS_ON]->(dep)
           CREATE (m)-[:RUNS]->(dp:Service:Process {name: dep.name, pid: toInt(rand()*10000), startTime:timestamp() - toInteger(rand() * 10*24*3600*1000) })-[:INSTANCE]->(dep)
           CREATE (ap)-[:DEPENDS_ON]->(dp)
           FOREACH (portNo in dep.ports |
              MERGE (port:Port {port:portNo})<-[:EXPOSES]-(i)
              CREATE (dp)-[:LISTENS]->(port)
           );

      创建完成后的信息提示如下图 

     

    There is not enough memory to perform the current task.
    Please try increasing 'dbms.memory.heap.max_size' in the neo4j configuration (normally in 'conf/neo4j.conf' or,
    if you you are using Neo4j Desktop, found through the user interface)
    or if you are running an embedded installation increase the heap by using '-Xmx' command line flag,
    and then restart the database.

       

      为此,我按: exit退出,进行内存大小调整。

     

      我这里,自行调整内存大小来试试,比如。改为2G吧,来试试!

     

    dbms.memory.heap.max_size=2g

     

    查看导入到Neo4j数据库后的沙盒数据之network-management
      启动 Neo4j 

    root@zhouls-virtual-machine:/usr/local/app/neo4j-community-3.2.0/bin#  ./neo4j console 
    
    

      在浏览器中打开:http://localhost:7474/ 进入 Neo4j 的 web 界面, 
      点击左上角的数据库图标就会显示刚才导入的数据节点标签、关系等信息。

      在命令行中输入:play http://localhost:8001/会显示在第 4 步中显示的介绍说明信息,这时可以按照说明信息查看操作。 

       成功!

  • 相关阅读:
    关于IE6不能兼容LCUC使用的PNG透明图象
    rmvb压制中高级技巧
    不错的课件网站
    C#程序多用户只启动一个进程的方法
    不可想像的加密光盘复制工具
    检测远程URL是否存在的三种方法
    请哪里有英文单词单复数转换的代码?
    一些感想,欢迎拍砖
    Some thoughts on my own O/R Mapping or Code Generation tools
    有了net send,谁还用IM?
  • 原文地址:https://www.cnblogs.com/zlslch/p/6936905.html
Copyright © 2020-2023  润新知