1. 新能参数

image.png

2. 分布式MinIO的特性

官方推荐:集群最小4台服务器
在大数据领域,通常的设计理念就是无中心和分布式,MinIO分布式模式可以帮你搭建一个高可用对象存储服务,可以使用这些设备的存储,但不需要去关心真实的物理地址。

  • 数据保护 — erasure code(纠删码)来防范多节点宕机和位衰减bit rot
  • 高可用 — 单机MinIO服务存在单点故障,相反,一个N节点的分布式MinIO,只有N/2节点在线,数据就是安全的。不过需要至少 N/2+1个节点Quorum来创建对象。
  • 限制 — 分布式MinIO单租户存在至少4个硬盘,最多16盘限制(受限于纠偏码);这种限制确保了MinIO的见解,但仍拥有伸缩性。如果需要多租户,需要使用Kubernetes来管理多个MinIO实例。
  • 一致性 — MinIO分布式和单机模式下,所有读写严格遵守read-after-writer 的一致性模型。

部署注意点

  • 所有运行分布式 MinIO 的节点需要具有相同的访问密钥和秘密密钥才能连接。建议在执行 MINIO 服务器命令之前,将访问密钥作为环境变量,MINIO access key 和 MINIO secret key 导出到所有节点上 。
  • Minio 创建4到16个驱动器的擦除编码集。
  • Minio 选择最大的 EC 集大小,该集大小除以给定的驱动器总数。 例如,8个驱动器将用作一个大小为8的 EC 集,而不是两个大小为4的 EC 集 。
  • 建议所有运行分布式 MinIO 设置的节点都是同构的,即相同的操作系统、相同数量的磁盘和相同的网络互连 。
  • 运行分布式 MinIO 实例的服务器时间差不应超过15分钟。
  1. # 伪分布式,通过不同的端口实现模拟不同服务器的部署
  2. RUNNING_USER=root
  3. MINIO_HOME=/opt/minio
  4. MINIO_HOST=192.168.222.10
  5. #accesskey and secretkey
  6. ACCESS_KEY=minio
  7. SECRET_KEY=minio123
  8. for i in {01..04}; do
  9. START_CMD="MINIO_ACCESS_KEY=${ACCESS_KEY} MINIO_SECRET_KEY=${SECRET_KEY} \
  10. nohup ${MINIO_HOME}/minio server --address "${MINIO_HOST}:90${i}" \
  11. http://${MINIO_HOST}:9001/opt/min-data1 \
  12. http://${MINIO_HOST}:9002/opt/min-data2 \
  13. http://${MINIO_HOST}:9003/opt/min-data3 \
  14. http://${MINIO_HOST}:9004/opt/min-data4 > ${MINIO_HOME}/minio-90${i}.log 2>&1 &" \
  15. su - ${RUNNING_USER} -c "${START_CMD}"
  16. done
# 分布式部署
## 1. 安装minIO
wget http://dl.minio.org.cn/server/minio/release/linux-amd64/minio
mv minio /usr/local/bin/
chmod +x /usr/local/bin/minio


## 2. 每个服务器上实例执行
mkdir -p /opt/minio/        # 创建启动脚本目录
mkdir -p /etc/minio/        # 创建配置文件目录

#### 安装用的脚本 ####
vim /opt/minio/run.sh

#!/bin/bash
export MINIO_ACCESS_KEY=<ACCESS_KEY>     # 指定访问的用户名
export MINIO_SECRET_KEY=<SECRET_KEY>     # 指定访问的密码
/opt/minio/minio server --config-dir /etc/minio \ 
               http://192.168.1.11/export1 http://192.168.1.12/export2 \
               http://192.168.1.13/export3 http://192.168.1.14/export4 \
               http://192.168.1.15/export5 http://192.168.1.16/export6 \
               http://192.168.1.17/export7 http://192.168.1.18/export8

## 3.编写服务的脚本
vim /usr/lib/systemd/system/minio.service

[Unit] 
Description = Minio service
Documentation=https://docs.minio.io/

[Service]
WorkingDirectory=/opt/minio
ExecStart=/opt/minio/run.sh

Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

#### 添加执行权限
sudo chmod a+x /usr/lib/systemd/system/minio.service


## 4.获取minio
cd /opt/minio
wget https://dl.minio.io/server/minio/release/linux-amd64/minio
sudo chmod a+x minio
sudo chmod a+x run.sh

## 5.更新并配置随机自启
systemctl daemon-reload
systemctl enable minio
systemctl start minio

3. Nginx的配置

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

   upstream minio {
        server 172.16.3.28:9000 fail_timeout=10s max_fails=2 weight=1;
        server 172.16.3.29:9000 fail_timeout=10s max_fails=2 weight=1;
        server 172.16.3.30:9000 fail_timeout=10s max_fails=2 weight=1;
    }

   upstream minio-console {
        server 172.16.3.28:10001 fail_timeout=10s max_fails=2 weight=1;
        server 172.16.3.29:10001 fail_timeout=10s max_fails=2 weight=1;
        server 172.16.3.30:10001 fail_timeout=10s max_fails=2 weight=1;
    }

    server {
        listen       10000;
        root         /usr/share/nginx/html;
       client_max_body_size        100m; # 文件最大不能超过100MB
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        proxy_pass http://minio;
        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 $remote_addr;
        proxy_set_header Host $http_host;
    }

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }

    server {
        listen       11000;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
                proxy_pass http://minio-console;
                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 $remote_addr;
                proxy_set_header Host $http_host;
        }

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }
}