圖資料庫 Nebula Graph 的安裝部署

nebulagraph發表於2019-10-31

Nebula Graph:一個開源的分散式圖資料庫。作為唯一能夠儲存萬億個帶屬性的節點和邊的線上圖資料庫,Nebula Graph 不僅能夠在高併發場景下滿足毫秒級的低時延查詢要求,還能夠實現服務高可用且保障資料安全性。

本文目錄

  1. 簡介
  2. Nebula 整體架構
    1. Meta Service
    2. Storage Service
    3. Graph Service
  3. 安裝部署
    1. 單機執行
    2. 叢集部署
      1. 環境準備
      2. 安裝
      3. 配置
    3. 測試叢集

簡介

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

感謝 Nebula Graph 社群 Committer 伊興路供稿本文。

Nebula Graph整體架構

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

Meta Service

Meta Service 是整個叢集的後設資料管理中心,採用 Raft 協議保證高可用。主要提供兩個功能:

  1. 管理各種元資訊,比如 Schema
  2. 指揮儲存擴容和資料遷移

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_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 資料,所以在配置中必須顯示指定叢集中 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:一個開源的分散式圖資料庫。

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

知乎: https://www.zhihu.com/org/nebulagraph/posts

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69952037/viewspace-2662046/,如需轉載,請註明出處,否則將追究法律責任。

相關文章