docker-compose部署MinIO分布式集群
文章目录
概述
MinIO是全球领先的对象存储先锋,目前在全世界有数百万的用户。
-
高性能
,在标准硬件上,读/写速度上高达183GB/秒和171GB/秒,拥有更高的吞吐量和更低的延迟 -
可扩展性
,为对象存储带来了简单的缩放模型,通过添加更多集群可以扩展空间 -
简单
,极简主义是MinIO的指导性设计原则,即可在几分钟内安装和配置 -
与Amazon S3兼容
,亚马逊云的
S3 API
(接口协议)是在全球范围内达到共识的对象存储的协议,是全世界内大家都认可的标准 -
数据安全
,使用纠删码来保护数据免受硬件故障和无声数据损坏
纠删码
纠删码
是一种恢复丢失和损坏数据的数学算法, Minio默认采用
Reed-Solomon code
将数据拆分成N/2个数据块和N/2个奇偶校验块。这就意味着如果是16块盘,一个对象会被分成8个数据块、8个奇偶校验块,你可以丢失任意8块盘(不管其是存放的数据块还是校验块),你仍可以从剩下的盘中的数据进行恢复。
部署
官方推荐
docker-compose.yaml
:
下载地址
稍加修改,内容如下:
version: '3.7'
# 所有容器通用的设置和配置
x-minio-common: &minio-common
image: minio/minio
command: server --console-address ":9001" http://minio{1...4}/data
expose:
- "9000"
# environment:
# MINIO_ROOT_USER: minioadmin
# MINIO_ROOT_PASSWORD: minioadmin
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
# 启动4个docker容器运行minio服务器实例
# 使用nginx反向代理9000端口,负载均衡, 你可以通过9001、9002、9003、9004端口访问它们的web console
services:
minio1:
<<: *minio-common
hostname: minio1
ports:
- "9001:9001"
volumes:
- ./data/data1:/data
minio2:
<<: *minio-common
hostname: minio2
ports:
- "9002:9001"
volumes:
- ./data/data2:/data
minio3:
<<: *minio-common
hostname: minio3
ports:
- "9003:9001"
volumes:
- ./data/data3:/data
minio4:
<<: *minio-common
hostname: minio4
ports:
- "9004:9001"
volumes:
- ./data/data4:/data
nginx:
image: nginx:1.19.2-alpine
hostname: nginx
volumes:
- ./config/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "9000:9000"
depends_on:
- minio1
- minio2
- minio3
- minio4
接着新建文件夹
config
,新建配置
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
# include /etc/nginx/conf.d/*.conf;
upstream minio {
server minio1:9000;
server minio2:9000;
server minio3:9000;
server minio4:9000;
}
server {
listen 9000;
listen [::]:9000;
server_name localhost;
# To allow special characters in headers
ignore_invalid_headers off;
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0;
# To disable buffering
proxy_buffering off;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://minio;
}
}
}
执行启动命令,看到各个节点
healthy
状态即成功
docker-compose up -d
配置
浏览器访问任意节点
web console
,进行简单配置,配置会自动在节点间同步
创建桶(Buckets)后,选择管理(Manage),在总结(Summary)中可以进行访问策略(Access Policy)配置
选择菜单设置(Settings)-配置( Configuration),选择扫描器(Scanner),配置
Max Wait
和
Cycle
为1s,可以大大加快节点间的同步效率