MinIO集群搭建手册

2026.03.22
苦温集 · 部署教程 Linux · MinIO

部署 MinIO 集群

一、先决条件

因 MinIO 集群纠删码机制,需至少 4 个服务器节点,并每台服务器拥有单独挂载的数据盘,不可与系统盘共用。

1、防火墙

  • 开放每台服务器上的 9000 和 9001 端口;
  • 在负载服务器上,开放 9099 和 9199 端口;

CentOS:

firewall-cmd --permanent --zone=public --add-port=9000/tcp
firewall-cmd --permanent --zone=public --add-port=9001/tcp
## 负载服务器端口
firewall-cmd --permanent --zone=public --add-port=9099/tcp
firewall-cmd --permanent --zone=public --add-port=9199/tcp
## 负载服务器端口
firewall-cmd --reload

Ubuntu:

ufw allow 9000
ufw allow 9001
## 负载服务器端口
ufw allow 9099
ufw allow 9199
## 负载服务器端口

2、顺序主机名

MinIO 需要使用扩展表示法 {x...y} 表示创建服务器池时连续的一系列 MinIO 主机。因此,MinIO 需要使用按顺序编号的主机名来表示部署中的每个 minio server 进程。 可在 /etc/hosts 中做映射:

root@zh151:/home/minio# cat /etc/hosts
127.0.0.1 localhost
192.168.5.152 minio2
192.168.12.26 minio3
192.168.12.27 minio4
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

3、磁盘存储

MinIO 强烈建议使用带有 XFS 格式磁盘的直连 JBOD 阵列,以获得最佳性能。

$ mkfs.xfs /dev/sdb -L DISK1
$ mkfs.xfs /dev/sdc -L DISK2
$ mkfs.xfs /dev/sdd -L DISK3
$ mkfs.xfs /dev/sde -L DISK4
$ nano /etc/fstab

/etc/fstab 配置示例:

# <file system>  <mount point>  <type>  <options>         <dump>  <pass>
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
LABEL=DISK4      /mnt/disk4     xfs     defaults,noatime  0       2

注意: MinIO 不支持将具有现有 MinIO 数据的驱动器任意迁移到新的装载位置,无论是有意的还是操作系统级行为的结果。如需迁移,参考进行操作,即先部署新环境,后通过 mc 客户端进行数据转移: minio 集群数据迁移实战:

./mc alias set old http://10.91.129.63:9000
./mc alias set new http://10.91.129.60:9000
## 添加客户端,需要输入用户名密码,old和new是取的别名
./mc admin info new
## 把old的bucket为test的数据迁移到new的test

4、同构节点配置

MinIO 强烈建议为部署中的所有节点选择基本相似的硬件配置。确保硬件(CPU、内存、主板、存储适配器)和软件(操作系统、内核设置、系统服务)在所有节点上保持一致。如果节点具有异构硬件或软件配置,则部署可能会表现出不可预测的性能。受益于在低成本硬件上存储旧数据的工作负载应改为部署专用的“暖”或“冷”MinIO 部署,并将数据转换为该层。

5、基于容量的规划

MinIO 通常建议规划容量,以便仅在部署正常运行时间 2+ 年后才需要扩展服务器池。例如,考虑一个估计每年产生 10TB 数据的应用程序套件。MinIO 部署应至少提供: 10TB + 10TB + 10TB = 30TB。MinIO 建议添加缓冲区存储,以应对存储数据的潜在增长(例如,总可用存储空间为 40TB)。根据经验,最初首选更多容量,而不是频繁的即时扩展以满足容量要求。由于 MinIO 纠删码需要一些存储才能实现奇偶校验,因此总原始存储必须超过计划的可用容量。请考虑使用 MinIO 纠删码计算器来指导围绕特定纠删码设置规划容量。


二、部署分布式 MinIO

以下过程创建一个由单个服务器池组成的新的分布式 MinIO 部署。下面提供的所有命令都使用示例值。将这些值替换为适合您的部署的值。

1、在每个节点上安装 MinIO 二进制文件

CentOS:

wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio-20230324214123.0.0.x86_64.rpm -O minio.rpm
sudo dnf install minio.rpm

Ubuntu:

wget https://dl.min.io/server/minio/release/linux-amd64/minio_20240829014052.0.0_amd64.deb -O minio.deb
sudo dpkg -i minio.deb

2、创建 systemd 服务文件

.deb.rpm 软件包将以下 systemd 服务文件安装到 /usr/lib/systemd/system/minio.service 中。对于二进制安装,请在所有 MinIO 主机上手动创建此文件: /usr/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})

下示例创建用户、组并设置访问供 MinIO 使用的文件夹路径的权限。这些命令通常需要根权限。

groupadd -r minio-user
useradd -M -r -g minio-user minio-user
chown minio-user:minio-user /mnt/disk1 /mnt/disk2 /mnt/disk3 /mnt/disk4

注意:指定的驱动器路径作为示例提供。更改它们以匹配供 MinIO 使用的驱动器的路径。或者,将“User”和“组”值更改为系统主机上具有必要访问权限和权限的其他用户和 Group。

3、创建服务环境文件

/etc/default/minio 创建一个环境文件。MinIO 服务使用此文件作为 MinIO 和 minio.service 文件使用的所有环境变量的源。部署有一个在 https://minio.example.net 上运行的负载均衡器,用于管理所有四个 MinIO 主机之间的连接。 修改示例以反映您的部署拓扑(每台节点上均需此文件,且内容一致): /etc/default/minio 内容:

# Set the hosts and volumes MinIO uses at startup
# The command uses MinIO expansion notation {x...y} to denote a
# sequential series.
#
# The following example covers four MinIO hosts
# with 4 drives each at the specified hostname and drive locations.
# The command includes the port that each MinIO server listens on
# (default 9000)
MINIO_VOLUMES="https://minio{1...4}.example.net:9000/mnt/disk{1...4}/minio"
# Set all MinIO server options
#
# The following explicitly sets the MinIO Console listen address to
# port 9001 on all network interfaces. The default behavior is dynamic
# port selection.
MINIO_OPTS="--console-address :9001"
# Set the root username. This user has unrestricted permissions to
# perform S3 and administrative API operations on any resource in the
#
# Defer to your organizations requirements for superadmin user name.
MINIO_ROOT_USER=minioadmin
# Set the root password
#
# Use a long, random, unique string that meets your organizations
# requirements for passwords.
MINIO_ROOT_PASSWORD=minio-secret-key-CHANGE-ME
# Set to the URL of the load balancer for the MinIO deployment
# This value *must* match across all MinIO servers. If you do
# not have a load balancer, set this value to to any *one* of the
# MinIO hosts in the deployment as a temporary measure.
MINIO_SERVER_URL="https://minio.example.net:9000"

您可以根据部署的需要指定其他环境变量或服务器命令行选项。部署中的所有 MinIO 节点都应包含相同的环境变量,每个变量的值相同。

4、添加 TLS/SSL 证书

暂时用不上,略过。

5、运行 MinIO 服务器进程

在部署中的每个节点上发出以下命令以启动 MinIO 服务:

sudo systemctl start minio.service

使用以下命令确认服务处于联机状态且正常运行:

sudo systemctl status minio.service
journalctl -f -u minio.service

版本更新 2023-02-09T05-16-53Z: 如果 MinIO 检测到足够的驱动器来满足部署的写入仲裁,它将启动。如果任何驱动器在启动 MinIO 后保持脱机状态,请在启动生产工作负载之前检查并解决阻止其功能的任何问题。

6、打开 MinIO 控制台

打开浏览器并访问端口 :9001 中的任何 MinIO 主机名以打开 MinIO 控制台登录页面。例如:https://minio1.example.com:9001。 使用上一步中的 MINIO_ROOT_USERMINIO_ROOT_PASSWORD 登录。 MinIO 控制台登录页面 您可以使用 MinIO 控制台执行常规管理任务,例如身份和访问管理、指标和日志监控或服务器配置。每个 MinIO 服务器都包含自己的嵌入式 MinIO 控制台。


参考