MinIO 是实施最广泛的对象存储之一,因为它提供高性能、大规模可扩展性、高可用性并遵守行业标准 S3 协议。 MinIO 具有惊人的性能—— 最近的基准测试 在 GET 上达到了 325 GiB/s (349 GB/s),在 PUT 上达到了 165 GiB/s (177 GB/s),只有 32 个现成的 NVMe SSD 节点。 无论您在哪里运行 MinIO——裸机、虚拟实例或 Kubernetes——MinIO 的性能和可扩展性都为数据湖、分析、AI/ML 等云原生应用程序提供了良好的基础。
除了 Kubernetes 之外,客户还在虚拟实例和裸机上运行 MinIO,经常依赖 数据中心和 AWS 、 GCP 和 Azure等云中的 Supermicro 硬件 。 Linux 的小占用空间加上高效的资源利用使其成为运行 MinIO 的多功能和灵活的选择。 然而,越来越多的 Linux 机器和实例需要自动化来减轻管理负担。 需要使用 SystemD 将 MinIO 服务器作为初始服务进行管理,因为它有助于自动化服务生命周期,特别是在启动、关闭和重新启动期间。
SystemD 是一个服务管理器,在启动、关闭、初始化等过程中维护 Linux 系统中的服务。 将其视为初始化脚本的后继者,您必须从头开始编写整个脚本,但使用 SystemD,您只需填写几个参数,命令和日志记录都是标准化的。
使用较旧的 init.d 服务管理的几个挑战之一是您必须从头开始编写整个文件。 每个 init.d 文件都是唯一的,并且有不同的方式来管理服务的生命周期。 SystemD 吸取了 init.d 的经验教训并对其进行了标准化。 例如,SystemD 服务文件可以运行任何服务,只要它被编写为运行——只是路径、名称和语义不同——但基本结构、如何重启服务、读取日志、优雅地卸载文件系统、等待对于网络连接的出现,除其他外,现在在所有服务中都很常见,因此无论您运行哪种服务,您都知道在哪里可以找到它的日志。
SystemD 不仅在不同服务之间具有通用性,而且您可以采用相同的 SystemD 服务文件并在多个操作系统中使用它,只要该操作系统也使用 SystemD 来管理其服务的生命周期。 这简化了自动化,因为您可以在创建初始文件时在 Ubuntu 上工作,但是只要路径和其他内容保持不变,就可以将相同的文件部署到 CentOS/RedHat 操作系统,在大多数情况下都是如此。
SystemD 有几个主要组件,但您会经常遇到的几个组件是:
要运行本指南中的大部分命令,您需要具有“sudo”或根访问权限,因为 SystemD 配置文件需要以根权限获得。
您还可以在我们的存储库中找到 有关 MinIO 和 SystemD 的其他说明 。
MinIO 二进制文件
# wget https://dl.min.io/server/minio/release/linux-amd64/minio
--2022-07-24 11 :31:33-- https://dl.min.io/server/minio/release/linux-amd64/minio Resolving dl.min.io (dl.min.io)... 132.68.11.115 , 138.118.66.212 Connecting to dl.min.io (dl.min.io)|132.68.11.115|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 96649216 (92M) [application/octet-stream] Saving to: 'minio' minio 100 %[==========================================>] 92.17 M 50.2 MB/s in 1.8 s 2022 -07-24 11 :31:35 (50.2 MB/s) - 'minio' saved [96649216/96649216]
# mv minio /usr/local/bin/
服务档案 MinIO 可以根据操作系统以几种不同的方式安装在 Linux 上。 RedHat/CentOS 及其衍生版本依赖.rpm 包,Debian/Ubuntu 使用.deb 包。 在这两种情况下,安装包中都包含以下 SystemD 服务文件。
但是,我们手动从上游获取了 MinIO 二进制文件,因此我们将手动创建 SystemD 服务文件。
[Unit] Description=MinIO Documentation=https://docs.min.io 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})
最小IO 分布式设置 在启动 MinIO 服务之前,需要在裸机节点上设置几个先决条件。
mkdir -p /mnt/data/disk1 \ mkdir -p /mnt/data/disk2 \ mkdir -p /mnt/data/disk3 \ mkdir -p /mnt/data/disk4
环境服务文件
# 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://minio1.example.com:9000/mnt/data/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=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="https://minio.example.net:9000"
启动 MinIO 进程
# systemctl enable minio.service
# systemctl start minio.service
# systemctl status minio.service # journalctl -e -u minio.service
Aug 01 13:27:06 aj-test-3 systemd[1]: Starting MinIO...
Aug 01 13:27:06 aj-test-3 systemd[1]: Started MinIO.
Aug 01 13:27:07 aj-test-3 minio[3241]: Formatting 1st pool, 1 set(s), 4 drives per set.
Aug 01 13:27:07 aj-test-3 minio[3241]: WARNING: Host minio1.example.com:9000 has more than 2 drives of set. A host fai>
Aug 01 13:27:07 aj-test-3 minio[3241]: You are running an older version of MinIO released 4 days ago
Aug 01 13:27:07 aj-test-3 minio[3241]: Update: Run `mc admin update`
Aug 01 13:27:07 aj-test-3 minio[3241]: MinIO Object Storage Server
Aug 01 13:27:07 aj-test-3 minio[3241]: Copyright: 2015-2022 MinIO, Inc.
Aug 01 13:27:07 aj-test-3 minio[3241]: License: GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
Aug 01 13:27:07 aj-test-3 minio[3241]: Version: RELEASE.2022-07-26T00-53-03Z (go1.18.4 linux/amd64)
Aug 01 13:27:07 aj-test-3 minio[3241]: Status: 4 Online, 0 Offline.
Aug 01 13:27:07 aj-test-3 minio[3241]: API: https://minio.example.net:9000
Aug 01 13:27:07 aj-test-3 minio[3241]: Console: http://10.128.0.4:9001 http://127.0.0.1:9001
Aug 01 13:27:07 aj-test-3 minio[3241]: Documentation: https://docs.min.io
登录控制台 MINIO_ROOT_USER使用浏览器,使用我们之前所做的配置 登录到 MinIO 控制台 MINIO_ROOT_PASSWORD。
http: //<server_host_ip>:9001/
请注意,以上设置是为了让您快速启动并运行 MinIO。 您可以从单个节点扩展到多节点分布式配置以进行额外测试。 如果您想在生产环境中部署和配置 MinIO,请参阅 文档 。
与 SystemD 的集成非常通用。
服务文件的语法在所有服务中都是相同的
相同的服务文件将适用于任何支持 SystemD 的操作系统
您可以将 SystemD 与裸机一起使用,也可以在任何云(例如 AWS、GCP 和 Azure)中的 VM 上使用。
这可以通过标准化格式并简化自动化部署来帮助实现 DevOps 的自动化。
在运行对象存储等关键任务服务时,自动化对保持可用性大有帮助。 自动化是跨多个云和环境大规模运行的要求。 在 SystemD 和 MinIO 的帮助下,您可以自动化云对象存储部署并确保服务生命周期得到顺利和成功的管理。
有问题吗? 想开始吗? 在Slack 上联系我们 。