MinIO 高性能分布式存储最新版单机与分布式部署

发布时间 2023-10-29 18:56:23作者: 大数据老司机

一、概述

MinIO 是一个开源的对象存储服务器,用于存储和管理大规模的非结构化数据,例如图像、视频、日志文件、备份和容器镜像。MinIO 旨在提供高性能、高可用性、可扩展性和易用性的对象存储解决方案,适用于私有云、公共云和混合云环境。

以下是 MinIO 的主要特点和介绍:

  • 开源和自由MinIO 是一个开源项目,根据 Apache License 2.0 许可证发布,这意味着您可以免费使用、修改和分发它。

  • 对象存储MinIO 是一种对象存储系统,它使用存储桶(buckets)来组织数据,每个存储桶包含多个对象。对象可以是各种文件、文档、媒体和其他非结构化数据。

  • 高性能MinIO 具有出色的性能,能够以高速处理大规模数据。它采用了分布式、并行和多线程处理技术,以支持高吞吐量和低延迟。

  • 高可用性MinIO 具有内置的冗余和故障转移功能,支持数据备份和多副本存储,以确保数据的持久性和高可用性。它还支持数据版本控制。

  • 容器化MinIO 可以轻松部署在容器化环境中,如DockerKubernetes。这使得它适用于云原生应用和容器化工作负载。

  • 分布式扩展MinIO 支持分布式架构,可以轻松扩展以适应不断增长的数据需求。您可以添加更多的MinIO实例以构建多节点集群。

  • S3 兼容MinIO 提供了S3(Simple Storage Service) API 兼容性,这意味着它可以与现有的S3客户端和应用程序集成,无需进行大规模修改。

  • 安全性MinIO 提供数据加密、身份验证和访问控制功能,以确保数据的保密性和完整性。它还支持SSL/TLS加密。

  • 易用性MinIO 的配置和管理非常简单,具有用户友好的命令行界面和Web管理控制台。它还有丰富的文档和活跃的社区支持。

MinIO 是一个功能强大且易于使用的对象存储解决方案,适用于各种应用,从数据备份和存档到大规模媒体存储和分析。它为云原生环境提供了一个强大的存储选项,并且由于其开源性质,广受开发者和组织的欢迎。

官方文档:https://min.io/docs/minio/linux/index.html

以前也写过蛮多 MinIO 的文章,可以参考以下:

在这里插入图片描述

二、单机部署(单主机,多硬盘模式)

在这里插入图片描述
官方部署文档:https://min.io/docs/minio/linux/operations/install-deploy-manage/deploy-minio-single-node-multi-drive.html

1)磁盘初始化

mkfs.xfs /dev/sdb -L DISK1
mkfs.xfs /dev/sdc -L DISK2
mkfs.xfs /dev/sdd -L DISK3
mkfs.xfs /dev/sde -L DISK4

mkdir /data{1..4}

vi /etc/fstab

  # <file system>  <mount point>  <type>  <options>         <dump>  <pass>
  LABEL=DISK1      /data1         xfs     defaults,noatime  0       2
  LABEL=DISK2      /data2         xfs     defaults,noatime  0       2
  LABEL=DISK3      /data3         xfs     defaults,noatime  0       2
  LABEL=DISK4      /data4         xfs     defaults,noatime  0       2
  • file system Label 就是分区的标签,在最初安装系统是填写的挂载点就是标签的名字。使用设备名(例如:/dev/sdb)labeluuid 作为标识的不同。这里使用的是 lable

  • mount point 挂载目录。

  • type 文件系统类型,包括xfs、ext2、ext3、ext4、reiserfs、nfs、vfat等。

  • options 文件系统的参数,参数如下:

    • Async/sync:设置是否为同步方式运行,默认为async
    • auto/noauto:当执行 mount -a 的命令时,此文件系统是否被主动挂载。默认为auto
    • rw/ro:是否以以只读或者读写模式挂载
    • exec/noexec:限制此文件系统内是否能够进行"执行"的操作
    • user/nouser:是否允许用户使用mount命令挂载
    • suid/nosuid:是否允许SUID的存在
    • Usrquota:启动文件系统支持磁盘配额模式
    • Grpquota:启动文件系统对群组磁盘配额模式的支持
    • Defaults:同事具有rw,suid,dev,exec,auto,nouser,async等默认参数的设置
  • dump 是一个用来作为备份的命令参数值解释如下:

    • 0 代表不要做dump备份
    • 1代表要每天进行dump的操作
    • 2代表不定日期的进行dump操作

2)创建服务启动用户并设置磁盘属主

groupadd -r minio-user
useradd -M -r -g minio-user minio-user
chown minio-user:minio-user /data{1..4}

3)下载 minio 安装包

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

4)修改配置

vi /etc/default/minio

# MINIO_ROOT_USER and MINIO_ROOT_PASSWORD sets the root account for the MinIO server.
# This user has unrestricted permissions to perform S3 and administrative API operations on any resource in the deployment.
# Omit to use the default values 'minioadmin:minioadmin'.
# MinIO recommends setting non-default values as a best practice, regardless of environment.

MINIO_ROOT_USER=myminioadmin
MINIO_ROOT_PASSWORD=myminioadmin

# MINIO_VOLUMES sets the storage volumes or paths to use for the MinIO server.
# The specified path uses MinIO expansion notation to denote a sequential series of drives between 1 and 4, inclusive.
# All drives or paths included in the expanded drive list must exist *and* be empty or freshly formatted for MinIO to start successfully.

MINIO_VOLUMES="/data{1...4}"

# MINIO_SERVER_URL sets the hostname of the local machine for use with the MinIO Server.
# MinIO assumes your network control plane can correctly resolve this hostname to the local machine.

# Uncomment the following line and replace the value with the correct hostname for the local machine.

#MINIO_SERVER_URL="http://minio.example.net"

5)配置 systemctl 启动

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

启动服务

sudo systemctl daemon-reload
sudo systemctl start minio.service
sudo systemctl status minio.service
journalctl -f -u minio.service
# 从日志里可以看到访问入口地址,也可以看/var/log/messages

【温馨提示】如果需要加磁盘,必须先把这个这个目录删掉,要不然无法启动,/data{1..4}/.minio.sys,报错:ERROR Unable to initialize backend: /data1 drive is already being used in another erasure deployment. (Number of drives specified: 5 but the number of drives found in the 1st drive's format.json: 4)

web 访问:

在这里插入图片描述
账号/密码(配置文件中的配置):myminioadmin/myminioadmin

在这里插入图片描述
在这里插入图片描述

6)客户端工具 mc

wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
sudo mv mc /usr/local/bin/mc

配置

# mc alias set <ALIAS> <YOUR-MINIO-ENDPOINT> [YOUR-ACCESS-KEY] [YOUR-SECRET-KEY]
mc alias set local http://192.168.182.110:9000 myminioadmin myminioadmin
mc admin info local

# 创建桶
# 并创建bucket harbor
mc mb local/test
mc ls local

在这里插入图片描述
更多 mc 客户端命令操作可以参考官方文档:https://min.io/docs/minio/linux/reference/minio-mc.html

三、分布式集群部署(多主机、多硬盘模式)

在这里插入图片描述
官方部署文档:https://min.io/docs/minio/linux/operations/install-deploy-manage/deploy-minio-multi-node-multi-drive.html#deploy-minio-distributed

1)磁盘初始化

mkfs.xfs /dev/sdb -L DISK1
mkfs.xfs /dev/sdc -L DISK2
mkfs.xfs /dev/sdd -L DISK3
mkfs.xfs /dev/sde -L DISK4

mkdir /data{1..4}

vi /etc/fstab

  # <file system>  <mount point>  <type>  <options>         <dump>  <pass>
  LABEL=DISK1      /data1         xfs     defaults,noatime  0       2
  LABEL=DISK2      /data2         xfs     defaults,noatime  0       2
  LABEL=DISK3      /data3         xfs     defaults,noatime  0       2
  LABEL=DISK4      /data4         xfs     defaults,noatime  0       2
  • file system Label 就是分区的标签,在最初安装系统是填写的挂载点就是标签的名字。使用设备名(例如:/dev/sdb)labeluuid 作为标识的不同。这里使用的是 lable

  • mount point 挂载目录。

  • type 文件系统类型,包括xfs、ext2、ext3、ext4、reiserfs、nfs、vfat等。

  • options 文件系统的参数,参数如下:

    • Async/sync:设置是否为同步方式运行,默认为async
    • auto/noauto:当执行 mount -a 的命令时,此文件系统是否被主动挂载。默认为auto
    • rw/ro:是否以以只读或者读写模式挂载
    • exec/noexec:限制此文件系统内是否能够进行"执行"的操作
    • user/nouser:是否允许用户使用mount命令挂载
    • suid/nosuid:是否允许SUID的存在
    • Usrquota:启动文件系统支持磁盘配额模式
    • Grpquota:启动文件系统对群组磁盘配额模式的支持
    • Defaults:同事具有rw,suid,dev,exec,auto,nouser,async等默认参数的设置
  • dump 是一个用来作为备份的命令参数值解释如下:

    • 0 代表不要做dump备份
    • 1代表要每天进行dump的操作
    • 2代表不定日期的进行dump操作

2)创建服务启动用户并设置磁盘属主

groupadd -r minio-user
useradd -M -r -g minio-user minio-user
chown minio-user:minio-user /data{1..4}

3)下载 minio 安装包

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

4)修改配置

vi /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://192.168.182.110:9000/data{1...4}/minio http://192.168.182.111:9000/data{1...4}/minio http://192.168.182.112:9000/data{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=minioadmin

# 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="http://10.192.168.110:9000"

【注意】MINIO_SERVER_URL 值必须所有节点是一样的。

5)配置 systemctl 启动

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

启动服务

sudo systemctl daemon-reload
sudo systemctl start minio.service
sudo systemctl status minio.service
journalctl -f -u minio.service
# 从日志里可以看到访问入口地址,也可以看/var/log/messages

在这里插入图片描述

【温馨提示】如果需要加磁盘,必须先把这个这个目录删掉,要不然无法启动,/data{1..4}/.minio.sys,报错:ERROR Unable to initialize backend: /data1 drive is already being used in another erasure deployment. (Number of drives specified: 5 but the number of drives found in the 1st drive's format.json: 4)

web 访问:

在这里插入图片描述

账号/密码:minioadmin/minioadmin

在这里插入图片描述

6)客户端工具 mc

wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
sudo mv mc /usr/local/bin/mc

配置

# mc alias set <ALIAS> <YOUR-MINIO-ENDPOINT> [YOUR-ACCESS-KEY] [YOUR-SECRET-KEY]
mc alias set local http://192.168.182.110:9000 myminioadmin myminioadmin
mc admin info local

# 创建桶
# 并创建bucket harbor
mc mb local/test
mc ls local

更多 mc 客户端命令操作可以参考官方文档:https://min.io/docs/minio/linux/reference/minio-mc.html


MinIO 高性能分布式存储最新版单机与分布式部署就先到这里了,有任何疑问也可关注我公众号:大数据与云原生技术分享,进行技术交流,如本篇文章对您有所帮助,麻烦帮忙一键三连(点赞、转发、收藏)~