圖數據庫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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM