原創/朱季謙
一、HugeGraph-Hubble簡介
關於HugeGraph,官方資料是這樣介紹的,它是一款易用、高效、通用的開源圖數據庫系統(Graph Database), 實現了 Apache TinkerPop3 框架及完全兼容 Gremlin 查詢語言, 具備完善的工具鏈組件,助力用戶輕松構建基於圖數據庫之上的應用和產品。HugeGraph 支持百億以上的頂點和邊快速導入,並提供毫秒級的關聯關系查詢能力(OLTP), 並可與 Hadoop、Spark 等大數據平台集成以進行離線分析(OLAP)。HugeGraph與其他圖數據庫系統一樣都提供了一套前端展示工具。HugeGraph在0.10 server 版本之前,是通過HugeGraph-Studio提供的前端展示工具,只有一個頁面用於來實現簡單圖操作。
在HugeGraph在0.10 server 版本之后,百度HugeGraph開始支持一套全新的Web圖管理界面HugeGraph-Hubble,其功能相比之前的HugeGraph-Studio,可以說更加豐富,可以實現圖管理、元數據建模、數據導入、圖分析以及跑批操作,對於想要學習HugeGraph的同學,可以起到更好的幫助。
官網上,關於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、rest-server.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配置持久化
本文主要介紹Hbase做持久化與MySql做持久化——
2.1、Hbase持久化設置
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持久化數據層的方式及原理。
2.2、MySql做持久化配置——
hugegraph.properties增加以下配置即可——
backend=mysql
serializer=mysql
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306
jdbc.username=root
jdbc.password=root
jdbc.storage_engine=InnoDB
四、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/
截圖里,我已經創建了一個圖,社區版本允許最大創建三個圖。
平台的模塊使用流程如下:
創建圖的方式很簡單,直接點擊創建圖,彈出框上填入相關服務器配置信息即可,可參考我已經配置好的——
這里主機名和端口號的參數需根據hugegraph.properties配置的ip與端口進行設置。
創建完成后,就可進入到圖管理頁面了——
我將在下一篇文章當中,分享如何居於hugegraph-hubble圖管理進行圖實例設計與圖分析。