圖數(shù)據(jù)庫 Nebula Graph 的安裝部署

Nebula Graph:一個開源的分布式圖數(shù)據(jù)庫。作為唯一能夠存儲萬億個帶屬性的節(jié)點和邊的在線圖數(shù)據(jù)庫,Nebula Graph 不僅能夠在高并發(fā)場景下滿足毫秒級的低時延查詢要求,還能夠?qū)崿F(xiàn)服務高可用且保障數(shù)據(jù)安全性。

本文目錄

  1. 簡介
  2. Nebula 整體架構
    1. Meta Service
    2. Storage Service
    3. Graph Service
  3. 安裝部署
    1. 單機運行
    2. 集群部署
      1. 環(huán)境準備
      2. 安裝
      3. 配置
    3. 測試集群

簡介

Nebula Graph 是開源的第三代分布式圖數(shù)據(jù)庫,不僅能夠存儲萬億個帶屬性的節(jié)點和邊,而且還能在高并發(fā)場景下滿足毫秒級的低時延查詢要求。不同于 Gremlin 和 Cypher,Nebula 提供了一種 SQL-LIKE 的查詢語言 nGQL,通過三種組合方式(管道、分號變量)完成對圖的 CRUD 的操作。在存儲層 Nebula Graph 目前支持 RocksDBHBase 兩種方式。

感謝 Nebula Graph 社區(qū) Committer 伊興路供稿本文。

Nebula Graph整體架構

image.png

Nebula Graph 主要有三個服務進程:

Meta Service

Meta Service 是整個集群的元數(shù)據(jù)管理中心,采用 Raft 協(xié)議保證高可用。主要提供兩個功能:

  1. 管理各種元信息,比如 Schema
  2. 指揮存儲擴容和數(shù)據(jù)遷移

Storage Service

image.png

Storage Service 負責 Graph 數(shù)據(jù)存儲。圖數(shù)據(jù)被切分成很多的分片 Partition,相同 ID 的 Partition 組成一個 Raft Group,實現(xiàn)多副本一致性。Nebula Graph 默認的存儲引擎是 RocksDB 的 Key-Value 存儲。

Graph Service

Graph Service 位于架構中的計算層,負責同 Console 等 Client 通信,解析 nGQL 的請求并生成執(zhí)行計劃。執(zhí)行計劃經(jīng)過優(yōu)化器優(yōu)化之后,交與執(zhí)行引擎執(zhí)行。執(zhí)行引擎會向 MetaService 請求點邊的 Schema 和向存儲引擎獲取點邊的數(shù)據(jù)。

GraphService 是個無狀態(tài)的服務,可以無限的水平拓展,并且計算層的執(zhí)行計劃最終會下發(fā)到數(shù)據(jù)節(jié)點執(zhí)行。

安裝部署

Nebula Graph 提供兩種部署方式:單機集群。單機部署主要用于測試和體驗使用,生產(chǎn)場景推薦集群方式。

單機運行

在單機上實踐或者測試 Nebula Graph 的最好方式是通過 Docker 容器運行,參照文檔拉取鏡像,并進入容器:

    $ docker pull vesoft/nebula-graph:latest
    $ docker run --rm -ti vesoft/nebula-graph:latest bash

進入容器之后首先啟動 Nebula 的所有 Services,再通過 Console 客戶端連接本容器內(nèi)部的 graphd 服務來執(zhí)行 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)

集群部署

環(huán)境準備

Nebula 支持編譯安裝和通過打包好的 Package 安裝。由于 Nebula 依賴較多,簡便起見推薦使用安裝包安裝。

本文準備了 3 臺裝有 CentOS 7.5 系統(tǒng)的機器,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 協(xié)議保證高可用,需要為每個 metad 的 service 都配置該服務部署的機器 ip 和端口。主要涉及 meta_server_addrslocal_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 數(shù)據(jù),所以在配置中必須顯示指定集群中 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 協(xié)議保證高可用,在數(shù)據(jù)遷移時會與 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

測試集群

登陸集群中的一臺,執(zhí)行如下命令:

    $ /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:一個開源的分布式圖數(shù)據(jù)庫。

GitHub:https://github.com/vesoft-inc/nebula

官方博客:https://nebula-graph.io/cn/posts/

微博:https://weibo.com/nebulagraph

image
最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容