Linux下快速部署多节点多硬盘架构MinIO
由于测试环境资源有限,本文旨在以多节点单硬盘的方式演示集群架构部署配置方法,多节点多硬盘在MINIO_VOLUMES
环境变量指定多个驱动器路径就行了,没啥区别。
下载MinIO服务器文件
这个步骤中介绍了如何在一个单节点单驱动(SNSD)的配置中部署MinIO,用于早期的开发和评估。 SNSD 部署不会提供任何超出底层存储卷实现的额外可靠性或可用性(RAID,LVM,ZFS等)。 SNSD 部署使用零奇偶校验的纠删码后端,这提供的可靠性或可用性与底层存储卷实现的一致,没有额外的可靠性或可用性。 这些部署最适合用于本地测试和评估,或者用于没有可用性或性能要求的小规模数据工作负载。
对于扩展开发或生产环境,将MinIO部署在 多节点多磁盘 (分布式) 网络拓扑中。
使用以下命令下载安装最新版本的稳定 MinIO二进制包, 并设置
$PATH
:
wget https://dl.minio.org.cn/server/minio/release/linux-amd64/minio
chmod +x minio
mv minio /usr/local/bin/
创建 systemd
系统启动服务文件
[root@minio-01 ~]# vim /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})
默认情况下, minio.service
文件以 minio-user
用户和组的身份运行。 您可以使用 groupadd
和 useradd
创建用户和组。 命令。下面的示例创建了用户和组,并设置了权限 来访问供 MinIO 使用的文件夹路径。这些命令通常 需要 root ( sudo
) 权限。
groupadd -r minio-user
useradd -M -r -g minio-user minio-user
mkdir /data/minio
chown minio-user:minio-user /data/minio
本例中的驱动器路径由 MINIO_VOLUMES 环境变量指定。更改此处和环境变量文件中的值,使其与 MinIO 打算使用的驱动器路径相匹配。
创建服务环境变量配置文件
在 /etc/default/minio
创建环境变量文件。 MinIO 服务器容器可以将此文件作为所有 environment variables 。
下面的示例提供了一个起始环境文件:
[root@minio-01 ~]# cat /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="http://minio-01:9000/data/minio http://minio-02:9000/data/minio http://minio-03:9000/data/minio http://minio-04:9000/data/minio"
# 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=admin
# Set the root password
#
# Use a long, random, unique string that meets your organizations
# requirements for passwords.
MINIO_ROOT_PASSWORD=Rb992334%
运行和启动MinIO服务器进程
生成用户账户和规定以控制对部署的访问:
systemctl start minio.service
使用以下命令确认服务是否在线和功能正常:
systemctl status minio.service
journalctl -f -u minio.service
MinIO在服务器处理连接和同步时可能会记录大量非关键性警告。 这些警告通常是短暂的, 在部署上线后应该会解决。
在 RELEASE.2023-02-09T05-16-53Z 版本发生变更: 如果MinIO检测到足够的驱动器以满足部署的 写入仲裁 需要,则会启动MinIO,如果不满足则会启动失败。
如果在启动MinIO后任何驱动器仍处于离线状态,请检查和修复阻止其功能的任何问题,然后再开始生产工作负载。
MinIO服务不会在主机重新启动时自动启动。 您必须使用 systemctl enable minio.service
将进程作为主机引导的一部分,在服务器重启的过程中该进程会自动重启,而不用再进行手动管理。
systemctl enable minio.service
打开MinIO控制台
打开浏览器并访问端口 :9001
处的任何MinIO主机名打开 MinIO控制台 登录页面。 例如, https://minio1.example.com:9001
.
使用服务环境变量配置文件中设置的MINIO_ROOT_USER和MINIO_ROOT_PASSWORD登录。