Docker部署swarm模式的minio

该博客主要介绍了使用Docker部署分布式Minio的详细步骤。首先讲解了创建蜂群,包括主节点初始化、从节点加入及查看蜂群;接着阐述部署分布式Minio,如准备密钥、添加节点标签、准备docker - compose文件和部署stack;最后说明了删除stack和volume的操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、创建蜂群

1.1 主节点上初始化

master上执行:

docker swarm init --advertise-addr 192.168.1.100

1.2 从节点加入蜂群

在slave001和slave002上执行:

docker swarm join --token SWMTKN-1-3nd71k9vkufr27loqf74offrjvqyezozizj3poq10jf3hdefvd-a3q6c8u227f3rcfnkomdq5pql 192.168.1.100:2377

1.3 查看蜂群

在master上查看蜂群:

docker node ls

二、部属分布式的minio

2.1 准备密钥

echo "minioadmin" | docker secret create minio_access_key -
echo "minioadmin" | docker secret create minio_secret_key -

2.2 给分群节点添加标签

docker node update --label-add minio1=true nu93s16h3lwt1et8606hy2woi
docker node update --label-add minio2=true yqiyrmyjptx91owxqs94qsfcw
docker node update --label-add minio3=true usfo19iz0ehtle7bvzfc9z9hh
docker node update --label-add minio4=true usfo19iz0ehtle7bvzfc9z9hh
  1. 必须至少是4个节点。因为采用的是Erasure Code(纠删码) 的方式实现数据恢复运算
  2. minio1在master上,minio2在slave001上,minio3和minio4在slave00上
  3. 纠删码的一些资料:https://zhuanlan.zhihu.com/p/106096265?utm_source=wechat_session

2.3 准备docker-compose的文件

新建一个文件docker-compose-secrets.yaml

vi docker-compose-secrets.yaml

文件内容如下:

version: '3.7'

services:
  minio1:
    image: minio/minio:RELEASE.2020-11-19T23-48-16Z
    hostname: minio1
    volumes:
      - minio1-data:/export
    ports:
      - "9001:9000"
    networks:
      - minio_distributed
    deploy:
      restart_policy:
        delay: 10s
        max_attempts: 10
        window: 60s
      placement:
        constraints:
          - node.labels.minio1==true
    command: server http://minio{1...4}/export
    secrets:
      - secret_key
      - access_key
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  minio2:
    image: minio/minio:RELEASE.2020-11-19T23-48-16Z
    hostname: minio2
    volumes:
      - minio2-data:/export
    ports:
      - "9002:9000"
    networks:
      - minio_distributed
    deploy:
      restart_policy:
        delay: 10s
        max_attempts: 10
        window: 60s
      placement:
        constraints:
          - node.labels.minio2==true
    command: server http://minio{1...4}/export
    secrets:
      - secret_key
      - access_key
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  minio3:
    image: minio/minio:RELEASE.2020-11-19T23-48-16Z
    hostname: minio3
    volumes:
      - minio3-data:/export
    ports:
      - "9003:9000"
    networks:
      - minio_distributed
    deploy:
      restart_policy:
        delay: 10s
        max_attempts: 10
        window: 60s
      placement:
        constraints:
          - node.labels.minio3==true
    command: server http://minio{1...4}/export
    secrets:
      - secret_key
      - access_key
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  minio4:
    image: minio/minio:RELEASE.2020-11-19T23-48-16Z
    hostname: minio4
    volumes:
      - minio4-data:/export
    ports:
      - "9004:9000"
    networks:
      - minio_distributed
    deploy:
      restart_policy:
        delay: 10s
        max_attempts: 10
        window: 60s
      placement:
        constraints:
          - node.labels.minio4==true
    command: server http://minio{1...4}/export
    secrets:
      - secret_key
      - access_key
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

volumes:
  minio1-data:

  minio2-data:

  minio3-data:

  minio4-data:

networks:
  minio_distributed:
    driver: overlay

secrets:
  secret_key:
    external: true
    name: minio_secret_key
  access_key:
    external: true
    name: minio_access_key

2.4 部属stack

docker stack deploy --compose-file=docker-compose-secrets.yaml minio_stack

三、删除

3.1 删除stack

docker stack rm minio_stack

3.2 删除volume

docker volume prune
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值