搭建高可用MinIO集群

配置服务器

cat >> /etc/sysctl.conf <<- 'EOF'
net.ipv4.ip_forward=1
vm.max_map_count=655360
EOF

# 查看配置
sysctl -p

配置docker

在第一台服务器192.168.2.4下运行 

docker run -d --name minio-4 \
--restart=always \
--net=host \
-v /data/n4/export1:/data1 \
-v /data/n4/export2:/data2 \
-e "MINIO_ROOT_USER=admin" \
-e "MINIO_ROOT_PASSWORD=mytest123" \
-e MINIO_ACCESS_KEY=minio \
-e MINIO_SECRET_KEY=minio123 \
minio/minio server --address 192.168.2.4:9000 http://192.168.2.{4...6}/export{1...2}
  • -d:将容器设置为在后台模式下运行。
  • --name minio-3:指定容器的名称为minio-3。
  • --restart=always:在容器退出时,总是自动重新启动容器。
  • --network macvlan31:将容器连接到名为macvlan31的Macvlan网络。
  • --ip=192.168.2.3:为容器分配静态IP地址192.168.2.3。
  • -v /data/n3/export1:/export1:将主机的/data/n3/export1目录挂载到容器内的/export1目录,实现主机和容器之间的文件共享。
  • -v /data/n3/export2:/export2:将主机的/data/n3/export2目录挂载到容器内的/export2目录。
  • -e "MINIO_ROOT_USER=admin":通过环境变量设置MinIO的根用户为admin。
  • -e "MINIO_ROOT_PASSWORD=mytest123":通过环境变量设置MinIO的根用户密码为mytest123。
  • minio/minio server http://192.168.2.{3...5}/export{3...5}:启动MinIO服务器,并配置存储目录为http://192.168.2.3/export3http://192.168.2.4/export4http://192.168.2.5/export5

第二台服务器下运行 

docker run -d --name minio-5 \
--restart=always \
--net=host \
-v /data/n5/export1:/data1 \
-v /data/n5/export2:/data2 \
-e "MINIO_ROOT_USER=admin" \
-e "MINIO_ROOT_PASSWORD=mytest123" \
-e MINIO_ACCESS_KEY=minio \
-e MINIO_SECRET_KEY=minio123 \
minio/minio server --address 192.168.2.5:9000 http://192.168.2.{4...6}/export{1...2}

第三台服务器下运行

docker run -d --name minio-6 \
--restart=always \
--net=host \
-v /data/n6/export1:/data1 \
-v /data/n6/export2:/data2 \
-e "MINIO_ROOT_USER=admin" \
-e "MINIO_ROOT_PASSWORD=mytest123" \
-e MINIO_ACCESS_KEY=minio \
-e MINIO_SECRET_KEY=minio123 \
minio/minio server --address 192.168.2.6:9000 http://192.168.2.{4...6}/export{1...2}

问题出错 

Error: Drive `http://192.168.2.6:9000/export2` is part of root drive, will not be used (*errors.errorString),如果出现上述问题,则需要添加一个新的硬盘。把数据挂载到新硬盘中。

访问

使用192.168.2.4:9000/去访问,Minio三节点集群宕机一个节点时可以正常使用  宕机两个节点时 无法使用。

搭建高可用MinIO集群_第1张图片

配置nginx

http {
    # 调大客户端请求体的大小限制,便于MinIO上传大文件
    client_max_body_size 10M;

    # websocket
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

     upstream minioapi {
      server 192.168.2.4:9000;
      server 192.168.2.5:9000;
      server 192.168.2.6:9000;
     }

     upstream minioconsole {
      server 192.168.2.4:50000;
      server 192.168.2.5:50000;
      server 192.168.2.6:50000;
     }
     
    server {
       listen     80;
       server_name  console.minio.com api.minio.com;
       access_log  /var/log/nginx/http_access.log  main;
       return 301 https://$host$request_uri;
    }

    server {
       listen       443 ssl http2;
       listen       [::]:443 ssl http2;
       server_name  api.minio.com;

       ssl_certificate "/etc/nginx/ssl_cert/api.minio.com.pem";
       ssl_certificate_key "/etc/nginx/ssl_cert/api.minio.com.key";
       ssl_session_cache shared:SSL:1m;
       ssl_session_timeout  10m;
       ssl_ciphers HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers on;

       access_log  /var/log/nginx/api_minio_com_access.log  main;
       location / {
           proxy_pass http://minioapi/;
           proxy_set_header Host $http_host;
           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_http_version 1.1;
        }
    }

    server {
       listen       443 ssl http2;
       listen       [::]:443 ssl http2;
       server_name  console.minio.com;

       ssl_certificate "/etc/nginx/ssl_cert/console.minio.com.pem";
       ssl_certificate_key "/etc/nginx/ssl_cert/console.minio.com.key";
       ssl_session_cache shared:SSL:1m;
       ssl_session_timeout  10m;
       ssl_ciphers HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers on;

       access_log  /var/log/nginx/console_minio_com_access.log  main;
       location / {
           proxy_pass http://minioconsole/;
           proxy_set_header Host $http_host;
           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_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection $connection_upgrade;
        }
    }
}

你可能感兴趣的:(工作问题总结,java,前端,linux)