图数据库HugeGraph

HugeGraph下载

进入https://hugegraph.github.io/hugegraph-doc/download.html,选择当前(2019-02-09)HugeGraph-Server的最新版本

最好将HugeGraph-Studio也下载了,它提供了基于Web的可视化工具,类似于Neo4j Browser,非常方便

HugeGraph的安装

注:安装环境为CentOS7,且已安装好JDK1.8.

先将安装包上传到用户根目录下,然后解压:

[root@centos7 ~]$ tar zxf hugegraph-0.8.0.tar.gz

[root@centos7 ~]$ tar zxf hugegraph-studio-0.8.0.tar.gz

初始化数据库

注:只需要执行一次。

HugeGraph支持多种后端,默认采用rocksdb。rocksdb是Facebook开源的一款嵌入式可持久化的key-value数据库。详细请参考:https://rocksdb.org/

 

[root@centos7 hugegraph-0.8.0]$ bin/init-store.sh

修改HugeGraph-Server可供外部访问调用api

[root@centos7 conf]# vim computer.yaml

 hugegraph_url: "http://192.168.60.109:8080",#修改这行为你的服务器ip

[root@centos7 conf]# vim rest-server.properties

restserver.url=http://192.168.60.109:8080 # 修改这行为你服务器ip,restserver为8182端口,与你的hugegraph8080端口是绑定的,只修改上面是不行的

启动HugeGraph-Server

[root@centos7 hugegraph-0.8.0]$ bin/start-hugegraph.sh

启动HugeGraph-Studio

修改配置文件:hugegraph-studio.properties。这里要注意host端口必须都是配置本机的ip(服务器的ip地址),不要使用localhost或者127.0.0.1,否则只能本地访问,外网无法访问。

复制代码
[root@cdh1 conf]# pwd
/HugeGraph/hugegraph-studio-0.11.0/conf
[root@cdh1 conf]# ll
total 8
-rw-r--r-- 1 xxli 20 1825 Sep 10 16:08 hugegraph-studio.properties
-rwxr-xr-x 1 xxli 20 1488 May  7 17:23 log4j2.xml

[root@cdh1 conf]# vim hugegraph-studio.properties

# 下面是vim打开之后的部分结果展示:

studio.server.port=8088  # studio提供外部访问的端口
studio.server.host=192.168.60.109  

graph.server.host=localhost
graph.server.port=8080  # 需要和HugeGraph中的配置文件rest-server.properties 端口保持一致,是HugeGraph提供服务的端口。
graph.name=hugegraph

client.timeout=30
复制代码

修改完上述配置后,即可启动 HugeGraphStudio:

$ bin/hugegraph-studio.sh

注意:如果启动HugeGraphStudio失败,可能设置的端口已经被使用,可以使用别的空闲端口或者将在用的端口停用,然后再试试重新启动。

$ netstat -nlutp    # (查看所有在使用的端口)
$ kill 1818         # (停掉使用端口的进程,1818为对应的编号) 

安装hubble(最新版前端可视化工具,Studio已不再维护

tar -xvzf hugegraph-hubble-1.5.0.tar.gz

./bin/start-hubble.sh

hubble默认在8088端口,确认该端口没被占用,访问http://服务器地址:8088/,第一次访问会需要创建图,按提示填写表单完成创建即可

 

创建schema

HugeGraph默认不支持自动创建schema(这点和JanusGraph不同),因此,创建图数据之前需要先创建对应的schema。

 

创建属性类型(PropertyKey)

graph.schema().propertyKey("name").asText().ifNotExist().create()

graph.schema().propertyKey("city").asText().ifNotExist().create()

graph.schema().propertyKey("date").asText().ifNotExist().create()

 

创建顶点类型(VertexLabel)

这里创建一个顶点类型person,如下:

graph.schema().vertexLabel("person").properties("name", "city").primaryKeys("name").ifNotExist().create()

 

创建边类型(EdgeLabel)

graph.schema().edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("date").ifNotExist().create()

 

创建顶点和边

dennis = graph.addVertex(T.label, "person", "name", "Dennis","city", "Chengdu")

jady = graph.addVertex(T.label, "person", "name", "Jady","city", "Beijing")

dennis.addEdge("knows", jady, "date", "20121201")

 参考:https://www.jianshu.com/p/618cf6667381

gremlin语句教程:https://blog.csdn.net/javeme/article/details/82631834

posted on   不要挡着我晒太阳  阅读(745)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示