部署一个MinIO集群,个人记录。
规划
首先准备好数个节点,官方要求不低于4个节点,各节点间时间同步,且建议节点数量为偶数,我这里使用6个节点,系统为CentOS 7(官方现已不再支持内核较低的版本,我这里只是测试就无所谓了)。前端由单独的机器做ubuntu 24.04起HAProxy做L4负载均衡。
同时为了防止存储内部传输对业务网络造成影响,存储仅配置L2网络用于局域网通信。
节点上提前做好硬盘的挂载,建议将数据放置在单独的硬盘上。

注意:
MinIO 分布式集群的拓扑是“静态”的,不能动态添加节点或磁盘,必须重建集群。
因此请务必在正式开始建设前确定好稳定的拓扑和架构,一旦集群创建并有数据写入后,整个拓扑就不再能添加节点或磁盘了。
部署
- 下载MinIO到本机,目前的话
RELEASE.2025-04-22T22-12-26Z
是最后一个内置WebUI面板的版本测试有效性,直接执行如下指令:1
2wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio.RELEASE.2025-04-22T22-12-26Z -O minio
chmod +x minio正常应该可以访问1
./minio server --address '0.0.0.0:9000' --console-address '0.0.0.0:9001' /storage0/
http://0.0.0.0:9001
到MinIO的控制面板,能够访问后kill掉当前minio进程。 - 禁用IPv6
将如下配置项写入/etc/sysctl.conf
:然后应用:1
2net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 11
sysctl -p
- 写hosts文件
1
2
3
4
5
630.20.10.11 storNode01
30.20.10.12 storNode02
30.20.10.13 storNode03
30.20.10.14 storNode04
30.20.10.15 storNode05
30.20.10.16 storNode06 - 写SystemD配置文件注意修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16[Unit]
Description=MinIO
After=network.target
[Service]
Environment="MINIO_ROOT_USER=lxnchan"
Environment="MINIO_ROOT_PASSWORD=lxnchanminioadmin"
ExecStart=/root/minio server http://stornode0{1...6}/storage0 --address '0.0.0.0:9000' --console-address '0.0.0.0:9001'
Restart=always
LimitNOFILE=1048576
TasksMax=infinity
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.targetMINIO_ROOT_USER
和MINIO_ROOT_PASSWORD
。 - 将
hosts
和minio.service
同步到剩余节点1
2
3
4
5
6
7
8
9
10scp /etc/hosts root@30.20.10.12:/etc/hosts
scp /etc/systemd/system/minio.service root@30.20.10.12:/etc/systemd/system/minio.service
scp /etc/hosts root@30.20.10.13:/etc/hosts
scp /etc/systemd/system/minio.service root@30.20.10.13:/etc/systemd/system/minio.service
scp /etc/hosts root@30.20.10.14:/etc/hosts
scp /etc/systemd/system/minio.service root@30.20.10.14:/etc/systemd/system/minio.service
scp /etc/hosts root@30.20.10.15:/etc/hosts
scp /etc/systemd/system/minio.service root@30.20.10.15:/etc/systemd/system/minio.service
scp /etc/hosts root@30.20.10.16:/etc/hosts
scp /etc/systemd/system/minio.service root@30.20.10.16:/etc/systemd/system/minio.service - 所有节点起MinIO:最后访问任一节点IP都可以访问到MinIO,如果访问不到看一下日志。
1
systemctl enable --now minio
HAProxy
- 安装HAProxy
1
sudo apt update && apt install haproxy -y
- 创建CA证书
因为我这里的业务要求强制使用HTTPS方式链接,因此我这里先本地自签个SSL证书。然后将两个证书和密钥合成一个文件,以便给HAProxy使用:1
2
3
4openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
-keyout private.key -out public.crt \
-subj "/C=CN/ST=Tianjin/L=Tianjin/O=LxnChan/OU=IT/CN=30.20.10.10" \
-addext "subjectAltName=IP:30.20.10.10,DNS:storl4lb"1
cat public.crt private.key > haproxy.pem
- 写入配置文件测试配置文件是否有效:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26frontend minio_frontend
#bind *:80
bind *:443 ssl crt /root/certs/minio.pem
mode tcp
default_backend minio_backend
backend minio_backend
# Layer7
#mode http
#balance roundrobin
#option httpchk GET /minio/health/ready
#http-check expect status 200
# Layer4
mode tcp
balance roundrobin
option tcp-check
tcp-check connect
# server [name] [source] [check or empty]
server minio1 stornode01:9000 check
server minio2 stornode02:9000 check
server minio3 stornode03:9000 check
server minio4 stornode04:9000 check
server minio5 stornode05:9000 check
server minio6 stornode06:9000 check重启HAProxy:1
2root@storl4lb:~# haproxy -c -f /etc/haproxy/haproxy.cfg
Configuration file is valid1
systemctl restart haproxy