准备nginx配置文件
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
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;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
# include /etc/nginx/conf.d/*.conf;
upstream minio9000 {
server minio1:9000;
server minio2:9000;
}
upstream minio9001 {
server minio1:9001;
server minio2:9001;
}
# main minio
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://minio9000;
}
}
server {
listen 9001;
listen [::]:9001;
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://minio9001;
}
}
}
准备docker-compose配置文件
version: '3'
services:
minio1:
image: minio/minio:RELEASE.2022-03-26T06-49-28Z
container_name: minio1
hostname: minio1
restart: always
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=minioadmin
volumes:
- ./data/minio1/data1:/data1
- ./data/minio1/data2:/data2
command: server http://minio{1...2}/data{1...2} --console-address ":9001"
minio2:
image: minio/minio:RELEASE.2022-03-26T06-49-28Z
container_name: minio2
hostname: minio2
restart: always
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=minioadmin
volumes:
- ./data/minio2/data1:/data1
- ./data/minio2/data2:/data2
command: server http://minio{1...2}/data{1...2} --console-address ":9001"
nginx:
image: nginx:1.19.2-alpine
container_name: minio-nginx
hostname: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "9900:9000"
- "9001:9001"
depends_on:
- minio1
- minio2
networks:
default:
external:
name: minio
启动服务
启动之前需要创建网络
docker network create minio
docker-compose up -d
扩容
将启动命令修改为server http://minio{1...2}/data{1...2} http://minio{3...4}/data{1...2}
,即将原来的集群扩展为包含4个实例的集群。
最终的配置文件如下
docker-compose
version: '3'
services:
minio1:
image: minio/minio:RELEASE.2022-03-26T06-49-28Z
container_name: minio1
hostname: minio1
restart: always
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=minioadmin
volumes:
- ./data/minio1/data1:/data1
- ./data/minio1/data2:/data2
command: server http://minio{1...2}/data{1...2} http://minio{3...4}/data{1...2} --console-address ":9001"
minio2:
image: minio/minio:RELEASE.2022-03-26T06-49-28Z
container_name: minio2
hostname: minio2
restart: always
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=minioadmin
volumes:
- ./data/minio2/data1:/data1
- ./data/minio2/data2:/data2
command: server http://minio{1...2}/data{1...2} http://minio{3...4}/data{1...2} --console-address ":9001"
minio3:
image: minio/minio:RELEASE.2022-03-26T06-49-28Z
container_name: minio3
hostname: minio3
restart: always
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=minioadmin
volumes:
- ./data/minio3/data1:/data1
- ./data/minio3/data2:/data2
command: server http://minio{1...2}/data{1...2} http://minio{3...4}/data{1...2} --console-address ":9001"
minio4:
image: minio/minio:RELEASE.2022-03-26T06-49-28Z
container_name: minio4
hostname: minio4
restart: always
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=minioadmin
volumes:
- ./data/minio4/data1:/data1
- ./data/minio4/data2:/data2
command: server http://minio{1...2}/data{1...2} http://minio{3...4}/data{1...2} --console-address ":9001"
nginx:
image: nginx:1.19.2-alpine
container_name: minio-nginx
hostname: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "9900:9000"
- "9001:9001"
depends_on:
- minio1
- minio2
- minio3
- minio4
networks:
default:
external:
name: minio
nginx
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
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;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
# include /etc/nginx/conf.d/*.conf;
upstream minio9000 {
server minio1:9000;
server minio2:9000;
server minio3:9000;
server minio4:9000;
}
upstream minio9001 {
server minio1:9001;
server minio2:9001;
server minio3:9001;
server minio4:9001;
}
# main minio
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://minio9000;
}
}
server {
listen 9001;
listen [::]:9001;
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://minio9001;
}
}
}