使用docker部署dgraph

  1. 1. 概述
  2. 2. 单Alpha
  3. 3. 多Alpha
  4. 4. 多Zero
  5. 5. 多Zero多节点

dgraph部署

1. 概述

dgraph主要有三个服务:

Zero: 是集群的核心, 负责调度集群服务器和平衡服务器组之间的数据。本身不保存数据。
Alpha: 保存数据的谓词索引. 谓词包括数据的属性数据之间的关系; 索引是为了更快的进行数据的过滤和查找。
Ratel: dgraph 的 UI 接口, 可以在此界面上进行数据的 CURD, 也可以修改数据的 schema。

2. 单Alpha

version: '3.8'

volumes:
  zero1-data:
  alpha1-data:

services:
  # dgraph cluster core
  zero1:
    image: dgraph/dgraph:latest
    container_name: iotx-zero1
    hostname: iotx-zero1
    restart: on-failure
    networks:
      - iotx-network
    ports:
      - 6080:6080
    volumes:
      - zero1-data:/dgraph
    command: dgraph zero --my=iotx-zero1:5080 --replicas=1  --idx 1
  alpha1:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha1
    hostname: iotx-alpha1
    networks:
      - iotx-network
    ports:
      - 9080:9080
      - 8080:8080
    volumes:
      - alpha1-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha1:7080 --lru_mb=2048 --zero=iotx-zero1:5080 --idx=1
    depends_on:
      - zero1
  ratel:
    image: dgraph/dgraph:latest
    container_name: iotx-ratel
    hostname: iotx-ratel
    networks:
      - iotx-network
    ports:
      - 7000:8000
    restart: always
    command: dgraph-ratel
networks:
  iotx-network:
    driver: "bridge"

3. 多Alpha

version: '3.8'

volumes:
  zero1-data:
  alpha1-data:
  alpha2-data:
  alpha3-data:

services:
  # dgraph cluster core
  zero1:
    image: dgraph/dgraph:latest
    container_name: iotx-zero1
    hostname: iotx-zero1
    restart: on-failure
    networks:
      - iotx-network
    ports:
      - 6080:6080
    volumes:
      - zero1-data:/dgraph
    command: dgraph zero --my=iotx-zero1:5080 --replicas=1  --idx 1
  alpha1:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha1
    hostname: iotx-alpha1
    networks:
      - iotx-network
    ports:
      - 9080:9080
      - 8080:8080
    volumes:
      - alpha1-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha1:7080 --lru_mb=2048 --zero=iotx-zero1:5080 --idx=1
    depends_on:
      - zero1
  alpha2:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha2
    hostname: iotx-alpha2
    networks:
      - iotx-network
    ports:
      - 9081:9080
      - 8081:8080
    volumes:
      - alpha2-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha2:7080 --lru_mb=2048 --zero=iotx-zero1:5080 --idx=2
    depends_on:
      - zero1
  alpha3:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha3
    hostname: iotx-alpha3
    networks:
      - iotx-network
    ports:
      - 9082:9080
      - 8082:8080
    volumes:
      - alpha3-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha3:7080 --lru_mb=2048 --zero=iotx-zero1:5080 --idx=3
    depends_on:
      - zero1
  ratel:
    image: dgraph/dgraph:latest
    container_name: iotx-ratel
    hostname: iotx-ratel
    networks:
      - iotx-network
    ports:
      - 7000:8000
    restart: always
    command: dgraph-ratel
networks:
  iotx-network:
    driver: "bridge"

4. 多Zero

version: '3.8'

volumes:
  zero1-data:
  zero2-data:
  zero3-data:
  alpha1-data:
  alpha2-data:
  alpha3-data:

services:
  # dgraph cluster core
  zero1:
    image: dgraph/dgraph:latest
    container_name: iotx-zero1
    hostname: iotx-zero1
    restart: on-failure
    networks:
      - iotx-network
    ports:
      - 6080:6080
    volumes:
      - zero1-data:/dgraph
    command: dgraph zero --my=iotx-zero1:5080 --replicas=1  --idx 1
  zero2:
    image: dgraph/dgraph:latest
    container_name: iotx-zero2
    hostname: iotx-zero2
    restart: on-failure
    networks:
      - iotx-network
    volumes:
      - zero2-data:/dgraph
    command: dgraph zero --my=iotx-zero2:5080 --peer=iotx-zero1:5080 --replicas=1 --idx 2
  zero3:
    image: dgraph/dgraph:latest
    container_name: iotx-zero3
    hostname: iotx-zero3
    restart: on-failure
    networks:
      - iotx-network
    volumes:
      - zero3-data:/dgraph
    command: dgraph zero --my=iotx-zero3:5080 --peer=iotx-zero1:5080 --replicas=1 --idx 3
  alpha1:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha1
    hostname: iotx-alpha1
    networks:
      - iotx-network
    ports:
      - 9080:9080
      - 8080:8080
    volumes:
      - alpha1-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha1:7080 --lru_mb=2048 --zero=iotx-zero1:5080,iotx-zero2:5080,iotx-zero3:5080 --idx=1
    depends_on:
      - zero1
  alpha2:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha2
    hostname: iotx-alpha2
    networks:
      - iotx-network
    ports:
      - 9081:9080
      - 8081:8080
    volumes:
      - alpha2-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha2:7080 --lru_mb=2048 --zero=iotx-zero1:5080,iotx-zero2:5080,iotx-zero3:5080 --idx=2
    depends_on:
      - zero1
  alpha3:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha3
    hostname: iotx-alpha3
    networks:
      - iotx-network
    ports:
      - 9082:9080
      - 8082:8080
    volumes:
      - alpha3-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha3:7080 --lru_mb=2048 --zero=iotx-zero1:5080,iotx-zero2:5080,iotx-zero3:5080 --idx=3
    depends_on:
      - zero1
  ratel:
    image: dgraph/dgraph:latest
    container_name: iotx-ratel
    hostname: iotx-ratel
    networks:
      - iotx-network
    ports:
      - 7000:8000
    restart: always
    command: dgraph-ratel
networks:
  iotx-network:
    driver: "bridge"

5. 多Zero多节点

replicas=3意味着每个group包含三个alpine

version: '3.8'

volumes:
  zero1-data:
  zero2-data:
  zero3-data:
  alpha1-data:
  alpha2-data:
  alpha3-data:

services:
  # dgraph cluster core
  zero1:
    image: dgraph/dgraph:latest
    container_name: iotx-zero1
    hostname: iotx-zero1
    restart: on-failure
    networks:
      - iotx-network
    ports:
      - 6080:6080
    volumes:
      - zero1-data:/dgraph
    command: dgraph zero --my=iotx-zero1:5080 --replicas=3  --idx 1
  zero2:
    image: dgraph/dgraph:latest
    container_name: iotx-zero2
    hostname: iotx-zero2
    restart: on-failure
    networks:
      - iotx-network
    volumes:
      - zero2-data:/dgraph
    command: dgraph zero --my=iotx-zero2:5080 --peer=iotx-zero1:5080 --replicas=3 --idx 2
  zero3:
    image: dgraph/dgraph:latest
    container_name: iotx-zero3
    hostname: iotx-zero3
    restart: on-failure
    networks:
      - iotx-network
    volumes:
      - zero3-data:/dgraph
    command: dgraph zero --my=iotx-zero3:5080 --peer=iotx-zero1:5080 --replicas=3 --idx 3
  alpha1:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha1
    hostname: iotx-alpha1
    networks:
      - iotx-network
    ports:
      - 9080:9080
      - 8080:8080
    volumes:
      - alpha1-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha1:7080 --lru_mb=2048 --zero=iotx-zero1:5080,iotx-zero2:5080,iotx-zero3:5080 --idx=1
    depends_on:
      - zero1
  alpha2:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha2
    hostname: iotx-alpha2
    networks:
      - iotx-network
    ports:
      - 9081:9080
      - 8081:8080
    volumes:
      - alpha2-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha2:7080 --lru_mb=2048 --zero=iotx-zero1:5080,iotx-zero2:5080,iotx-zero3:5080 --idx=2
    depends_on:
      - zero1
  alpha3:
    image: dgraph/dgraph:latest
    container_name: iotx-alpha3
    hostname: iotx-alpha3
    networks:
      - iotx-network
    ports:
      - 9082:9080
      - 8082:8080
    volumes:
      - alpha3-data:/dgraph
    restart: on-failure
    command: dgraph alpha --my=iotx-alpha3:7080 --lru_mb=2048 --zero=iotx-zero1:5080,iotx-zero2:5080,iotx-zero3:5080 --idx=3
    depends_on:
      - zero1
  ratel:
    image: dgraph/dgraph:latest
    container_name: iotx-ratel
    hostname: iotx-ratel
    networks:
      - iotx-network
    ports:
      - 7000:8000
    restart: always
    command: dgraph-ratel
networks:
  iotx-network:
    driver: "bridge"

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 wind.kaisa@gmail.com

文章标题:使用docker部署dgraph

本文作者:kaisawind

发布时间:2020-08-07, 16:57:04

最后更新:2020-12-04, 10:18:58

原始链接:https://kaisawind.gitee.io/2020/08/07/2020-08-08-dgraph-deploy/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏