minio对象存储两台服务器部署4个节点集群

环境:centos7.6 、两台服务器部署4个节点集群

minio简介:
MinIO 是一个基于Apache License v2.0开源协议的对象存储服务。它兼容亚马逊S3云存储服务接口,非常适合于存储大容量非结构化的数据,例如图片、视频、日志文件、备份数据和容器/虚拟机镜像等,而一个对象文件可以是任意大小,从几kb到最大5T不等。
MinIO是一个非常轻量的服务,可以很简单的和其他应用的结合,类似 NodeJS, Redis 或者 MySQL。

ip 数据路径 端口
80.213.8.30 /data/minio1 9000
80.213.8.30 /data/minio2 9100
80.213.8.31 /data/minio1 9000
80.213.8.31 /data/minio2 9100

一、新建安装目录和数据目录并下载GNU/Linux版本minio软件

所有节点执行下列操作
配置时间同步,配置时间同步的方式不做讲述
两台服务器上分别创建数据目录

先挂新的磁盘到/data目录下,否则启动会报错Waiting for a minimum of 1 drives to come online

mkdir -p /data/minio/minio1
mkdir -p /data/minio/minio2
创建程序存放路径
mkdir -p /usr/local/minio
下载minio程序包
wget -P /usr/local/minio https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x /usr/local/minio/minio
修改系统最大文件数
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf

二、编写启动Minio的配置文件

vim /usr/local/minio/minio.conf

点击查看代码
MINIO_ACCESS_KEY=admin
MINIO_SECRET_KEY=123qweQWE
ENDPOINTS="http://80.213.8.30:9000/data/minio/minio1 http://80.213.8.30:9100/data/minio/minio2 http://80.213.8.31:9000/data/minio/minio1
http://80.213.8.31:9100/data/minio/minio2"

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

点击查看代码
[Unit]
Description=Minio
Documentation=https://docs.minio.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/minio/minio

[Service]
EnvironmentFile=/usr/local/minio/minio.conf
ExecStart=/usr/local/minio/minio server $ENDPOINTS --address :9000  --console-address :19000

# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target

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

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

点击查看代码
[Unit]
Description=Minio
Documentation=https://docs.minio.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/minio/minio

[Service]
EnvironmentFile=/usr/local/minio/minio.conf
ExecStart=/usr/local/minio/minio server $ENDPOINTS --address :9100

# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target

chmod +x /usr/lib/systemd/system/minio2.service
将上述配置同步到2台服务器,并启动,minio实例之间会自行发现各个节点
systemctl enable minio1 && systemctl start minio1 && systemctl status minio1

systemctl enable minio2 && systemctl start minio2 && systemctl status minio2

三、页面登录

控制台访问链接 http://80.213.8.30:39897

四、Nginx代理minio做负载均衡

配置nginx
修改nginx配置文件/usr/local/nginx/conf/nginx.conf
关键配置如下:

点击查看代码
worker_processes  1;
events {
    worker_connections  1024;
}
 
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    upstream minio{
        server 80.213.8.30:9000;
        server 80.213.8.30:9100;
        server 80.213.8.31:9000;
        server 80.213.8.31:9100;
    }
    server {
        listen       9001;
        server_name  localhost;
        location / {   #minio代理不能带任何路径
                proxy_pass http://minio;
                proxy_set_header Host $http_host;
                client_max_body_size 20m;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

posted @ 2023-01-13 10:47  村尚chun叔  阅读(1363)  评论(13编辑  收藏  举报