共計 3971 個字符,預計需要花費 10 分鐘才能閱讀完成。
這篇文章主要介紹 Nebula Graph 如何安裝部署,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
Nebula Graph:一個開源的分布式圖數據庫。作為唯一能夠存儲萬億個帶屬性的節點和邊的在線圖數據庫,Nebula Graph 不僅能夠在高并發場景下滿足毫秒級的低時延查詢要求,還能夠實現服務高可用且保障數據安全性。
簡介
Nebula Graph 是開源的第三代分布式圖數據庫,不僅能夠存儲萬億個帶屬性的節點和邊,而且還能在高并發場景下滿足毫秒級的低時延查詢要求。不同于 Gremlin 和 Cypher,Nebula 提供了一種 SQL-LIKE 的查詢語言
nGQL,通過三種組合方式(管道、分號和變量)完成對圖的 CRUD 的操作。在存儲層 Nebula Graph 目前支持
RocksDB 和
HBase 兩種方式。
感謝 Nebula Graph 社區 Committer 伊興路供稿本文。
Nebula Graph 整體架構
Nebula Graph 主要有三個服務進程:
Meta Service
Meta Service 是整個集群的元數據管理中心,采用 Raft 協議保證高可用。主要提供兩個功能:
管理各種元信息,比如 Schema
指揮存儲擴容和數據遷移
Storage Service
Storage Service 負責 Graph 數據存儲。圖數據被切分成很多的分片 Partition,相同 ID 的 Partition 組成一個 Raft Group,實現多副本一致性。Nebula Graph 默認的存儲引擎是 RocksDB 的 Key-Value 存儲。
Graph Service
Graph Service 位于架構中的計算層,負責同 Console 等 Client 通信,解析 nGQL 的請求并生成執行計劃。執行計劃經過優化器優化之后,交與執行引擎執行。執行引擎會向 MetaService 請求點邊的 Schema 和向存儲引擎獲取點邊的數據。
GraphService 是個無狀態的服務,可以無限的水平拓展,并且計算層的執行計劃最終會下發到數據節點執行。
安裝部署
Nebula Graph 提供兩種部署方式:單機和集群。單機部署主要用于測試和體驗使用,生產場景推薦集群方式。
單機運行
在單機上實踐或者測試 Nebula Graph 的最好方式是通過
Docker 容器運行,參照
文檔拉取鏡像,并進入容器:
$ docker pull vesoft/nebula-graph:latest
$ docker run --rm -ti vesoft/nebula-graph:latest bash
進入容器之后首先啟動 Nebula 的所有 Services,再通過 Console 客戶端連接本容器內部的
graphd 服務來執行 nGQL 語句
$ cd /usr/local/nebula
$ ./scripts/nebula.service start all
$ ./bin/nebula -u user -p password
(user@127.0.0.1) [(none)] SHOW HOSTS;
===============================
| Ip | Port | Status |
===============================
| 172.17.0.2 | 44500 | online |
-------------------------------
Got 1 rows (Time spent: 15621/16775 us)
集群部署環境準備
Nebula 支持編譯安裝和通過打包好的 Package 安裝。由于 Nebula 依賴較多,簡便起見推薦使用安裝包安裝。
本文準備了 3 臺裝有 CentOS 7.5 系統的機器,IP 如下所示:
192.168.8.14 # cluster-14
192.168.8.15 # cluster-15
192.168.8.16 # cluster-16
在每臺機器上下載對應的
安裝包:
$ wget -O nebula-1.0.0-beta.el7-5.x86_64.rpm https://github.com/vesoft-inc/nebula/releases/download/v1.0.0-beta/nebula-1.0.0-beta.el7-5.x86_64.rpm
此外由于 Nebula 的服務之間通信需要開放一些端口,所以可以臨時關掉所有機器上的防火墻: (具體使用端口見
/usr/local/nebula/etc/ 下面的配置文件 )
$ systemctl disable firewalld
本文將按如下的方式部署 Nebula 的集群:
- cluster-14: metad/storaged/graphd
- cluster-15: metad/storaged
- cluster-16: metad/storaged
安裝
使用 rpm 安裝上步準備好的安裝包
$ rpm -ivh nebula-*.rpm
Nebula 默認的安裝目錄位于
/usr/local/nebula
配置
Nebula 的所有配置文件都位于
/usr/local/nebula/etc 目錄下,并且提供了三份默認配置。分別編輯這些配置文件:
第一份配置文件:nebula-metad.conf
metad 通過 raft 協議保證高可用,需要為每個 metad 的 service 都配置該服務部署的機器 ip 和端口。主要涉及
meta_server_addrs 和
local_ip 兩個字段,其他使用默認配置。
cluster-14 上的兩項配置示例如下所示:
# Peers
--meta_server_addrs=192.168.8.14:45500,192.168.8.15:45500,192.168.8.16:45500
# Local ip
--local_ip=192.168.8.14
# Meta daemon listening port
--port=45500
第二份配置文件:nebula-graphd.conf
graphd 運行時需要從 metad 中獲取 schema 數據,所以在配置中必須顯示指定集群中 metad 的 ip 地址和端口選項
meta_server_addrs,其他使用默認配置。
cluster-14 上的 graphd 配置如下:
# Meta Server Address
--meta_server_addrs=192.168.8.14:45500,192.168.8.15:45500,192.168.8.16:45500
第三份配置文件:nebula-storaged.conf
storaged 也是使用的 raft 協議保證高可用,在數據遷移時會與 metad 通信,所以需要配置 metad 的地址和端口
meta_server_addrs 和本機地址
local_ip,其 peers 可以通過 metad 獲得。
cluster-14 上的部分配置選項如下:
# Meta server address
--meta_server_addrs=192.168.8.14:45500,192.168.8.15:45500,192.168.8.16:45500
# Local ip
--local_ip=192.168.8.14
# Storage daemon listening port
--port=44500
啟動集群
cluster-14
$ /usr/local/nebula/scripts/nebula.service start all
[INFO] Starting nebula-metad...
[INFO] Done
[INFO] Starting nebula-graphd...
[INFO] Done
[INFO] Starting nebula-storaged...
[INFO] Done
cluster-15/cluster-16
$ /usr/local/nebula/scripts/nebula.service start metad
[INFO] Starting nebula-metad...
[INFO] Done
$ /usr/local/nebula/scripts/nebula.service start storaged
[INFO] Starting nebula-storaged...
[INFO] Done
注:部分用戶可能會遇到
[WARN] The maximum files allowed to open might be too few: 1024
可以自己修改
/etc/security/limits.conf
測試集群
登陸集群中的一臺,執行如下命令:
$ /usr/local/nebula/bin/nebula -u user -p password --addr 192.168.8.14 --port 3699
(user@192.168.8.14) [(none)] SHOW HOSTS;
==================================
| Ip | Port | Status |
==================================
| 192.168.8.14 | 44500 | offline |
----------------------------------
Got 1 rows (Time spent: 3511/4024 us)
以上是“Nebula Graph 如何安裝部署”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注丸趣 TV 行業資訊頻道!