MinIO分布式部署

本文翻译自MinIO官网:部署MinIO(多节点多驱动器:https://min.io/docs/minio/linux/operations/install-deploy-manage/deploy-minio-multi-node-multi-drive.html)

MinIO使用纠删码( Erasure Coding)来做数据的备份和数据恢复,

先决条件

网络和防火墙

网络

分布式部署中每一个节点需要保证网络的畅通,如果是使用容器化或者编排的基础架构,可能需要额外配置网络和路由组件。

防火墙

对于Linux来说如果启用了防火墙功能,需要通过如下命令开启MinIO-Server的api端口(9000)和Minio-Server的WebUI访问端口(9001)


firewall-cmd --permanent --zone=public --add-port=9000/tcp

firewall-cmd --reload

对于WebUI访问端口可参考MinIO-Server的api端口开启方式进行操作。另外需要说明的是WebUI访问端口通常可以通过启动命令或者配置文件修改为用户自定义的端口,并非固定为9001.

负载均衡

MinIO强烈建议使用负载均衡器来管理MinIOServer簇。一般来说负载均衡器应使用“最少连接数”算法来路由请求。

已知如下负载均衡器可以和MinIO很好的配合:

  • Nginx
  • HAProxy

顺序的主机名

当MinIO分布式部署的时候,需要使用“扩展表示法”来表示一系列的MinIO服务器主机:

  • 连续的主机名:minioserver1.com,minioserver2.com,minioserver3.com,minioserver4.com
  • 连续的ip:192.156.1.101,192.156.1.102,192.156.1.103,192.156.1.104

使用扩展表示法则为:

  • minioserver{1...4}.com
  • 192.168.1.10

MinIO在分布式部署的时候要求主机名必须是顺序的,当无法满足此要求的时候可以通过手动修改每一个服务器主机的 hosts 文件来添加DNS映射,从而变相支持顺序主机名。

驱动器要求

XFS格式性能最优

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

  • 直连存储(DAS)的性能比网络存储(NAS,SAN,NFS)性能有显著提高。
  • 使用非XFS格式文件系统(ext4,btrfs,zfs)部署的MinIO性能往往比较地下,并且不稳定,容易发生意料之外的事情
  • RAID技术并不会带来性能的提升,并且通常会降低性能,所以不建议在MinIO分布式部署中使用RAID磁盘阵列技术。

最小IO

需要使用相同的硬盘类型(NVMe,SSD,HDD),并且它们应该具有相同的容量。此外,最小IO限制了硬盘的使用量,例如:如果部署15个10TB的启动器和1个1TB的驱动器,MinIO会限制每一个驱动器容量上限为1TB。

顺序的驱动器名

和主机名类似的,驱动器的名字也要求是顺序的,例如:
/mnt/data1,/mnt/data2,/mnt/data3,/mnt/data4

扩展表示法为:

/mnt/data{1...4}

任意迁移

MinIO不支持使用现有的MinIO任意迁移驱动器,也就是说如果一个驱动器硬盘已经被一个MinIOServer使用了,就不可以作为扩展硬盘纳入到MinIOServer集群中。

时间同步

多节点系统必须保持同步的时间和日期,以保持稳定的节点间操作和交互。 确保所有节点定期同步到同一时间服务器。

考虑

相同的硬软件环境

MinIO强烈建议所运行的环境配置尽量相同,如
硬件(CPU、 内存、主板、存储适配器)和软件(操作系统、内核、 设置、系统服务)在所有节点上保持一致。

存储容量规划

MinIO建议规划“2年+”的容量,例如,如果系统每年产生10TB的数据,那么建议部署的时候每一个节点为30TB.

推荐的操作系统

推荐使用linux来部署MinIOServer

  • RHEL8+
  • Ubuntu 18.04+

预先存在的数据

MinIO启动后所管理的硬盘驱动器应该是空的,不应预先存放任何文件。

如果之前已经有文件了, MinIO无法管理这些文件,无法通过MinIO的api或者webui浏览到预先存在的数据。

与MinIO-server的交互仅能通过如下途径:

  • S3-API(9000端口)
  • WebUI(9001端口)
  • SDK:java、C# 等

部署分布式MinIO

在每一个节点上安装MinIO

可通过RPM、DEB或者二进制文件的方式在服务器上面安装MinIO-server

创建服务文件minio.service

对于RPM和DEB方式安装,服务文件将由安装程序创建。

对于二进制方式安装需要手动创建此文件。

/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
#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})


  • EnvironmentFile:环境文件

systemd程序在扫描的时候使用它找到的第一个文件,为了避免冲突和意外的发生,请检查minio.service文件是否在如下路径中没有重复:

  • /etc/systemd/...
  • /usr/lib/systemd/...
  • /usr/lib/systemd/system/...

默认情况下文件以用户和组身份运行,以下示例代码创建用户、组并设置可执行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.service启动的时候会读取这个文件。

在 /etc/defalt/ 下面创建 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
#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
#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"


添加TLS/SSL证书

这一步是可选的

运行MinIO服务进程

分别在每一个节点上运行如下命令来启动MinIO进程:


sudo systemctl start minio.service

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


sudo systemctl status minio.service

journalctl -f -u minio.service

将minio.service添加到开机自启动:


sudo systemctl enable minio.service

访问MinIO控制台

http://ip:9001
登录账号密码为:minio_root_user,
minio_root_password

您可以使用 MinIO 控制台执行常规管理任务,例如 身份和访问管理、指标和日志监控,或 服务器配置

说明

  • 不是简单的直译,按照自己的理解渲染了部分语言
  • 可能存在错误和漏掉的地方
  • 官网本身对分布式部署讲的特别的简单
  • 如果有用,希望一键三连 =_=+
posted @ 2023-09-18 15:10  Naylor  阅读(672)  评论(0编辑  收藏  举报