单机多副本docker-compose部署minio
简单介绍
如果服务器有限可以单机挂载多硬盘实现多副本容错(生产不推荐)
部署好的文件状态
有两个重要文件 docker-compose.yaml和nginx.conf
docker-compose.yaml是docker部署容器的配置信息包括4个minio和1个nginx容器
部署好的状态
操作步骤
-
安装docker
yum install docker
-
安装docker-compose
curl -L https://github.com/docker/compose/releases/download/1.21.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
-
放置配置docker-compose.yaml文件和nginx.conf
mkdir /home/minios/ #创建文件夹
-
运行docker-compose.yaml
systemctl enable docker systemctl start docker systemctl status docker docker-compose -f docker-compose.yaml up -d docker images #查看docker服务镜像 docker ps #正在运行的docker容器 docker ps -a #全部的docker容器 docker logs --tail 100 容器ID #查看容器日志信息 telnet 127.0.0.1 9000检查是否成功
-
创建文件桶
docker-compose.yaml
version: '3.3'# starts 4 docker containers running minio server instances.
# using nginx reverse proxy, load balancing, you can access
# it through port 9000.
services:minio1:image: minio/minio:RELEASE.2021-04-22T15-44-28Zvolumes:- ./data1-1:/data1- ./data1-2:/data2expose:- "9000"environment:MINIO_ROOT_USER: minioMINIO_ROOT_PASSWORD: minio123command: server http://minio{1...4}/data{1...2}healthcheck:test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]interval: 30stimeout: 20sretries: 3networks:- fjjminiorestart: alwaysminio2:image: minio/minio:RELEASE.2021-04-22T15-44-28Zvolumes:- ./data2-1:/data1- ./data2-2:/data2expose:- "9000"environment:MINIO_ROOT_USER: minioMINIO_ROOT_PASSWORD: minio123command: server http://minio{1...4}/data{1...2}healthcheck:test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]interval: 30stimeout: 20sretries: 3networks:- fjjminiorestart: alwaysminio3:image: minio/minio:RELEASE.2021-04-22T15-44-28Zvolumes:- ./data3-1:/data1- ./data3-2:/data2expose:- "9000"environment:MINIO_ROOT_USER: minioMINIO_ROOT_PASSWORD: minio123command: server http://minio{1...4}/data{1...2}healthcheck:test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]interval: 30stimeout: 20sretries: 3networks:- fjjminiorestart: alwaysminio4:image: minio/minio:RELEASE.2021-04-22T15-44-28Zvolumes:- ./data4-1:/data1- ./data4-2:/data2expose:- "9000"environment:MINIO_ROOT_USER: minioMINIO_ROOT_PASSWORD: minio123command: server http://minio{1...4}/data{1...2}healthcheck:test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]interval: 30stimeout: 20sretries: 3networks:- fjjminiorestart: alwaysnginx:image: nginx:1.19.2-alpinevolumes:- ./nginx.conf:/etc/nginx/nginx.conf:roports:- "9000:9000"depends_on:- minio1- minio2- minio3- minio4networks:- fjjminiorestart: alwaysnetworks:fjjminio:
nginx.conf
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 minio {ip_hash;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 headersignore_invalid_headers off;# Allow any size file to be uploaded.# Set to a value such as 1000m; to restrict file size to a specific valueclient_max_body_size 50m;# To disable bufferingproxy_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.1proxy_http_version 1.1;proxy_set_header Connection "";chunked_transfer_encoding off;proxy_pass http://minio;}}
}