Docker-compose minio集群部署

一、虚机准备

192.168.40.174       192.168.40.174      192.168.40.176

二、下载docker-compose 

离线安装docker及docker-compose_docker-compose离线安装-CSDN博客

三、docker-compose.yml文件

按docker-compose文件启动,minio的api端口为9000,控制台端口为9001

174
version: "3"
services:
  nginx:
    image: nginx:latest
    container_name: nginx
    hostname: nginx
    restart: unless-stopped
    ports:
      - 8080:8080
      - 8081:8081
    network_mode: "host"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - /etc/localtime:/etc/localtime

  minio1:
    image: minio/minio:RELEASE.2023-12-02T10-51-33Z
    container_name: minio1
    restart: always
    ports:
      - 9000:9000
      - 9001:9001
    network_mode: "host"
    environment:
      - MINIO_ROOT_USER=minio
      - MINIO_ROOT_PASSWORD=minio123
      - TZ=Asia/Shanghai
    command: server --address ":9000" --console-address ":9001" http://192.168.40.174/data1 http://192.168.40.174/data2 http://192.168.40.175/data1 http://192.168.40.175/data2 http://192.168.40.176/data1 http://192.168.40.176/data2
    volumes:
      - /etc/localtime:/etc/localtime
      - ./minio/data1-1:/data1
      - ./minio/data1-2:/data2
175
version: "3"
services:
  minio2:
    image: minio/minio:RELEASE.2023-12-02T10-51-33Z
    container_name: minio2
    restart: always
    ports:
      - 9000:9000
      - 9001:9001
    network_mode: "host"
    environment:
      - MINIO_ROOT_USER=minio
      - MINIO_ROOT_PASSWORD=minio123
      - TZ=Asia/Shanghai
    command: server --address ":9000" --console-address ":9001" http://192.168.40.174/data1 http://192.168.40.174/data2 http://192.168.40.175/data1 http://192.168.40.175/data2 http://192.168.40.176/data1 http://192.168.40.176/data2
    volumes:
      - /etc/localtime:/etc/localtime
      - ./minio/data2-1:/data1
      - ./minio/data2-2:/data2
176
version: "3"
services:
  minio3:
    image: minio/minio:RELEASE.2023-12-02T10-51-33Z
    container_name: minio3
    restart: always
    ports:
      - 9000:9000
      - 9001:9001
    network_mode: "host"
    environment:
      - MINIO_ROOT_USER=minio
      - MINIO_ROOT_PASSWORD=minio123
      - TZ=Asia/Shanghai
    command: server --address ":9000" --console-address ":9001" http://192.168.40.174/data1 http://192.168.40.174/data2 http://192.168.40.175/data1 http://192.168.40.175/data2 http://192.168.40.176/data1 http://192.168.40.176/data2
    volumes:
      - /etc/localtime:/etc/localtime
      - ./minio/data3-1:/data1
      - ./minio/data3-2:/data2

因为在174的虚拟机上使用了nginx做了代理分发流量,所以需要在174 修改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 192.168.40.174:9000;
        server 192.168.40.175:9000;
        server 192.168.40.176:9000;
    }

    upstream console {
        ip_hash;
        server 192.168.40.174:9001;
        server 192.168.40.175:9001;
        server 192.168.40.176:9001;
    }

    server {
        listen       8080;
        listen  [::]:8080;
        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;
        proxy_request_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       8081;
        listen  [::]:8081;
        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;
        proxy_request_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;
        }
    }
}
四、备注

# 登陆地址
# 因为设置了nginx负载均衡,所以登陆后会跳转到某个节点的IP
http://192.168.40.174:8080/
账号密码
minio 
minio123

# 集群参数,增加任意节点以及data数据,后边增加依次排列,
server --address ":9000" --console-address ":9001" http://192.168.40.174/data1 http://192.168.40.174/data2 http://192.168.40.175/data1 http://192.168.40.175/data2 http://192.168.40.176/data1 http://192.168.40.176/data2 xxxxxxx 

你可能感兴趣的:(docker,容器,运维)