環(huán)境:4節(jié)點服務器集群(192.168.2.1/2/3/4),每節(jié)點4塊硬盤,一臺Nginx做負載均衡,本文主要記錄4個節(jié)點的配置,操作系統(tǒng)是Centos7。
1.網(wǎng)絡(luò)設(shè)置和防火墻
每個節(jié)點都應該具有對部署中其他每個節(jié)點的完全雙向網(wǎng)絡(luò)訪問權(quán)限。設(shè)置防火墻規(guī)則,以下命令明確打開運行firewalld的服務器的默認MinIO服務器API端口 9000 :
firewall-cmd --permanent --zone=public --add-port=9000/tcp
firewall-cmd --reload
部署中的所有MinIO服務器 必須 使用相同的監(jiān)聽端口。
如果您設(shè)置了一個靜態(tài)的MinIO控制臺端口(例如 9001 ), 則還必須授予對該端口的訪問權(quán)限,以確保來自外部客戶端的連接。
2.布署分布式MinIO服務器
用于運行 Linux 操作系統(tǒng)的 Intel 64 位處理器的 MinIO 服務器安裝文件二進制包,使用以下命令下載安裝最新版本的穩(wěn)定 MinIO二進制包, 并設(shè)置 $PATH :
wget https://dl.minio.org.cn/server/minio/release/linux-amd64/minio
chmod +x minio
sudo mv minio /usr/local/bin/
3.創(chuàng)建 systemd 系統(tǒng)啟動服務文件,對于二進制安裝,請在所有 MinIO 主機上手動創(chuàng)建此文件。
備注: systemd 命令啟動前,系統(tǒng)內(nèi)部會檢查 /etc/systemd/... 這個路徑,是否存在啟動系統(tǒng)文件,如果沖突請在 /usr/lib/systemd/... 路徑,找到對應文件,避免重復創(chuàng)建后的沖突。并且,為了避免沖突或意外的配置選項,請確保該文件僅存在于 /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})
4.創(chuàng)建系統(tǒng)用戶名和用戶組
minio.service 文件默認以 minio-user 用戶和組身份運行。 您可以使用 groupadd 和 useradd 命令創(chuàng)建用戶和組。以下示例創(chuàng)建用戶、組并設(shè)置權(quán)限以訪問MinIO預定用于存儲的文件夾路徑。 這些命令通常需要管理員 ( sudo ) 權(quán)限。
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
指定的驅(qū)動器路徑是作為示例提供的, 請更改它們以匹配MinIO擬用于使用的這些驅(qū)動器的路徑。
5.創(chuàng)建服務環(huán)變變量配置文件
創(chuàng)建一個環(huán)變變量配置文件在 /etc/default/minio 路徑.。MinIO 服務使用此文件作為所有內(nèi)容的來源 ,環(huán)境變量使用 MinIO 和 minio.service 文件。
修改示例以反映您的部署拓撲:
# 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.2.{1...4}:9000/mnt/disk{1...4}"
# 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=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
6.運行和啟動MinIO服務器進程
生成用戶賬戶和規(guī)定以控制對部署的訪問:
sudo systemctl start minio.service
使用以下命令確認服務是否在線和功能正常:
sudo systemctl status minio.service
journalctl -f -u minio.service
備注:MinIO在服務器處理連接和同步時可能會記錄大量非關(guān)鍵性警告。 這些警告通常是短暫的, 在部署上線后應該會解決。在 RELEASE.2023-02-09T05-16-53Z 版本發(fā)生變更: 如果MinIO檢測到足夠的驅(qū)動器以滿足部署的 寫入仲裁需要,則會啟動MinIO,如果不滿足則會啟動失敗。
如果在啟動MinIO后任何驅(qū)動器仍處于離線狀態(tài),請檢查和修復阻止其功能的任何問題,然后再開始生產(chǎn)工作負載。
MinIO服務不會在主機重新啟動時自動啟動。 您必須使用 systemctl enable minio.service 將進程作為主機引導的一部分,在服務器重啟的過程中該進程會自動重啟,而不用再進行手動管理。
7.打開MinIO控制臺
打開瀏覽器并訪問端口 :9001 處的任何 MinIO 主機名 打開 MinIO控制臺登錄頁面。 例如: http://192.168.2.1:9001
使用 MINIO_ROOT_USER 和 MINIO_ROOT_PASSWORD 登錄 從上一步開始。

您可以使用MinIO控制臺進行常規(guī)管理任務, 如身份和訪問管理、指標和日志監(jiān)控以及服務器配置。 每個MinIO服務器都包含了自己的內(nèi)嵌 MinIO控制臺。