HugeGraph

HugeGraph是一款易用、高效、通用的开源图数据库系统,实现了Apache TinkerPop3框架,完全兼容 Gremlin 查询语言,具备完善的工具链组件。支持百亿以上的顶点和边快速导入,并提供毫秒级的关联关系查询能力(OLTP),并可与Hadoop、Spark等大数据平台集成以进行离线分析(OLAP)。

Gremlin是Apache TinkerPop的图遍历语言,相当于关系型数据库的SQL。

HugeGraph的安装部署

在Linux服务器上部署HugeGraph,需要有JDK环境。

首先部署HugeGraph:

  1. 安装JDK,并配置环境变量
    1. rpm -ivh jdk-8u181-linux-x64.rpm


安装后的路径为:/usr/java/jdk1.8.0_181-amd64

  1. 到 GitHub 上下载HugeGraph的发行包:hugegraph-0.11.2-b3.tar.gz

  2. 将压缩包上传到服务器,解压

  3. 根据需要,修改 conf/rest-server.properties 配置文件 ```properties

    bind url

    restserver.url=http://127.0.0.1:8080

    gremlin server url, need to be consistent with host and port in gremlin-server.yaml

    gremlinserver.url=http://127.0.0.1:8182

graphs list with pair NAME:CONF_PATH

graphs=[hugegraph:conf/hugegraph.properties]

authentication

auth.authenticator=

auth.admin_token=

auth.user_tokens=[]

server.id=server-1 server.role=master

  1. 5.
  2. 启动服务之前需要先手动初始化后端
  3. ```sh
  4. bin/init-store.sh
  1. 启动服务
    1. bin/start-hugegraph.sh
  1. 启动之后可以验证是否启动成功 ```sh

    查看是否有 HugeGraphServer进程

    jps

访问http服务

curl http://127.0.0.1:8080/graphs

  1. 在服务器部署HugeGraphStudio
  2. 1.
  3. GitHub下载HugeGraphStudio发行包:[hugegraph-studio-0.11.0.tar.gz](https://github.com/hugegraph/hugegraph-studio/releases/download/v0.11.0/hugegraph-studio-0.11.0.tar.gz)
  4. 2.
  5. 将压缩包上传到服务器,解压
  6. 3.
  7. 根据需要,修改 conf/huge-studio.properties 配置文件
  8. ```properties
  9. studio.server.port=8088
  10. # 此处需要将原来的localhost修改为具体的IP,否则其他电脑无法访问
  11. studio.server.host=192.168.29.146
  12. graph.server.host=localhost
  13. graph.server.port=8080
  14. graph.name=hugegraph
  15. client.timeout=30
  1. 启动hugegraph-studio
    1. # 该命令默认没有使用后台运行
    2. bin/hugegraph-studio.sh
  1. 使用浏览器访问hugegraph-studio验证:http://192.168.29.146:8088/

可以在hugegraph-studio中创建测试数据进行验证:

  1. // PropertyKey
  2. graph.schema().propertyKey("name").asText().ifNotExist().create()
  3. graph.schema().propertyKey("age").asInt().ifNotExist().create()
  4. graph.schema().propertyKey("addr").asText().ifNotExist().create()
  5. graph.schema().propertyKey("lang").asText().ifNotExist().create()
  6. graph.schema().propertyKey("tag").asText().ifNotExist().create()
  7. graph.schema().propertyKey("weight").asFloat().ifNotExist().create()
  8. // VertexLabel
  9. graph.schema().vertexLabel("person").properties("name", "age", "addr", "weight").useCustomizeStringId().ifNotExist().create()
  10. graph.schema().vertexLabel("software").properties("name", "lang", "tag", "weight").primaryKeys("name").ifNotExist().create()
  11. graph.schema().vertexLabel("language").properties("name", "lang", "weight").primaryKeys("name").ifNotExist().create()
  12. // EdgeLabel
  13. graph.schema().edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("weight").ifNotExist().create()
  14. graph.schema().edgeLabel("created").sourceLabel("person").targetLabel("software").properties("weight").ifNotExist().create()
  15. graph.schema().edgeLabel("contains").sourceLabel("software").targetLabel("software").properties("weight").ifNotExist().create()
  16. graph.schema().edgeLabel("define").sourceLabel("software").targetLabel("language").properties("weight").ifNotExist().create()
  17. graph.schema().edgeLabel("implements").sourceLabel("software").targetLabel("software").properties("weight").ifNotExist().create()
  18. graph.schema().edgeLabel("supports").sourceLabel("software").targetLabel("language").properties("weight").ifNotExist().create()
  19. // TinkerPop
  20. okram = graph.addVertex(T.label, "person", T.id, "okram", "name", "Marko A. Rodriguez", "age", 29, "addr", "Santa Fe, New Mexico", "weight", 1)
  21. spmallette = graph.addVertex(T.label, "person", T.id, "spmallette", "name", "Stephen Mallette", "age", 0, "addr", "", "weight", 1)
  22. tinkerpop = graph.addVertex(T.label, "software", "name", "TinkerPop", "lang", "java", "tag", "Graph computing framework", "weight", 1)
  23. tinkergraph = graph.addVertex(T.label, "software", "name", "TinkerGraph", "lang", "java", "tag", "In-memory property graph", "weight", 1)
  24. gremlin = graph.addVertex(T.label, "language", "name", "Gremlin", "lang", "groovy/python/javascript", "weight", 1)
  25. okram.addEdge("created", tinkerpop, "weight", 1)
  26. spmallette.addEdge("created", tinkerpop, "weight", 1)
  27. okram.addEdge("knows", spmallette, "weight", 1)
  28. tinkerpop.addEdge("define", gremlin, "weight", 1)
  29. tinkerpop.addEdge("contains", tinkergraph, "weight", 1)
  30. tinkergraph.addEdge("supports", gremlin, "weight", 1)
  31. // Titan
  32. dalaro = graph.addVertex(T.label, "person", T.id, "dalaro", "name", "Dan LaRocque ", "age", 0, "addr", "", "weight", 1)
  33. mbroecheler = graph.addVertex(T.label, "person", T.id, "mbroecheler", "name", "Matthias Broecheler", "age", 29, "addr", "San Francisco", "weight", 1)
  34. titan = graph.addVertex(T.label, "software", "name", "Titan", "lang", "java", "tag", "Graph Database", "weight", 1)
  35. dalaro.addEdge("created", titan, "weight", 1)
  36. mbroecheler.addEdge("created", titan, "weight", 1)
  37. okram.addEdge("created", titan, "weight", 1)
  38. dalaro.addEdge("knows", mbroecheler, "weight", 1)
  39. titan.addEdge("implements", tinkerpop, "weight", 1)
  40. titan.addEdge("supports", gremlin, "weight", 1)
  41. // HugeGraph
  42. javeme = graph.addVertex(T.label, "person", T.id, "javeme", "name", "Jermy Li", "age", 29, "addr", "Beijing", "weight", 1)
  43. zhoney = graph.addVertex(T.label, "person", T.id, "zhoney", "name", "Zhoney Zhang", "age", 29, "addr", "Beijing", "weight", 1)
  44. linary = graph.addVertex(T.label, "person", T.id, "linary", "name", "Linary Li", "age", 28, "addr", "Wuhan. Hubei", "weight", 1)
  45. hugegraph = graph.addVertex(T.label, "software", "name", "HugeGraph", "lang", "java", "tag", "Graph Database", "weight", 1)
  46. javeme.addEdge("created", hugegraph, "weight", 1)
  47. zhoney.addEdge("created", hugegraph, "weight", 1)
  48. linary.addEdge("created", hugegraph, "weight", 1)
  49. javeme.addEdge("knows", zhoney, "weight", 1)
  50. javeme.addEdge("knows", linary, "weight", 1)
  51. hugegraph.addEdge("implements", tinkerpop, "weight", 1)
  52. hugegraph.addEdge("supports", gremlin, "weight", 1)

查询顶点:

  1. g.V()