minIO分布式集群搭建+nginx负载均衡

时间:2025-04-21 18:06:49

暂时关闭防火墙

systemctl stop firewalld

查看防火墙状态

systemctl status firewalld

赋予最高权限

chmod +x minio

!/bin/bash

export MINIO_ACCESS_KEY=XXX

export MINIO_SECRET_KEY=XXX

./minio server --config-dir /apps/conf

http://10.95.130.134/apps/data

http://10.95.130.135/apps/data

http://10.95.130.136/apps/data

http://10.95.130.137/apps/data

其中,“MINIO_ACCESS_KEY”为用户名,“MINIO_SECRET_KEY”为密码,密码不能设置过于简单,不然minio会启动失败,“-config-dir”指定集群配置文件目录,集群相关配置需要一样

编写服务脚本(所有节点)

vi /usr/lib/systemd/system/minio.service

[Unit]

Description=Minio service

Documentation=https://docs.minio.io/

[Service]

WorkingDirectory=/apps/

ExecStart=/apps/run.sh

Restart=on-failure

RestartSec=5

[Install]

WantedBy=multi-user.target

其中,“WorkingDirectory”为启动脚本目录,“ExecStart”为指定集群启动脚本

chmod +x /usr/lib/systemd/system/minio.service

启动

systemctl daemon-reload

systemctl start minio

systemctl enable minio

systemctl stop minio

配置负载均衡

upstream minio-server {

server 10.95.130.144:9000 weight=25 max_fails=2 fail_timeout=30s;

server 10.95.130.145:9000 weight=25 max_fails=2 fail_timeout=30s;

server 10.95.130.146:9000 weight=25 max_fails=2 fail_timeout=30s;

server 10.95.130.147:9000 weight=25 max_fails=2 fail_timeout=30s;

}

server {

listen 80;

server_name localhost;

charset utf-8;

default_type text/html;

location /{

proxy_set_header Host $http_host;

proxy_set_header X-Forwarded-For $remote_addr;

client_body_buffer_size 10M;

client_max_body_size 10G;

proxy_buffers 1024 4k;

proxy_read_timeout 300;

proxy_next_upstream error timeout http_404;

proxy_pass http://minio-server;

}

}

Nginx重启

/usr/sbin/nginx -s reload