根據(jù)
官網(wǎng)介紹http://docs.minio.org.cn/docs/master/deploy-minio-on-docker-swarm
屯蹦,多主機(jī)minio只有介紹swarm的模式凳兵,但是單獨(dú)為minio搭建swarm有點(diǎn)麻煩,所以改造了官網(wǎng)docker-compose模式http://docs.minio.org.cn/docs/master/deploy-minio-on-docker-compose
單機(jī)模式為多機(jī)模式
服務(wù)器信息如下:
服務(wù)器 | IP | 安裝組件 |
---|---|---|
node1 | 192.168.1.1 | minio1仗岸、nginx |
node2 | 192.168.1.2 | minio2、nginx |
node3 | 192.168.1.3 | minio3、nginx |
安裝配置步驟如下(假設(shè)已經(jīng)安裝docker坠韩,本處使用docker-ce 19.03.12):
- docker下載鏡像(
如果服務(wù)器能夠訪問公網(wǎng),則忽略此步驟
)
docker pull quay.io/minio/minio:RELEASE.2021-10-23T03-28-24Z
docker pull nginx:1.19.2-alpine
- 下載docker-compose (本處使用docker-compose version 1.29.2炼列,docker-compose需要支持語法3.7)
# 增加執(zhí)行權(quán)限
chmod +x docker-compose
- 創(chuàng)建docker-compose.yaml(按需修改IP)
version: '3.7'
# Settings and configurations that are common for all containers
# minio節(jié)點(diǎn)之間默認(rèn)使用9000來連通只搁,所以容器把9000暴露出來,9001是console端口俭尖,每個(gè)節(jié)點(diǎn)設(shè)置兩塊磁盤
x-minio-common: &minio-common
image: quay.io/minio/minio:RELEASE.2021-10-23T03-28-24Z
command: server --console-address ":9001" http://minio{1...3}/data{1...2}
expose:
- "9000"
- "9001"
# 增加host映射氢惋,以便三個(gè)節(jié)點(diǎn)之間通過域名連通
extra_hosts:
minio1: 192.168.1.1
minio2: 192.168.1.2
minio3: 192.168.1.3
depends_on:
- nginx
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 5
# starts 4 docker containers running minio server instances.
# using nginx reverse proxy, load balancing, you can access
# it through port 9000.
# 數(shù)據(jù)盤掛載目錄洞翩,按需修改
services:
minio1:
<<: *minio-common
container_name: minio1
hostname: minio1
volumes:
- ./minio_data/data1-1:/data1
- ./minio_data/data1-2:/data2
ports:
- "9000:9000"
- "9001:9001"
minio2:
<<: *minio-common
container_name: minio2
hostname: minio2
volumes:
- ./minio_data/data2-1:/data1
- ./minio_data/data2-2:/data2
ports:
- "9000:9000"
- "9001:9001"
minio3:
<<: *minio-common
container_name: minio3
hostname: minio3
volumes:
- ./minio_data/data3-1:/data1
- ./minio_data/data3-2:/data2
ports:
- "9000:9000"
- "9001:9001"
# 三個(gè)節(jié)點(diǎn)都安裝nginx,并且負(fù)載到三個(gè)節(jié)點(diǎn)焰望,nginx暴露端口按需修改19000/19001
nginx:
image: nginx:1.19.2-alpine
container_name: nginx-minio
hostname: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "19000:9000"
- "19001:9001"
extra_hosts:
minio1: 192.168.1.1
minio2: 192.168.1.2
minio3: 192.168.1.3
- 創(chuàng)建nginx配置如下:
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;
}
upstream console {
ip_hash;
server minio1:9001;
server minio2:9001;
server minio3:9001;
}
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;
}
}
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_set_header X-NginX-Proxy true;
# This is necessary to pass the correct IP to be hashed
real_ip_header X-Real-IP;
proxy_connect_timeout 300;
# To support websocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
chunked_transfer_encoding off;
proxy_pass http://console;
}
}
}
- 三個(gè)節(jié)點(diǎn)分別啟動(dòng)
# 拉包
./docker-compose pull
# 后臺(tái)啟動(dòng)骚亿,三臺(tái)對(duì)應(yīng)啟動(dòng)各自節(jié)點(diǎn)minio1/minio2/minio3 (切勿單臺(tái)啟動(dòng)多個(gè))
./docker-compose up -d minio1
./docker-compose up -d minio2
./docker-compose up -d minio3
- 驗(yàn)證,登陸 http://192.168.1.1:19001/熊赖,賬號(hào)密碼 minio/minio123