概述
minio是一个比ceph更轻的存储管理服务,它可以部署在Kubernetes及各种操作系统下。对于Java程序来说,最常有的就是两种使用方法,使用Linux或Kubernetes来集群部署。
Minio的集群其实就是多节点、多驱动器部署,用英文的说法:Multi-Node Multi-Drive,简称:MNMD。
Minio强烈建议,使用XFS格式的磁盘构成的直连式(使用scsi电缆)的JBOD磁盘阵列来作为其后端存储。
前置条件
1、防火墙
在ubuntu操作系统下,默认的情况下并没有安装防火墙,但是在Centos或Fedora的操作系统中,默认是启动防火墙的,因此要么就关闭防火墙,要么就加入过滤条件。
关闭防火墙
systemctl disable firewalld
systemctl stop firewalld或者加入过滤条件
firewall-cmd --permanent --zone=public --add-port=9000/tcp
firewall-cmd --reload2、关闭SeLinux
Ubuntu操作系统是没有启用SeLinux的,Centos及Fedora是需要事先关闭它的。
vim /etc/selinux/config
    SELINUX=disabled
#重新启动
reboot3、Kernel要求
一定要注意:Kernel的版本一定不能低于4.0.0,可以使用如下命令查看自己的服务器的操作系统下集成的kernel的版本是多少:
cat /proc/verion
或
uname -r硬件条件
| 主机名 | IP地址 | 
| minio1.dokbok.com | 192.168.3.36 | 
| minio2.dokbok.com | 192.168.3.37 | 
| minio3.dokbok.com | 192.168.3.38 | 
主机名配置如下,注意此处只列举了minio1服务器的主机名配置文件
127.0.0.1	minio1.dokbok.com
192.168.3.36	minio1.dokbok.com
192.168.3.37	minio2.dokbok.com
192.168.3.38	minio3.dokbok.com
192.168.3.11	minio.dokbok.com所有的操作系统目前均于ubuntu22.04,每一台服务器上都有三块未格式化或者可以格式化的磁盘。
mkfs.xfs /dev/sdb -L DISK1 -f
#如果你的服务器中存在多个磁盘,请按照上面的格式更改应的编号格式即可
mkfs.xfs /dev/sdc -L DISK2 -f
mkfs.xfs /dev/sdd -L DISK3 -f并在/etc/fstab中进行配置,如下:
LABEL=DISK1      /mnt/disk1     xfs     defaults,noatime  0       2
LABEL=DISK2      /mnt/disk2     xfs     defaults,noatime  0       2
LABEL=DISK3      /mnt/disk3     xfs     defaults,noatime  0       2磁盘状态如下图:

安装软件
在第一个节点上下载minio.deb,然后拷贝到其他节点后再进行安装。
wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20221212192727.0.0_amd64.deb -O minio.deb #在各个节点上安装
dpkg -i minio.deb创建minio的数据文件夹并赋权限:
mkdir /mnt/disk1
mkdir /mnt/disk2
mkdir /mnt/disk3
chown -R minio-user.minio-user /mnt/disk1
chown -R minio-user /mnt/disk2
chown -R minio-user /mnt/disk3配置
1、配置minio服务的负载均衡(集群间通讯-基于9000端口的http服务)
集群环境启动的时候,各个节点间需要互相通讯。我们需要配置一个minio服务的负载均衡点,如果不配负载均衡的话就需要指定某一个节点,只有等到该节点启动成功后其他节点才会连入集群。使用nginx配置负载均衡后,所有节点可以一并启动(可以互相查找并连接)。
http {
    include       mime.types;
    default_type  application/octet-stream;
    upstream minio-9000 {
        server 192.168.3.36:9000;
        server 192.168.3.37:9000;
        server 192.168.3.38:9000;
    }
    server {
        listen       9000;
        server_name  minio.dokbok.com;
        ignore_invalid_headers off;
        client_max_body_size 0;
        proxy_buffering off;
        location / {
            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 Host $http_host;
            proxy_connect_timeout 300;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            chunked_transfer_encoding off;
            proxy_pass http://minio-9000;
        }
    }
}2、配置对外的UI服务(基于9001端口的http服务)
http {
    include       mime.types;
    default_type  application/octet-stream;
    upstream minio{
        server 192.168.3.36:9001;
        server 192.168.3.37:9001;
        server 192.168.3.38:9001;
    }
    server {
        listen       443  ssl;
        server_name  minio.dokbok.com;
        ignore_invalid_headers off;
        client_max_body_size 0;
        proxy_buffering off;
        ssl_certificate ssl/dokbok_com.pem;
        ssl_certificate_key ssl/dokbok_com.key;
        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers on;
        location / {
            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 Host $http_host;
            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 80;
        server_name minio.dokbok.com;
        rewrite ^(.*)$  https://$host$1 permanent;
    }
}3、创建minio启动配置文件
vim /etc/default/minio
MINIO_VOLUMES="http://minio{1...3}.dokbok.com:9000/mnt/disk{1...3}/minio"
MINIO_OPTS="--console-address :9001"
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=tdjgamtam
# 此处的值是上述配置的nginx负载均衡的ip地址及端口
MINIO_SERVER_URL="http://minio.dokbok.com:9000"4、配置minio服务
vim /lib/systemd/system/minio.service
[Unit]
Description=MinIO
Documentation=https://min.io/docs/minio/linux/index.html
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
WorkingDirectory=/usr/local
User=minio-user
Group=minio-user
ProtectProc=invisible
EnvironmentFile=-/etc/default/minio
ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi"
ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Specifies the maximum number of threads this process can create
TasksMax=infinity
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
# Built for ${project.name}-${project.version} (${project.name})
配置服务
systemctl enable minio
systemctl start minio