Appearance
MinIO 快速开始
官方文档:MinIO Object Storage for Linux — MinIO Object Storage for Linux
下载
下载地址:MinIO | Code and downloads to create high performance object storage
MinIO Server
服务端下载方法
shell
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
MINIO_ROOT_USER=admin MINIO_ROOT_PASSWORD=password ./minio server /mnt/data --console-address ":9001"MinIO Client
客户端下载方法
shell
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
mc alias set myminio/ http://MINIO-SERVER MYUSER MYPASSWORD安装和部署
所有MinIO部署实现了 纠删码(Erasure Coding) 后端. 你可以使用以下其中一种拓扑来部署MinIO:
- 单节点单硬盘 (SNSD 或者 “单节点”)
- 本地开发和评估,可靠性不高/有限。
- 单节点多硬盘 (SNMD 或者 “单节点多硬盘”)
- 性能、规模和容量要求较低的工作负载
- 驱动级别的可靠性,可配置容忍损失高达一半所有驱动器的能力。
- 对多驱动器拓扑和故障转移行为进行评估。
- 多节点多硬盘 (MNMD or “Distributed”)
- 企业级高性能对象存储
- 多节点/驱动器级可靠性,可配置容忍性,可承受多达1/2的节点/驱动器损失
- 用于AI/ML、分布式查询、分析和其他数据湖组件的主要存储
- 可扩展到PB+级工作负载-包括存储容量和性能
单节点多硬盘部署MinIO
先决条件
使用本地存储
直接连接存储(DAS)在性能和一致性方面比网络存储( 网络附加存储(NAS)、 存储区域网络(SAN)、 网络文件存储(NFS))有显著优势。 MinIO 强烈建议使用闪存存储(NVMe,SSD)作为主要或 “热” 数据。
使用 XFS 格式化驱动器。
MinIO 强烈建议为存储提供 XFS 格式化的驱动器。 MinIO 在内部测试和验证套件中使用 XFS,以提供对性能和行为在所有规模上的额外信心。
MinIO 并 不 测试也不推荐其他文件系统,如 EXT4、BTRFS 或 ZFS。
使用一致类型的驱动器
MinIO 不区分驱动器类型,并且不从混合存储类型中受益。 每个 pool(池)必须使用相同类型(NVMe,SSD)的驱动器。
例如,部署一个仅由 NVMe 驱动器组成的池。 如果您将一些驱动器作为 SSD 或 HDD 部署,MinIO 会将与 NVMe 驱动器相同的方式来处理这些驱动器。 这可能会导致性能问题,因为一些驱动器具有不同的或更差的读/写特性,并且不能像 NVMe 驱动器那样以相同的速率响应。
使用一致大小的驱动器
MinIO 将每个驱动器上使用的大小限制为部署中最小的驱动器大小。
例如,部署一个由容量相同的 7.68TiB NVMe驱动器组成的数据池。 如果您部署了一个容量为 3.84TiB 的驱动器,MinIO会将池中的所有驱动器都视为具有那个较小的容量。
配置顺序挂载驱动器
MinIO 使用 Go 扩展表示法 {x...y} 来表示在创建新 deployment 时驱动器的顺序系列,其中 deployment 中的所有节点都具有相同的一组挂载驱动器。 将驱动器挂载路径配置为顺序系列,以最佳支持这种表示法。 例如,使用模式 /mnt/drive-n 挂载您的驱动器,其中 n 从 1 开始,每增加一个驱动器就递增 1 。
在重新启动后保持驱动器挂载和映射不变
使用 /etc/fstab 确保在节点重新启动后驱动器到挂载点的映射一致。
在重新启动后,非Linux操作系统应使用等效的驱动器挂载管理工具以保持驱动器到挂载点的映射一致。
独占访问驱动器
MinIO 要求 专有 对提供给对象存储的驱动器或卷的访问。 其他任何进程、软件、脚本或人员都不得直接对提供给MinIO的驱动器或卷执行 任何 操作,也不得对MinIO放置在其上的对象或文件执行操作。 除非由MinIO工程部门指导,否则不要使用脚本或工具直接修改、删除或移动提供给MinIO的驱动器上的任何数据片段、校验片段或元数据文件,包括从一个驱动器或节点移动到另一个驱动器或节点。 这些操作很可能会导致广泛的数据损坏和丢失,超出了MinIO的修复能力。
创建 systemd 系统启动服务文件
.deb 或 .rpm 安装包将安装 systemd 文件至 /usr/lib/systemd/system/minio.service。 对于二进制安装,请在所有 MinIO 主机上手动创建此文件。
[!abstract] 注意
systemd 命令启动前,系统内部会检查 /etc/systemd/... 这个路径是否存在启动系统文件,如果冲突请在 /usr/lib/systemd/... 路径找到对应文件,避免重复创建后的冲突。 并且为了避免冲突或意外的配置选项,请确保该文件仅存在于 /usr/lib/systemd/system/minio.service 。
请参考 systemd.unit 手册和说明 了解有关文件路径搜索顺序的详细信息。
[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预定用于存储的文件夹路径。 这些命令通常需要管理员 ( sudo ) 权限。
shell
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拟用于使用的这些驱动器的路径。
或者,将 User 和 Group 的值改为系统主机上另一个 具有必要访问和权限的用户和组。
MinIO在其网站上发布了一些额外的启动脚本示例 github.com/minio/minio-service.
要更新使用 systemctl , 请访问 minio-upgrade-systemctl 查看。
创建环境变量文件
在指定位置创建一个环境变量文件 /etc/default/minio 。 对于Windows主机,请指定一个类似Windows风格的路径: C:\minio\config 。 MinIO服务器容器可以使用此文件作为来源: environment variables 。
以下示例提供了一个启动的环境变量配置文件:
toml
# 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=minio-secret-key-change-me
# 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="/mnt/disk{1...4}"
# MINIO_OPTS sets any additional commandline options to pass to the MinIO server.
# 例如, `--console-address :9001` sets the MinIO Console listen port
MINIO_OPTS="--console-address :9001"创建一个与S3兼容的服务别名
重要
以下示例暂时禁用了 bash 历史记录,以减轻认证凭据以明文形式泄露 的风险。这是一个基本的安全措施, 并不能减轻所有可能的攻击向量。 对于在命令行输入敏感信息, 请参考您操作系统的安全最佳实践。
使用 mc alias set 命令将 Amazon S3 兼容服务添加到 mc 配置 中。
shell
bash +o history
mc alias set ALIAS HOSTNAME ACCESS_KEY SECRET_KEY
bash -o history- 将
ALIAS替换为要与 S3 服务关联的名称。mc命令通常需要ALIAS作为参数, 用于识别要执行哪个 S3 服务。 - 将
HOSTNAME替换为 S3 服务的 URL 端点或 IP 地址。 - 将
ACCESS_KEY和SECRET_KEY替换为 S3 服务上用户的访问密钥和秘密密钥。
将每个参数替换为所需的值。 如果您省略了 ACCESS_KEY 和 SECRET_KEY ,该命令将提示您在命令行界面(CLI)中输入这些值。
使用 mc admin info 命令来测试新添加的 MinIO 部署的连接:
shell
mc admin info myminio如果成功,该命令将返回有关 S3 服务的信息。 如果 如果不成功,请检查以下各项:
- 主机能够连接到 S3 服务 URL(即使用
ping或traceroute)。 - 指定的
ACCESSKEY和SECRETKEY对应于 S3 服务上的 一个用户。该用户必须有权限在服务上 执行操作。
Nginx服务器反向代理MinIO配置
以下文档为您在 Linux 环境中配置 NGINX 以代理请求到 MinIO 提供了基本指导。 本文档并不旨在提供 NGINX、代理或反向代理的全面方法。 根据您的基础设施需要修改配置。
本文档假设以下内容:
- 一个现有的 NGINX 部署
- 一个现有的 MinIO 部署
- 一个唯一标识 MinIO 部署的 DNS 主机名
提示
S3 API签名计算算法 不 支持通过代理方案来托管MinIO服务器API的情况,例如 example.net/s3/ 。 您还必须为MinIO部署设置以下环境变量:
- 将
MINIO_BROWSER_REDIRECT_URL设置为 MinIO 控制台的代理主机 FQDN (https://example.net/minio/ui)
有两种模型用于将请求代理到 MinIO 服务器 API 和 MinIO 控制台:
Dedicated DNS
为 MinIO 服务创建或配置一个专用的 DNS 名称。
对于 MinIO 服务器 S3 API,将请求代理到该域名的根目录。 对于 MinIO 控制台的 Web GUI,将请求代理到 /minio 子路径。
例如, 给定主机名 minio.example.net :
- 将请求代理到
https://minio.example.net的根目录到监听在https://minio.local:9000的 MinIO 服务器。 - 将请求代理到
https://minio.example.net/minio/ui子路径到监听在https://minio.local:9001的 MinIO 控制台。
以下位置块为您在独特环境中进行进一步自定义提供了模板:
nginx
upstream minio_s3 {
least_conn;
server minio-01.internal-domain.com:9000;
server minio-02.internal-domain.com:9000;
server minio-03.internal-domain.com:9000;
server minio-04.internal-domain.com:9000;
}
upstream minio_console {
least_conn;
server minio-01.internal-domain.com:9001;
server minio-02.internal-domain.com:9001;
server minio-03.internal-domain.com:9001;
server minio-04.internal-domain.com:9001;
}
server {
listen 80;
listen [::]:80;
server_name minio.example.net;
# Allow special characters in headers
ignore_invalid_headers off;
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0;
# Disable buffering
proxy_buffering off;
proxy_request_buffering off;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://minio_s3; # This uses the upstream directive definition to load balance
}
location /minio/ui/ {
rewrite ^/minio/ui/(.*) /$1 break;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;
# This is necessary to pass the correct IP to be hashed
real_ip_header X-Real-IP;
proxy_connect_timeout 300;
# To support websockets in MinIO versions released after January 2023
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Some environments may encounter CORS errors (Kubernetes + Nginx Ingress)
# Uncomment the following line to set the Origin request to an empty string
# proxy_set_header Origin '';
chunked_transfer_encoding off;
proxy_pass http://minio_console; # This uses the upstream directive definition to load balance
}
}Subdomain
为MinIO服务器S3 API和MinIO控制台Web GUI创建或配置单独的、唯一的子域名。
例如, 给定根域 example.net :
- 将代理请求转发到子域
minio.example.net,该子域指向在https://minio.local:9000上监听的MinIO服务器。 - 将请求代理到子域
console.example.net,该子域指向在https://minio.local:9001上监听的MinIO控制台。
以下位置块为您提供了一个模板,以便在您的独特环境中进行进一步的自定义:
nginx
upstream minio_s3 {
least_conn;
server minio-01.internal-domain.com:9000;
server minio-02.internal-domain.com:9000;
server minio-03.internal-domain.com:9000;
server minio-04.internal-domain.com:9000;
}
upstream minio_console {
least_conn;
server minio-01.internal-domain.com:9001;
server minio-02.internal-domain.com:9001;
server minio-03.internal-domain.com:9001;
server minio-04.internal-domain.com:9001;
}
server {
listen 80;
listen [::]:80;
server_name minio.example.net;
# Allow special characters in headers
ignore_invalid_headers off;
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0;
# Disable buffering
proxy_buffering off;
proxy_request_buffering off;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://minio_s3; # This uses the upstream directive definition to load balance
}
}
server {
listen 80;
listen [::]:80;
server_name console.example.net;
# Allow special characters in headers
ignore_invalid_headers off;
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0;
# Disable buffering
proxy_buffering off;
proxy_request_buffering off;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;
# This is necessary to pass the correct IP to be hashed
real_ip_header X-Real-IP;
proxy_connect_timeout 300;
# To support websocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
chunked_transfer_encoding off;
proxy_pass http://minio_console/; # This uses the upstream directive definition to load balance
}
}