一、镜像选择
Minio有很多镜像会有一些bug,而且不好解决,这里使用的是镜像
RELEASE.2021-04-18T19-26-29Z
直接: docker pull minio/minio:RELEASE.2021-04-18T19-26-29Z 即可:
拉取之后可以打个tag,这里是new2
RELEASE.2021-06-17T00-10-46Z 这个镜像是稍微新一点的,但是会有一些问题
二、docker-compse
version: '3.5'
services:
minio1:
image: minio:new2
hostname: minio1
#volumes:
# - D:\Research\Minio\data\driver1:/miniodisk
environment:
- MINIO_ROOT_USER=minio_admin
- MINIO_ROOT_PASSWORD=minio_admin
command: ["server","http://minio{1...4}/miniodisk"]
minio2:
image: minio:new2
hostname: minio2
deploy:
replicas: 1
restart_policy:
condition: on-failure
#volumes:
# - D:\Research\Minio\data\driver2:/miniodisk
environment:
- MINIO_ROOT_USER=minio_admin
- MINIO_ROOT_PASSWORD=minio_admin
command: ["server","http://minio{1...4}/miniodisk"]
minio3:
image: minio:new2
hostname: minio3
deploy:
replicas: 1
restart_policy:
condition: on-failure
#volumes:
# - D:\Research\Minio\data\driver3:/miniodisk
environment:
- MINIO_ROOT_USER=minio_admin
- MINIO_ROOT_PASSWORD=minio_admin
command: ["server","http://minio{1...4}/miniodisk"]
minio4:
image: minio:new2
hostname: minio4
deploy:
replicas: 1
restart_policy:
condition: on-failure
#volumes:
# - D:\Research\Minio\data\driver4:/miniodisk
environment:
- MINIO_ROOT_USER=minio_admin
- MINIO_ROOT_PASSWORD=minio_admin
command: ["server","http://minio{1...4}/miniodisk"]
nginx:
image: nginx
hostname: nginx
ports:
- 8088:8080
volumes:
- D:\Research\Minio\nginx.conf2:/etc/nginx/conf.d/nginx.conf
有几点说明:
1. 关于volumes,因为我这里是使用的docker-desktop,windows的磁盘文件映射到linux内部,这样导致minio请求磁盘信息的时候有问题,所以我们直接使用内部目录,会导致容器销毁后文件丢失,但是测试不影响。在Linux上可以直接映射
2. 关于command:这里我们是模拟四个节点 每个节点一个驱动一个磁盘 , 所以这里是http://minio{1...4}/miniodisk 如果每个驱动2个磁盘,直接可以http://minio{1...4}/miniodisk{1...2}
三、关于nginx
这里贴出nginx配置文件:
upstream minioconsole {
server minio1:9000;
server minio2:9000;
server minio3:9000;
server minio4:9000;
}
server {
listen 8080;
listen [::]:8080;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
client_max_body_size 5120M;
location /{
proxy_pass http://minioconsole/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
nginx直接做负载均衡
四、结果展示: