MinIO单机模式搭建
创建数据存储文件夹(data代表磁盘盘符)
mkdir -p /home/minio/data
mkdir -p /home/minio/config
创建Minio Docker实例
docker run -p 9000:9000 -p 9001:9001 \
--name minio-dev \
-d --restart=always \
-e "MINIO_ACCESS_KEY=admin" \
-e "MINIO_SECRET_KEY=abc123456" \
-v /home/minio/data:/data \
-v /home/minio/config:/root/.minio \
minio/minio \
server /data --console-address ":9001" -address ":9000"
访问管理后台测试
http://localhost:9001
账号为:admin/abc123456
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,并配置反向代理,nginx.conf
配置内容如下
#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
修改/etc/hosts文件,添加如下内容
192.168.31.65 dev.minio.com
然后使用域名进行访问
http://dev.minio.com/mybucket/test.jpg