圖資料庫HugeGraph:HugeGraph-Hubble基於Web的視覺化圖管理初體驗

朱季謙發表於2021-12-16

原創/朱季謙

一、HugeGraph-Hubble簡介

關於HugeGraph,官方資料是這樣介紹的,它是一款易用、高效、通用的開源圖資料庫系統(Graph Database), 實現了 Apache TinkerPop3 框架及完全相容 Gremlin 查詢語言, 具備完善的工具鏈元件,助力使用者輕鬆構建基於圖資料庫之上的應用和產品。HugeGraph 支援百億以上的頂點和邊快速匯入,並提供毫秒級的關聯關係查詢能力(OLTP), 並可與 Hadoop、Spark 等大資料平臺整合以進行離線分析(OLAP)。

HugeGraph與其他圖資料庫系統一樣都提供了一套前端展示工具。HugeGraph在0.10 server 版本之前,是通過HugeGraph-Studio提供的前端展示工具,只有一個頁面用於來實現簡單圖操作。

image

在HugeGraph在0.10 server 版本之後,百度HugeGraph開始支援一套全新的Web圖管理介面HugeGraph-Hubble,其功能相比之前的HugeGraph-Studio,可以說更加豐富,可以實現圖管理、後設資料建模、資料匯入、圖分析以及跑批操作,對於想要學習HugeGraph的同學,可以起到更好的幫助。

image

官網上,關於HugeGraph-Hubble是這樣介紹的:HugeGraph-Hubble是HugeGraph的一站式視覺化分析平臺,平臺涵蓋了從資料建模,到資料快速匯入,再到資料的線上、離線分析、以及圖的統一管理的全過程,實現了圖應用的全流程嚮導式操作,旨在提升使用者的使用流暢度,降低使用者的使用門檻,提供更為高效易用的使用體驗。

相關的具體介紹,可以跳轉至HugeGraph-Hubble官網詳情——

很遺憾是,官網上並沒有很詳細地介紹如何搭建HugeGraph-Hubble整合到HugeGraph-Server中,我是根據之前的linux環境安裝可操作相簿語言Gremlin的圖框架HugeGraph一文的搭建經驗,來重新搭建HugeGraph-Hubble。


二、環境安裝依賴版本

首先,是環境依賴,我選擇的hadoop、hbase、hugegraph、hugegraph-hubble版本分別是——

hadoop hbase hugegraph hugegraph-hubble
2.7.5 2.1.0 0.11.2 1.5.0

三、hugegraph服務部署檔案引數

具體如何安裝配置hugegraph的server端,請移步至我之前0.10.4版本的linux環境安裝可操作相簿語言Gremlin的圖框架HugeGraph一文,整體相差不大,主要就修hugegraph安裝目錄裡的hugegraph.properties和rest-server.properties兩個檔案。

1、hugegraph.properties檔案主要修改引數——

//圖服務ip埠
restserver.url=http://192.168.200.153:8099
graphs=[hugegraph:conf/hugegraph.properties]
server.id=server-1
server.role=master

這裡需要注意一點,該圖服務埠http://192.168.200.153:8099將在後面的hugegraph-hubble進行圖建立時用到。

2、hugegraph整合hbase2.1.0儲存配置方式如下——

hbase需要求版本 在2.0 以上,修改hugegraph.properties以下引數:

//hbase持久化儲存
backend=hbase
//後端儲存的序列化程式,可用值為[text、binary、cassandra、hbase、mysql],選hbase就用hbase
serializer=hbase
//hbase連線的zookeeper叢集連線
hbase.hosts=192.168.200.130,192.168.200.131,192.168.200.132
//hbase連線的zookeeper介面
hbase.port=2181
//儲存庫名
store=hugegraph

其中,hbase.hosts與hbase.port的引數是對應了hbase設定zookeeper註冊中心的引數,hbase的zookeeper叢集配置在hbase-2.1.0/conf/hbase-site.xml檔案裡,我的是——

<configuration>
   ......
   <property>
      <name>hbase.master</name>
      <value>master1</value>
   </property>
   <property>
      <name>hbase.zookeeper.quorum</name>
      <value>192.168.200.130:2181,192.168.200.131:2181,192.168.200.132:2181</value>
   </property>
   ......
</configuration>

而hbase的master預設埠是16000,當hugeGraph這樣配置hbase如以下的hosts和post引數後,它起到作用是,會到zookeeper叢集註冊中心的/hbase/master節點處獲取需要連線的hbase的master地址,進而連線hbase,我的hbase的master是放在192.168.200.150機器上。

hbase.hosts=192.168.200.130,192.168.200.131,192.168.200.132
//hbase連線的zookeeper介面
hbase.port=2181

可以稍微驗證一下,假如我啟動了zookeeper叢集,但是沒有啟動hbase叢集,那麼當hugeGraph啟動進行資料操作時,會出現以下異常——

org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /hbase/master, details=, see https://s.apache.org/timeout

其中KeeperErrorCode = NoNode for /hbase/master,說明zookeeper沒有/hbase/master這個節點,那就以為著,hugeGraph持久化連線到zookeeper,獲取儲存到/hbase/master的資料,那麼,該資料是什麼呢?

很遺憾,我這邊直接通過zookeeper客戶端去看,出現了亂碼,但其他地方的中文又是正常的,因此,我懷疑,該節點資料估計是做了序列化,導致無法看到正常資料......

[zk: localhost:2181(CONNECTED) 21] get /hbase/master
�master:16000�o]7��#PBUF

master1�}�����/��
cZxid = 0x10000032a
ctime = Thu Dec 16 07:50:34 CST 2021
mZxid = 0x10000032a
mtime = Thu Dec 16 07:50:34 CST 2021
pZxid = 0x10000032a
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x27db96bfb240022
dataLength = 56
numChildren = 0

可以換一種方式驗證,我在啟動hbase過程中,操作hugeGraph,然後看hugeGraph日誌,這時已經可以連線到zookeeper了,但出現以下日誌——

2021-12-16 07:49:53 3324377514 [grizzly-http-server-3] [WARN ] org.apache.hadoop.hbase.client.ConnectionImplementation [] - Checking master connection
org.apache.hadoop.hbase.ipc.FailedServerException: Call to master1/192.168.200.150:16000 failed on local exception: org.apache.hadoop.hbase.ipc.FailedServerException: This server is in the failed servers list: master1/192.168.200.150:16000

其中,This server is in the failed servers list: master1/192.168.200.150:16000,說明最後hugeGraph是通過zookeeper拿到了hbase的master地址master1/192.168.200.150:16000,然後去連線hbase,但hbase正在啟動中,故而還連線不到,後面有一條日誌是連線到,但hbase的master正在啟動的提示——

org.apache.hadoop.hbase.client.RpcRetryingCallerImpl [] - Call exception, tries=10, retries=16, started=58047 ms ago, cancelled=false, msg=org.apache.hadoop.hbase.PleaseHoldException: Master is initializing

以上,就是配置hbase做hugeGraph持久化資料層的方式及原理。


四、hugegraph與hugegraph-hubble啟動服務

配置完後,就可以啟動hugeGraph了——(這裡需要注意,首次啟動,需要進行初始化,初始化指令為bin/init-store.sh,執行完後,再進行服務啟動)

[root@slave2 bin]# ./start-hugegraph.sh 
Starting HugeGraphServer...
Connecting to HugeGraphServer (http://192.168.200.153:8099/graphs).OK
Started [pid 39235]

當HugeGraphServer服務成功啟動後,就可以開始安裝啟動web圖管理介面 hugegraph-hubble1.5.0了。

上傳至虛擬機器,解壓,進入到/hugegraph-hubble-1.5.0/conf目錄,修改hugegraph-hubble.properties檔案,我修改後的引數主要為以下——

//允許本機與本機之外的機器訪問
server.host=0.0.0.0
//圖管理頁面埠
server.port=8088

gremlin.suffix_limit=250
//頂點預設查詢數量
gremlin.vertex_degree_limit=100
//邊預設查詢數量
gremlin.edges_total_limit=500

gremlin.batch_query_ids=100

配置完成後,啟動hugegraph-hubble——

[root@slave2 bin]# ./start-hubble.sh 
starting HugeGraphHubble....OK
logging to /app/hugegraph-hubble-1.5.0/logs/hugegraph-hubble.log

完成後,瀏覽器上訪問http://192.168.200.153:8088/

image

截圖裡,我已經建立了一個圖,社群版本允許最大建立三個圖。

平臺的模組使用流程如下:

image

建立圖的方式很簡單,直接點選建立圖,彈出框上填入相關伺服器配置資訊即可,可參考我已經配置好的——

image

這裡主機名和埠號的引數需根據hugegraph.properties配置的ip與埠進行設定。

建立完成後,就可進入到圖管理頁面了——
image
我將在下一篇文章當中,分享如何居於hugegraph-hubble圖管理進行圖例項設計與圖分析。

相關文章