Minio集群部署

发布于:2025-04-02 ⋅ 阅读:(16) ⋅ 点赞:(0)

Minio集群部署

资源规划

IP 服务规划 配置
192.168.116.138 minio-1 16核32G磁盘10T
192.168.116.139 minio-2 16核32G磁盘10T
192.168.116.140 minio-3 16核32G磁盘10T
192.168.116.141 minio-4 16核32G磁盘10T
192.168.116.128 nginx代理 8核16G磁盘500G

基本环境配置

下面命令minio4台设备都要执行
[root@minio-1 ~]# tee >> /etc/hosts << EOF
192.168.116.138 minio-1
192.168.116.139 minio-2
192.168.116.140 minio-3
192.168.116.141 minio-4
EOF

[root@minio-1 ~]# mkdir /home/minio/{app,config,data,logs} -p 

下载文件

[root@minio-1 ~]# cd /home/minio/app
[root@minio-1 app]# wget https://dl.min.io/server/minio/release/linux-amd64/minio

创建启动命令

[root@minio-1 app]# tee > run.sh << EOF
#!/bin/bash
export MINIO_ROOT_USER=admin
export MINIO_ROOT_PASSWORD=admin@123
nohup /home/minio/app/minio server --config-dir /home/minio/config --console-address ":9001" \
http://minio-1:9000/home/minio/data http://minio-2:9000/home/minio/data http://minio-3:9000/home/minio/data http://minio-4:9000/home/minio/data > /home/minio/logs/start.log 2>&1 &
echo "MinIO started with PID: $!"
EOF

[root@minio-1 app]# chmod a+x  run.sh 

# 批量发送文件与启动脚本到minio2-3-4服务器
[root@minio-1 app]# for i in 139 140 141; do scp minio run.sh root@192.168.116.$i:/home/minio/app ; done


# 启动minio服务
[root@minio-1 app]# bash run.sh 
[root@minio-2 app]# bash run.sh 
[root@minio-3 app]# bash run.sh 
[root@minio-4 app]# bash run.sh 

配置负载均衡

# 安装nginx
192.168.116.128 机器
[root@nginx-minio ~]# yum -y install nginx

# 写入负载均衡配置文件
[root@nginx-minio conf.d]# cat minio-cluster.conf 
upstream minio-console {
    server 192.168.116.138:9001 max_fails=3 fail_timeout=5s;
    server 192.168.116.139:9001 max_fails=3 fail_timeout=5s;
    server 192.168.116.140:9001 max_fails=3 fail_timeout=5s;
    server 192.168.116.141:9001 max_fails=3 fail_timeout=5s;
}
upstream minio-api {
    server 192.168.116.138:9000 max_fails=3 fail_timeout=5s;
    server 192.168.116.139:9000 max_fails=3 fail_timeout=5s;
    server 192.168.116.140:9000 max_fails=3 fail_timeout=5s;
    server 192.168.116.141:9000 max_fails=3 fail_timeout=5s;
}

server {
    listen          9001;   #或者用80端口也可以
    server_name     _;    #可以用域名
    access_log      /home/minio/logs/minio.com_access.log main;
    error_log       /home/minio/logs/minio.com_error.log warn;
    location / {
        proxy_next_upstream     http_500 http_502 http_503 http_504 error timeout invalid_header;
        proxy_set_header        Host  $host;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass              http://minio-console;
        expires                 0;
    }
}

server {
    listen          9000;
    server_name     _;   #可以用域名
    access_log      /home/minio/logs/minio.com_access.log main;
    error_log       /home/minio/logs/minio.com_error.log warn;

    location / {
        proxy_next_upstream     http_500 http_502 http_503 http_504 error timeout invalid_header;
        proxy_set_header        Host  $host;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass              http://minio-api;
        expires                 0;
    }
}

# 启动nginx
[root@nginx-minio conf.d]# systemctl  start nginx 

# 检查集群是否健康 
# 默认账号密码 admin/amdin@123
访问http://192.168.116.128:9001/tools/metrics

网站公告

今日签到

点亮在社区的每一天
去签到