环境:4节点服务器集群(192.168.2.1/2/3/4),每节点4块硬盘,一台Nginx做负载均衡,本文主要记录4个节点的配置,操作系统是Centos7。
1.网络设置和防火墙
每个节点都应该具有对部署中其他每个节点的完全双向网络访问权限。设置防火墙规则,以下命令明确打开运行firewalld的服务器的默认MinIO服务器API端口 9000 :
firewall-cmd --permanent --zone=public --add-port=9000/tcp
firewall-cmd --reload
部署中的所有MinIO服务器 必须 使用相同的监听端口。
如果您设置了一个静态的MinIO控制台端口(例如 9001 ), 则还必须授予对该端口的访问权限,以确保来自外部客户端的连接。
2.布署分布式MinIO服务器
用于运行 Linux 操作系统的 Intel 64 位处理器的 MinIO 服务器安装文件二进制包,使用以下命令下载安装最新版本的稳定 MinIO二进制包, 并设置 $PATH :
wget https://dl.minio.org.cn/server/minio/release/linux-amd64/minio
chmod +x minio
sudo mv minio /usr/local/bin/
3.创建 systemd 系统启动服务文件,对于二进制安装,请在所有 MinIO 主机上手动创建此文件。
备注: systemd 命令启动前,系统内部会检查 /etc/systemd/... 这个路径,是否存在启动系统文件,如果冲突请在 /usr/lib/systemd/... 路径,找到对应文件,避免重复创建后的冲突。并且,为了避免冲突或意外的配置选项,请确保该文件仅存在于 /usr/lib/systemd/system/minio.service 。
[Unit]
Description=MinIO
Documentation=https://minio.org.cn/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
# MinIO RELEASE.2023-05-04T21-44-30Z adds support for Type=notify (https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=)
# This may improve systemctl setups where other services use `After=minio.server`
# Uncomment the line to enable the functionality
# Type=notify
# 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})
4.创建系统用户名和用户组
minio.service 文件默认以 minio-user 用户和组身份运行。 您可以使用 groupadd 和 useradd 命令创建用户和组。以下示例创建用户、组并设置权限以访问MinIO预定用于存储的文件夹路径。 这些命令通常需要管理员 ( sudo ) 权限。
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拟用于使用的这些驱动器的路径。
5.创建服务环变变量配置文件
创建一个环变变量配置文件在 /etc/default/minio 路径.。MinIO 服务使用此文件作为所有内容的来源 ,环境变量使用 MinIO 和 minio.service 文件。
修改示例以反映您的部署拓扑:
# 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="http://192.168.2.{1...4}:9000/mnt/disk{1...4}"
# Set all MinIO server options
#
# The following explicitly sets the MinIO控制台 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
# deployment.
#
# 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
6.运行和启动MinIO服务器进程
生成用户账户和规定以控制对部署的访问:
sudo systemctl start minio.service
使用以下命令确认服务是否在线和功能正常:
sudo systemctl status minio.service
journalctl -f -u minio.service
备注:MinIO在服务器处理连接和同步时可能会记录大量非关键性警告。 这些警告通常是短暂的, 在部署上线后应该会解决。在 RELEASE.2023-02-09T05-16-53Z 版本发生变更: 如果MinIO检测到足够的驱动器以满足部署的 写入仲裁需要,则会启动MinIO,如果不满足则会启动失败。
如果在启动MinIO后任何驱动器仍处于离线状态,请检查和修复阻止其功能的任何问题,然后再开始生产工作负载。
MinIO服务不会在主机重新启动时自动启动。 您必须使用 systemctl enable minio.service 将进程作为主机引导的一部分,在服务器重启的过程中该进程会自动重启,而不用再进行手动管理。
7.打开MinIO控制台
打开浏览器并访问端口 :9001 处的任何 MinIO 主机名 打开 MinIO控制台登录页面。 例如: http://192.168.2.1:9001
使用 MINIO_ROOT_USER 和 MINIO_ROOT_PASSWORD 登录 从上一步开始。

您可以使用MinIO控制台进行常规管理任务, 如身份和访问管理、指标和日志监控以及服务器配置。 每个MinIO服务器都包含了自己的内嵌 MinIO控制台。