Docker部署swarm模式的minio
-
- 一、建立蜂群
-
- 1.1 主節點上初始化
- 1.2 從節點加入蜂群
- 1.3 檢視蜂群
- 二、部屬分布式的minio
-
- 2.1 準備密鑰
- 2.2 給分群節點添加标簽
- 2.3 準備docker-compose的檔案
- 2.4 部屬stack
- 三、删除
-
- 3.1 删除stack
- 3.2 删除volume
一、建立蜂群
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上檢視蜂群:
二、部屬分布式的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
- 必須至少是4個節點。因為采用的是Erasure Code(糾删碼) 的方式實作資料恢複運算
- minio1在master上,minio2在slave001上,minio3和minio4在slave00上
- 糾删碼的一些資料: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