单机docker-compose部署minio

单机多副本docker-compose部署minio

简单介绍

如果服务器有限可以单机挂载多硬盘实现多副本容错(生产不推荐)

部署好的文件状态

有两个重要文件 docker-compose.yamlnginx.conf

docker-compose.yaml是docker部署容器的配置信息包括4个minio和1个nginx容器

部署好的状态

操作步骤
  1. 安装docker

    bash 复制代码
    yum install docker
  2. 安装docker-compose

    bash 复制代码
     curl -L https://github.com/docker/compose/releases/download/1.21.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
     
  1. 放置配置docker-compose.yaml文件和nginx.conf

    mkdir /home/minios/ #创建文件夹
    
  1. 运行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检查是否成功
    
  2. 创建文件桶

docker-compose.yaml
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-28Z
    volumes:
      - ./data1-1:/data1
      - ./data1-2:/data2
    expose:
      - "9000"
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: minio123
    command: server http://minio{1...4}/data{1...2}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3
    networks:
      - fjjminio
    restart: always

  minio2:
    image: minio/minio:RELEASE.2021-04-22T15-44-28Z
    volumes:
      - ./data2-1:/data1
      - ./data2-2:/data2
    expose:
      - "9000"
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: minio123
    command: server http://minio{1...4}/data{1...2}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3
    networks:
      - fjjminio
    restart: always

  minio3:
    image: minio/minio:RELEASE.2021-04-22T15-44-28Z
    volumes:
      - ./data3-1:/data1
      - ./data3-2:/data2
    expose:
      - "9000"
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: minio123
    command: server http://minio{1...4}/data{1...2}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3
    networks:
      - fjjminio
    restart: always

  minio4:
    image: minio/minio:RELEASE.2021-04-22T15-44-28Z
    volumes:
      - ./data4-1:/data1
      - ./data4-2:/data2
    expose:
      - "9000"
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: minio123
    command: server http://minio{1...4}/data{1...2}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3
    networks:
      - fjjminio
    restart: always

  nginx:
    image: nginx:1.19.2-alpine
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    ports:
      - "9000:9000"
    depends_on:
      - minio1
      - minio2
      - minio3
      - minio4
    networks:
      - fjjminio
    restart: always

networks:
  fjjminio:
nginx.conf
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 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 50m;
         # 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;
        }
    }
}
相关推荐
韦德斯24 分钟前
嵌入式Linux的RTC读写操作应用
linux·运维·c语言·arm开发·实时音视频
程序员JerrySUN28 分钟前
熟悉的 Docker,陌生的 Podman
linux·docker·容器·系统架构·podman
哎呦喂-ll40 分钟前
Linux进阶:常用操作
linux·运维·服务器
m0_6446973342 分钟前
DNS域名解析服务器
linux·运维·服务器
长囧鹿1 小时前
云原生之k8s服务管理
云原生·容器·kubernetes
Oliver_LaVine1 小时前
linux搭建Gray
运维
gobeyye1 小时前
Docker 用法详解
运维·docker·容器
小灰灰__2 小时前
Linux离线安装Docker命令,简单镜像操作
linux·docker·eureka
怡雪~2 小时前
centos7.9搭建k8s集群
云原生·容器·kubernetes
VVVVWeiYee2 小时前
Mesh路由组网
运维·网络·智能路由器·信息与通信