Docker compose deploy MinIO distributed cluster

Docker compose deploy MinIO distributed cluster

summary

MinIO is the world's leading pioneer in object storage, with millions of users worldwide.

  • High performance. On standard hardware, the read / write speed is as high as 183GB / s and 171GB / s, with higher throughput and lower latency
  • Scalability, which brings a simple scaling model for object storage. You can expand the space by adding more clusters
  • Simplicity and minimalism are the guiding design principles of MinIO, which can be installed and configured in a few minutes
  • Compatible with Amazon S3, Amazon cloud's S3 API (Interface Protocol) is a globally agreed object storage protocol and a recognized standard all over the world
  • Data security, using erasure code to protect data from hardware failure and silent data damage

Erasure code

The N/2 parity check algorithm is used to correct the data loss, and the N/2 parity check algorithm is used to correct the data loss. This means that if there are 16 disks, an object will be divided into 8 data blocks and 8 parity blocks. You can lose any 8 disks (whether they are stored data blocks or parity blocks), and you can still recover the data from the remaining disks.

deploy

The official recommendation is docker compose yaml: Download address

With minor modifications, it reads as follows:

version: '3.7'

# Settings and configurations common to all containers
x-minio-common: &minio-common
  image: minio/minio
  command: server --console-address ":9001" http://minio{1...4}/data
  expose:
    - "9000"
  # environment:
    # MINIO_ROOT_USER: minioadmin
    # MINIO_ROOT_PASSWORD: minioadmin
  healthcheck:
    test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
    interval: 30s
    timeout: 20s
    retries: 3

# Start four docker containers and run the minio server instance
# Using nginx reverse proxy 9000 port and load balancing, you can access their web console through ports 9001, 9002, 9003 and 9004
services:
  minio1:
    <<: *minio-common
    hostname: minio1
    ports:
      - "9001:9001"
    volumes:
      - ./data/data1:/data

  minio2:
    <<: *minio-common
    hostname: minio2
    ports:
      - "9002:9001"
    volumes:
      - ./data/data2:/data

  minio3:
    <<: *minio-common
    hostname: minio3
    ports:
      - "9003:9001"
    volumes:
      - ./data/data3:/data

  minio4:
    <<: *minio-common
    hostname: minio4
    ports:
      - "9004:9001"
    volumes:
      - ./data/data4:/data

  nginx:
    image: nginx:1.19.2-alpine
    hostname: nginx
    volumes:
      - ./config/nginx.conf:/etc/nginx/nginx.conf:ro
    ports:
      - "9000:9000"
    depends_on:
      - minio1
      - minio2
      - minio3
      - minio4

Then create a new folder config and a new configuration nginx conf

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;
        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 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;
        }
    }

}

Execute the startup command and see the health status of each node

docker-compose up -d

to configure

The browser accesses the web console of any node for simple configuration, and the configuration will be synchronized between nodes automatically

After creating Buckets, select Manage and configure Access Policy in the Summary

Select Settings - Configuration, select Scanner, and configure Max Wait and Cycle to 1s, which can greatly speed up the synchronization efficiency between nodes

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-dycn6ke-1649771651586)( http://xiguapengpeng.gitee.io/imgtu/blog/post_img_20220412102249.png )]

Tags: Docker Load Balance Distribution Container

Posted by kkeim on Tue, 12 Apr 2022 22:33:28 +0300