当前位置:   article > 正文

Minio集群docker-compose部署Ngnix均衡负载(多机分布式)_docker-compose 集群 minio

docker-compose 集群 minio

目录

概述

部署流程

软件准备:

部署环境:


 

概述

        先动手部署,部署成功后再补充,加深理解。

 

部署流程

软件准备:

虚拟机 + Ubuntu18.04 + docker

部署环境:

1、整体思路

        分别在3台服务器上创建minio服务,这里可以使用docker或者docker-compose的方式比较方便,相当于独立的本地服务;然后在其中1台服务器上进行ngnix的部署以实现多节点的反向代理与均衡负载。已在公司服务器成功部署过,这里再拿虚拟机走一遍。

2、docker-compose安装:docker-compose文件下载

         可以在这个步骤完成之后克隆虚拟机

  1. # 下载上方的docker-compose-linux-x86_64文件
  2. # 拷贝docker-compose-linux-x86_64文件为
  3. sudo cp mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
  4. # 给权限
  5. chmod +x /usr/local/bin/docker-compose
  6. # 验证
  7. docker-compose version

c387ff7c426b4172a288f9ff0bc029f9.png

如图所示 我这里建了3个虚拟机

3、创建挂载路径(3台服务器)

  1. sudo mkdir -p /data/application/oosEnv/minio/minio/data1
  2. sudo mkdir -p /data/application/oosEnv/minio/minio/data1
  3. sudo mkdir -p /data/application/oosEnv/nginx

4、创建docker-compose.yml(3台服务器)

  1. cd /data/application/oosEnv/minio
  2. sudo vim docker-compose.yml
  3. # 粘贴下方代码框yaml文件,保存推出
  1. version: '3.7'
  2. services:
  3. minio1: # 注意3台服务器分别为minio1,minio2,minio3
  4. image: minio/minio
  5. volumes:
  6. - /data/application/oosEnv/minio/minio/data1:/data1
  7. - /data/application/oosEnv/minio/minio/data2:/data2
  8. environment:
  9. MINIO_ROOT_USER: admin
  10. MINIO_ROOT_PASSWORD: admin123456
  11. network_mode: host
  12. command: server --console-address ":9001" http://minio{1...3}/data{1...2}
  13. extra_hosts:
  14. - "minio1:192.168.xx.131"
  15. - "minio2:192.168.xx.132"
  16. - "minio3:192.168.xx.133"
  17. healthcheck:
  18. test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
  19. interval: 30s
  20. timeout: 20s
  21. retries: 3

5、创建nginx的docker-compose.yml (3台服务器)

  1. cd /data/application/oosEnv/nginx
  2. sudo vim docker-compose.yml
  3. # 粘贴下方代码框yaml文件,保存推出
  1. version: '3.7'
  2. services:
  3. nginx:
  4. container_name: nginx
  5. image: nginx:1.19.2-alpine
  6. volumes:
  7. - /data/application/oosEnv/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
  8. ports:
  9. - "90:9000"
  10. - "91:9001"
  1. cd /data/application/oosEnv/nginx
  2. sudo vim nginx.conf
  3. # 粘贴下方代码框conf文件,保存推出
  1. user nginx;
  2. worker_processes auto;
  3. error_log /var/log/nginx/error.log warn;
  4. pid /var/run/nginx.pid;
  5. events {
  6. worker_connections 1024;
  7. }
  8. http {
  9. include /etc/nginx/mime.types;
  10. default_type application/octet-stream
  11. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for"';
  14. access_log /var/log/nginx/access.log main;
  15. sendfile on
  16. keepalive_timeout 65;
  17. upstream minio {
  18. server 192.168.xx.131:9000;
  19. server 192.168.xx.132:9000;
  20. server 192.168.xx.133:9000;
  21. }
  22. upstream console {
  23. ip_hash;
  24. server 192.168.xx.131:9001;
  25. server 192.168.xx.132:9001;
  26. server 192.168.xx.133:9001;
  27. }
  28. server {
  29. listen 9000;
  30. listen [::]:9000;
  31. server_name localhost;
  32. ignore_invalid_headers off;
  33. client_max_body_size 0;
  34. proxy_buffering off;
  35. location / {
  36. proxy_set_header Host $http_host;
  37. proxy_set_header X-Real-IP $remote_addr;
  38. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  39. proxy_set_header X-Forwarded-Proto $scheme;
  40. proxy_connect_timeout 300;
  41. # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
  42. proxy_http_version 1.1;
  43. proxy_set_header Connection "";
  44. chunked_transfer_encoding off;
  45. proxy_pass http://minio;
  46. }
  47. }
  48. server {
  49. listen 9091;
  50. listen [::]:9091;
  51. server_name localhost;
  52. ignore_invalid_headers off;
  53. client_max_body_size 0;
  54. proxy_buffering off;
  55. proxy_request_buffering off;
  56. location / {
  57. proxy_set_header Host $http_host;
  58. proxy_set_header X-Real-IP $remote_addr;
  59. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  60. proxy_set_header X-Forwarded-Proto $scheme;
  61. proxy_set_header X-NginX-Proxy true;
  62. real_ip_header X-Real-IP;
  63. proxy_connect_timeout 300;
  64. proxy_http_version 1.1;
  65. proxy_set_header Upgrade $http_upgrade;
  66. proxy_set_header Connection "upgrade";
  67. chunked_transfer_encoding off;
  68. proxy_pass http://console;
  69. }
  70. }
  71. }

 文件结构如下:81358f5aec85463db8737da5765e3523.png

 

6、启动minio服务(3台服务器的服务分别起来)

  1. sudo docker-compose pull
  2. sudo docker-compose up -d
  3. sudo docker-compose ps # 查看容器状态

a104889eda864f1da9c3c0aab0a2eb28.png

 随便打开其中1台服务器端口可以正常连接

76d56c380b834c4cb918f93c15962c6c.png

 

7、启动nginx服务(可以指定其中一台)

  1. sudo docker-compose pull
  2. sudo docker-compose up -d


9ecbe66c8c4c4c81a3d28c95eb6cf7c5.png

如图在131的服务器上创建bucket另外两个成功同步。
ac2ca5ef3c3440b28edc445fff5b182e.png

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/919657
推荐阅读
相关标签
  

闽ICP备14008679号