LINUX-MinIO搭建

一、MinIO单机模式

1、创建数据存储文件夹(data代表磁盘盘符)

mkdir -p /home/minio/data
mkdir -p /home/minio/config

2、创建Minio Docker实例

docker run -p 9000:9000 -p 9001:9001 \
--name minio-dev \
-d --restart=always \
-e "MINIO_ACCESS_KEY=minioadmin" \
-e "MINIO_SECRET_KEY=minioadmin123" \
-v /home/minio/data:/data \
-v /home/minio/config:/root/.minio \
minio/minio \
server /data --console-address ":9001" -address ":9000"

3、访问管理后台测试

访问地址
http://localhost:9001
账号为:
minioadmin/minioadmin123

二、MinIO集群模式搭建

1、创建挂载文件夹

mkdir -p /home/minio/data1
mkdir -p /home/minio/data2
mkdir -p /home/minio/data3
mkdir -p /home/minio/data4

2、创建docker桥接网络和4个docker minio实例

#用桥接模式`bridge`创建网络
docker network create -d bridge --subnet 172.30.0.0/24 --gateway 172.30.0.1 minio-network

#创建实例1
docker run -it -d \
-p 8500:9000 \
-p 8600:9001 \
--name minio1 \
--network minio-network \
--ip 172.30.0.2 \
-v /home/minio/data1:/data1 \
-e "MINIO_ROOT_USER=admin" \
-e "MINIO_ROOT_PASSWORD=abc123456" \
minio/minio server http://172.30.0.2/data1 http://172.30.0.3/data1 http://172.30.0.4/data1 http://172.30.0.5/data1 --console-address ":9001"

#创建实例2
docker run -it -d \
-p 8501:9000 \
-p 8601:9001 \
--name minio2 \
--network minio-network \
--ip 172.30.0.3 \
-v /home/minio/data2:/data1 \
-e "MINIO_ROOT_USER=admin" \
-e "MINIO_ROOT_PASSWORD=abc123456" \
minio/minio server http://172.30.0.2/data1 http://172.30.0.3/data1 http://172.30.0.4/data1 http://172.30.0.5/data1 --console-address ":9001"

#创建实例3
docker run -it -d \
-p 8502:9000 \
-p 8602:9001 \
--name minio3 \
--network minio-network \
--ip 172.30.0.4 \
-v /home/minio/data3:/data1 \
-e "MINIO_ROOT_USER=admin" \
-e "MINIO_ROOT_PASSWORD=abc123456" \
minio/minio server http://172.30.0.2/data1 http://172.30.0.3/data1 http://172.30.0.4/data1 http://172.30.0.5/data1 --console-address ":9001"

#创建实例4
docker run -it -d \
-p 8503:9000 \
-p 8603:9001 \
--name minio4 \
--network minio-network \
--ip 172.30.0.5 \
-v /home/minio/data4:/data1 \
-e "MINIO_ROOT_USER=admin" \
-e "MINIO_ROOT_PASSWORD=abc123456" \
minio/minio server http://172.30.0.2/data1 http://172.30.0.3/data1 http://172.30.0.4/data1 http://172.30.0.5/data1 --console-address ":9001"

3、安装Nginx,并配置反向代理

#API接口反向代理设置
upstream minio{
    server 192.168.31.65:8500;
    server 192.168.31.65:8501;
    server 192.168.31.65:8502;
    server 192.168.31.65:8503;
}

server {
    listen 80;
    server_name dev.minio.com;
    charset utf-8;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;

        proxy_connect_timeout 300;
        # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        chunked_transfer_encoding off;
        client_max_body_size 1000m;

        proxy_pass http://minio;
    }

}

#管理后台反向代理设置
upstream minio-web{
    server 192.168.31.65:8600;
    server 192.168.31.65:8601;
    server 192.168.31.65:8602;
    server 192.168.31.65:8603;
}

server {
    listen 9001;
    server_name 192.168.31.65; #这里如果设置成域名会报错‘strict-origin-when-cross-origin’,        页面出现一片空白
    charset utf-8;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;

        proxy_connect_timeout 300;
        # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        chunked_transfer_encoding off;

        proxy_pass http://minio-web/;
    }

}

4、使用域名进行测试

 http:// 192.168.31.65:9001/ #管理后台地址

 账号为:admin/abc123456

        登录后台后创建存储桶mybucket,并将该存储桶的访问策略(Manage->Access Policy)修改为public,·然后返回并上传一个图片文件test.jpg

5、hosts文件配置添加

您的IP dev.minio.com

6、进行访问

http://dev.minio.com/mybucket/test.jpg

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值