Minio
本示例compose文件会拉起4个节点的minio集群,节点用swarm node标签replica来标记。
docker-compose文件准备
docker-compose-minio-new.yml
version: '3.7'
# Settings and configurations that are common for all containers
x-minio-common: &minio-common
image: quay.io/minio/minio:latest
command: server --console-address ":9001" http://minio{1...3}/data{1...2}
# expose:
# - "9000"
# - "9001"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
networks:
- minio_distributed
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
# starts 3 docker containers running minio server instances.
# using nginx reverse proxy, load balancing, you can access
# it through port 9000.
services:
minio1:
<<: *minio-common
hostname: minio1
ports:
- "9000:9000"
- "9001:9001"
deploy:
restart_policy:
delay: 10s
max_attempts: 10
window: 60s
placement:
constraints:
- node.labels.replica==1
volumes:
- minio1-data-1:/data1
- minio1-data-2:/data2
minio2:
<<: *minio-common
hostname: minio2
deploy:
restart_policy:
delay: 10s
max_attempts: 10
window: 60s
placement:
constraints:
- node.labels.replica==2
volumes:
- minio2-data-1:/data1
- minio2-data-2:/data2
minio3:
<<: *minio-common
hostname: minio3
deploy:
restart_policy:
delay: 10s
max_attempts: 10
window: 60s
placement:
constraints:
- node.labels.replica==3
volumes:
- minio3-data-1:/data1
- minio3-data-2:/data2
# nginx:
# image: nginx:1.19.2-alpine
# hostname: nginx
# volumes:
# - ./nginx.conf:/etc/nginx/nginx.conf:ro
# ports:
# - "9000:9000"
# - "9001:9001"
# depends_on:
# - minio1
# - minio2
# - minio3
## By default this config uses default local driver,
## For custom volumes replace with volume driver configuration.
volumes:
minio1-data-1:
minio1-data-2:
minio2-data-1:
minio2-data-2:
minio3-data-1:
minio3-data-2:
networks:
minio_distributed:
external: true # 用已经创建好的网络
准备工作
修改docker-compose-minio.yml里的配置信息
- swarm节点标记replica
- 用户名密码,MINIO_ROOT_USER和MINIO_ROOT_PASSWORD
- 修改卷挂载,改到数据盘
创建专用网络:
docker network create --driver overlay minio_distributed
拉起服务
sudo docker stack deploy -c docker-compose-minio-new.yml minio
sudo docker stack ps minio查看服务状态
服务验证
- 登录控制台
访问 http://node1:19002 输入上面的用户名和密码,登录成功界面。 - 登录其他节点控制台
问题排查
- 无法创建服务,没找到网卡,因为服务启动依赖网卡,重新再拉起一次,看到先创建网卡就好了:Creating network minio_minio_distributed。
Creating service minio_minio2
failed to create service minio_minio2: Error response from daemon: network minio_minio_distributed not found
标签:compose,minio,distributed,swarm,docker,ROOT
From: https://www.cnblogs.com/JentZhang/p/17120500.html