Docker搭建分布式图数据库nebula

简介: 被老大按着完成nebula分布式容器化部署。

大家好,我是脚丫先生 (o^^o)

最近在做数据融合分析平台。需要搭建一个分布式图数据库,第一想法就是面向百度和官网搜索,但是大多数只看到单节点搭建,分布式搭建都是基于k8s。自己不想那么把项目搞这么重,于是考利用docker-compose进行分布式搭建。下面进行阐述搭建过程,希望能帮助到大家。

在这里插入图片描述

一、图数据库nebula

Nebula Graph 是开源的第三代分布式图数据库,不仅能够存储万亿个带属性的节点和边,而且还能在高并发场景下满足毫秒级的低时延查询要求。不同于 Gremlin 和 Cypher,Nebula 提供了一种 SQL-LIKE 的查询语言 nGQL,通过三种组合方式(管道、分号和变量)完成对图的 CRUD 的操作。在存储层 Nebula Graph 目前支持 RocksDB 和 HBase 两种方式。

二、集群规划

主机名 IP Nebula服务
spark1 192.168.239.128 graphd0, metad-0, storaged-0
spark2 192.168.239.129 graphd1, metad-1, storaged-1
spark3 192.168.239.130 graphd2, metad-2, storaged-2

对于运维来说,之前搭建原生的环境,非常之麻烦,大部分时候搭建一个环境需要很多时间,而且交付项目,运维项目,都想把客户掐死。阿西吧

2.1 spark1节点的docker-compose

version: '3.4'
services:
  metad0:
    image: vesoft/nebula-metad:v2.0.0
    privileged: true
    network_mode: host
    environment:
      USER: root
      TZ:   "${TZ}"
    command:
      - --meta_server_addrs=192.168.239.128:9559,192.168.239.129:9559,192.168.239.129:9559
      - --local_ip=192.168.239.128
      - --ws_ip=0.0.0.0
      - --port=9559
      - --ws_http_port=19559
      - --data_path=/data/meta
      - --log_dir=/logs
      - --v=0
      - --minloglevel=0
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://192.168.239.128:19559/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - 9559
      - 19559
      - 19560
    volumes:
      - ./data/meta0:/data/meta
      - ./logs/meta0:/logs
    restart: on-failure
  
  storaged0:
    image: vesoft/nebula-storaged:v2.0.0
    privileged: true
    network_mode: host
    environment:
      USER: root
      TZ:   "${TZ}"
    command:
      - --meta_server_addrs=192.168.239.128:9559,192.168.239.129:9559,192.168.239.130:9559
      - --local_ip=192.168.239.128
      - --ws_ip=0.0.0.0
      - --port=9779
      - --ws_http_port=19779
      - --data_path=/data/storage
      - --log_dir=/logs
      - --v=0
      - --minloglevel=0
    depends_on:
      - metad0
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://192.168.239.128:19779/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - 9779
      - 19779
      - 19780
    volumes:
      - ./data/storage0:/data/storage
      - ./logs/storage0:/logs
    restart: on-failure

  graphd0:
    image: vesoft/nebula-graphd:v2.0.0
    privileged: true
    network_mode: host
    environment:
      USER: root
      TZ:   "${TZ}"
    command:
      - --meta_server_addrs=192.168.239.128:9559,192.168.239.129:9559,192.168.239.130:9559
      - --port=9669
      - --ws_ip=0.0.0.0
      - --ws_http_port=19669
      - --log_dir=/logs
      - --v=0
      - --minloglevel=0
    depends_on:
      - metad0
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://192.168.239.128:19669/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "9669:9669"
      - 19669
      - 19670
    volumes:
      - ./logs/graph:/logs
    restart: on-failure

注意:

  • 修改参数meta_server_addrs:

全部Meta服务的IP地址和端口。多个Meta服务用英文逗号(,)分隔

  • 修改参数local_ip:
    Meta服务的本地IP地址。本地IP地址用于识别nebula-metad进程,如果是分布式集群或需要远程访问,请修改为对应地址。

    • 默认参数ws_ip:

    HTTP服务的IP地址。预设值:0.0.0.0。

    2.2 spark2节点的docker-compose(配置与spark1同理)

version: '3.4'
services:
  metad1:
    image: vesoft/nebula-metad:v2.0.0
    privileged: true
    network_mode: host
    environment:
      USER: root
      TZ:   "${TZ}"
    command:
      - --meta_server_addrs=192.168.239.128:9559,192.168.239.129:9559,192.168.239.129:9559
      - --local_ip=192.168.239.129
      - --ws_ip=0.0.0.0
      - --port=9559
      - --ws_http_port=19559
      - --data_path=/data/meta
      - --log_dir=/logs
      - --v=0
      - --minloglevel=0
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://192.168.239.129:19559/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - 9559
      - 19559
      - 19560
    volumes:
      - ./data/meta1:/data/meta
      - ./logs/meta1:/logs
    restart: on-failure
  
  storaged1:
    image: vesoft/nebula-storaged:v2.0.0
    privileged: true
    network_mode: host
    environment:
      USER: root
      TZ:   "${TZ}"
    command:
      - --meta_server_addrs=192.168.239.128:9559,192.168.239.129:9559,192.168.239.130:9559
      - --local_ip=192.168.239.129
      - --ws_ip=0.0.0.0
      - --port=9779
      - --ws_http_port=19779
      - --data_path=/data/storage
      - --log_dir=/logs
      - --v=0
      - --minloglevel=0
    depends_on:
      - metad1
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://192.168.239.129:19779/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - 9779
      - 19779
      - 19780
    volumes:
      - ./data/storage1:/data/storage
      - ./logs/storage1:/logs
    restart: on-failure
  
  graphd1:
    image: vesoft/nebula-graphd:v2.0.0
    privileged: true
    network_mode: host
    environment:
      USER: root
      TZ:   "${TZ}"
    command:
      - --meta_server_addrs=192.168.239.128:9559,192.168.239.129:9559,192.168.239.130:9559
      - --port=9669
      - --ws_ip=0.0.0.0
      - --ws_http_port=19669
      - --log_dir=/logs
      - --v=0
      - --minloglevel=0
    depends_on:
      - metad1
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://192.168.239.129:19669/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "9669:9669"
      - 19669
      - 19670
    volumes:
      - ./logs/graph1:/logs
    restart: on-failure

2.3 spark3节点的docker-compose(配置与spark1同理)

version: '3.4'
services:
  metad2:
    image: vesoft/nebula-metad:v2.0.0
    privileged: true
    network_mode: host
    environment:
      USER: root
      TZ:   "${TZ}"
    command:
      - --meta_server_addrs=192.168.239.128:9559,192.168.239.129:9559,192.168.239.129:9559
      - --local_ip=192.168.239.130
      - --ws_ip=0.0.0.0
      - --port=9559
      - --ws_http_port=19559
      - --data_path=/data/meta
      - --log_dir=/logs
      - --v=0
      - --minloglevel=0
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://192.168.239.130:19559/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - 9559
      - 19559
      - 19560
    volumes:
      - ./data/meta3:/data/meta
      - ./logs/meta3:/logs
    restart: on-failure
  
  storaged2:
    image: vesoft/nebula-storaged:v2.0.0
    privileged: true
    network_mode: host
    environment:
      USER: root
      TZ:   "${TZ}"
    command:
      - --meta_server_addrs=192.168.239.128:9559,192.168.239.129:9559,192.168.239.130:9559
      - --local_ip=192.168.239.130
      - --ws_ip=192.168.239.130
      - --port=9779
      - --ws_http_port=19779
      - --data_path=/data/storage
      - --log_dir=/logs
      - --v=0
      - --minloglevel=0
    depends_on:
      - metad2
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://192.168.239.130:19779/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - 9779
      - 19779
      - 19780
    volumes:
      - ./data/storage3:/data/storage
      - ./logs/storage3:/logs
    restart: on-failure
  
  graphd2:
    image: vesoft/nebula-graphd:v2.0.0
    privileged: true
    network_mode: host
    environment:
      USER: root
      TZ:   "${TZ}"
    command:
      - --meta_server_addrs=192.168.239.128:9559,192.168.239.129:9559,192.168.239.130:9559
      - --port=9669
      - --ws_ip=0.0.0.0
      - --ws_http_port=19669
      - --log_dir=/logs
      - --v=0
      - --minloglevel=0
    depends_on:
      - metad2
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://192.168.239.128:19669/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "9669:9669"
      - 19669
      - 19670
    volumes:
      - ./logs/graph:/logs
    restart: on-failure

三、客户端

不说这么花里胡哨的,直接上docker-compose

version: '3.4'
services:
  client:
    image: vesoft/nebula-http-gateway:v2
    environment:
      USER: root
    ports:
      - 8080
    networks:
      - nebula-web
  web:
    image: vesoft/nebula-graph-studio:v2
    environment:
      USER: root
      UPLOAD_DIR: ${MAPPING_DOCKER_DIR}
    ports:
      - 7001
    depends_on:
      - client
    volumes:
      - ${UPLOAD_DIR}:${MAPPING_DOCKER_DIR}:rw
    networks:
      - nebula-web
  importer:
    image: vesoft/nebula-importer:v2
    networks:
      - nebula-web
    ports:
      - 5699
    volumes:
      - ${UPLOAD_DIR}:${MAPPING_DOCKER_DIR}:rw
    command:
      - "--port=5699"
      - "--callback=http://nginx:7001/api/import/finish"
  nginx:
    image: nginx:alpine
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/conf.d/nebula.conf
      - ${UPLOAD_DIR}:${MAPPING_DOCKER_DIR}:rw
    depends_on:
      - client
      - web
    networks:
      - nebula-web
    ports:
      - 7001:7001

networks:
  nebula-web:

谷歌浏览器访问web界面: http://192.168.239.128:7001
在这里插入图片描述

利用SHOW HOSTS;在这里插入图片描述

相关实践学习
阿里云图数据库GDB入门与应用
图数据库(Graph Database,简称GDB)是一种支持Property Graph图模型、用于处理高度连接数据查询与存储的实时、可靠的在线数据库服务。它支持Apache TinkerPop Gremlin查询语言,可以帮您快速构建基于高度连接的数据集的应用程序。GDB非常适合社交网络、欺诈检测、推荐引擎、实时图谱、网络/IT运营这类高度互连数据集的场景。 GDB由阿里云自主研发,具备如下优势: 标准图查询语言:支持属性图,高度兼容Gremlin图查询语言。 高度优化的自研引擎:高度优化的自研图计算层和存储层,云盘多副本保障数据超高可靠,支持ACID事务。 服务高可用:支持高可用实例,节点故障迅速转移,保障业务连续性。 易运维:提供备份恢复、自动升级、监控告警、故障切换等丰富的运维功能,大幅降低运维成本。 产品主页:https://www.aliyun.com/product/gdb
相关文章
|
21天前
|
SQL 关系型数据库 MySQL
乐观锁在分布式数据库中如何与事务隔离级别结合使用
乐观锁在分布式数据库中如何与事务隔离级别结合使用
|
19天前
|
存储 SQL 分布式数据库
OceanBase 入门:分布式数据库的基础概念
【8月更文第31天】在当今的大数据时代,随着业务规模的不断扩大,传统的单机数据库已经难以满足高并发、大数据量的应用需求。分布式数据库应运而生,成为解决这一问题的有效方案之一。本文将介绍一款由阿里巴巴集团自主研发的分布式数据库——OceanBase,并通过一些基础概念和实际代码示例来帮助读者理解其工作原理。
69 0
|
25天前
|
存储 缓存 负载均衡
【PolarDB-X 技术揭秘】Lizard B+tree:揭秘分布式数据库索引优化的终极奥秘!
【8月更文挑战第25天】PolarDB-X是阿里云的一款分布式数据库产品,其核心组件Lizard B+tree针对分布式环境优化,解决了传统B+tree面临的数据分片与跨节点查询等问题。Lizard B+tree通过一致性哈希实现数据分片,确保分布式一致性;智能分区实现了负载均衡;高效的搜索算法与缓存机制降低了查询延迟;副本机制确保了系统的高可用性。此外,PolarDB-X通过自适应分支因子、缓存优化、异步写入、数据压缩和智能分片等策略进一步提升了Lizard B+tree的性能,使其能够在分布式环境下提供高性能的索引服务。这些优化不仅提高了查询速度,还确保了系统的稳定性和可靠性。
54 5
|
26天前
|
运维 安全 Cloud Native
核心系统转型问题之分布式数据库和数据访问中间件协作如何解决
核心系统转型问题之分布式数据库和数据访问中间件协作如何解决
|
30天前
|
Linux 数据库 数据安全/隐私保护
|
11天前
|
关系型数据库 数据库 网络虚拟化
Docker环境下重启PostgreSQL数据库服务的全面指南与代码示例
由于时间和空间限制,我将在后续的回答中分别涉及到“Python中采用lasso、SCAD、LARS技术分析棒球运动员薪资的案例集锦”以及“Docker环境下重启PostgreSQL数据库服务的全面指南与代码示例”。如果你有任何一个问题的优先顺序或需要立即回答的,请告知。
21 0
|
19天前
|
C# UED 定位技术
WPF控件大全:初学者必读,掌握控件使用技巧,让你的应用程序更上一层楼!
【8月更文挑战第31天】在WPF应用程序开发中,控件是实现用户界面交互的关键元素。WPF提供了丰富的控件库,包括基础控件(如`Button`、`TextBox`)、布局控件(如`StackPanel`、`Grid`)、数据绑定控件(如`ListBox`、`DataGrid`)等。本文将介绍这些控件的基本分类及使用技巧,并通过示例代码展示如何在项目中应用。合理选择控件并利用布局控件和数据绑定功能,可以提升用户体验和程序性能。
36 0
|
1月前
|
存储 SQL 运维
“震撼发布!PolarDB-X:云原生分布式数据库巨擘,超高并发、海量存储、复杂查询,一网打尽!错过等哭!”
【8月更文挑战第7天】PolarDB-X 是面向超高并发、海量存储和复杂查询场景设计的云原生分布式数据库系统
87 1
|
2月前
|
Cloud Native 关系型数据库 分布式数据库
中国金融分布式数据库,双料冠军!
中国金融分布式数据库同比增长12.1%,阿里云绝对优势夺得公有云市场冠军
|
1月前
|
存储 负载均衡 中间件
构建可扩展的分布式数据库:技术策略与实践
【8月更文挑战第3天】构建可扩展的分布式数据库是一个复杂而具有挑战性的任务。通过采用数据分片、复制与一致性模型、分布式事务管理和负载均衡与自动扩展等关键技术策略,并合理设计节点、架构模式和网络拓扑等关键组件,可以构建出高可用性、高性能和可扩展的分布式数据库系统。然而,在实际应用中还需要注意解决数据一致性、故障恢复与容错性以及分布式事务的复杂性等挑战。随着技术的不断发展和创新,相信分布式数据库系统将在未来发挥更加重要的作用。