亚洲视频二区_亚洲欧洲日本天天堂在线观看_日韩一区二区在线观看_中文字幕不卡一区

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.430618.com 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

目錄
  • 介紹
  • 單機版部署
  • 糾刪碼模式部署
  • 分布式部署

介紹

最近才知道minio這個對象存儲服務中間件,簡直相見恨晚,只怪我見識太短淺(哭泣臉)。

說得通俗易懂點,minio的作用就是用來存儲文件的,比如圖片、視頻、音頻等各種類型的文件。

那么問題來了,java本身就可以直接把文件寫到磁盤里面,為什么還要用minio呢?

  • minio有完善的文件管理功能,包括針對文件的上傳,下載,刪除等
  • minio有強大的糾刪功能,即便磁盤損壞,在一定程度上時可以避免丟失文件的
  • minio有完善的權限管理功能,它可以針對不同的業務角色,分配不同的操作權限
  • 天然的分布式存儲功能
  • 高性能;在標準硬件上,對象存儲的讀/寫速度最高可以高達183 GB/s和171 GB/s
  • 文檔全面,簡單易用

所以綜上所述,相較于其他的文件存儲方案,minio的競爭力還是很大的。下面附上官網鏈接。

單機版部署

一般為了簡單集成minio client,我們會自己部署一個單機版的先用用?,F在我們開始,講解一下如何快速部署一個單機版minio服務:

version: "3.7"
services:
  minio:
 ?  image: "quay.io/minio/minio:RELEASE.2022-08-02T23-59-16Z"
 ?  ports:
 ? ?  - "9000:9000"
 ? ?  - "9001:9001"
 ?  volumes:
 ? ?  - "./minio/data1:/data1"
 ? ?  - "./minio/data2:/data2"
 ?  command: server --console-address ":9001" http://minio/data{1...2}
 ?  environment:
 ? ?  - MINIO_ROOT_USER=admin
 ? ?  - MINIO_ROOT_PASSWORD=12345678
 ? ? ?#- MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE
 ? ? ?#- MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
 ?  healthcheck:
 ? ?  test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
 ? ?  interval: 30s
 ? ?  timeout: 20s
 ? ?  retries: 3

以上需要注意的幾個點:

  • 需要暴露的端口有兩個,一個是API暴露端口9000,一個是服務管理頁面暴露端口9001。啟動成功后,訪問9001端口即可進入管理頁面。
  • 單機版部署也可掛載多個磁盤,單個服務掛載超過(等于)4個磁盤,自動啟動糾刪碼模式,可以預防磁盤損壞的情況下,導致文件丟失。
  • 最新版本里面已經不使用MINIO_ACCESS_KEY和MINIO_SECRET_KEY兩個環境變量了,改由MINIO_ROOT_USER和MINIO_ROOT_PASSWORD替換。
  • 啟動命令中--console-address代表指定服務管理頁面暴露的端口,http://minio/data{1...2}代表指定的minio服務下面掛載的目標磁盤為/data1和/data2,否則磁盤掛載不起作用。API暴露端口可通過參數–address指定。

糾刪碼模式部署

為了啟動糾刪碼模式,我們需要在部署的服務上掛載至少4塊磁盤:

version: "3.7"
services:
  minio:
 ?  image: "quay.io/minio/minio:RELEASE.2022-08-02T23-59-16Z"
 ?  ports:
 ? ?  - "9000:9000"
 ? ?  - "9001:9001"
 ?  volumes:
 ? ?  - "./minio/data1:/data1"
 ? ?  - "./minio/data2:/data2"
 ? ?  - "./minio/data3:/data3"
 ? ?  - "./minio/data4:/data4"
 ?  command: server --console-address ":9001" http://minio/data{1...4}
 ?  environment:
 ? ?  - MINIO_ROOT_USER=admin
 ? ?  - MINIO_ROOT_PASSWORD=12345678
 ?  healthcheck:
 ? ?  test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
 ? ?  interval: 30s
 ? ?  timeout: 20s
 ? ?  retries: 3

在單機模式部署的情況下,調整為糾刪碼模式,我們需要修改兩個地方:

  • 掛載的磁盤增加到四個
  • 啟動命令里面補上對應的掛載磁盤

該模式運行其中某個磁盤出現損壞的情況,在磁盤損壞后也能保證文件不會丟失。

分布式部署

在單機上部署糾刪碼模式只能保證磁盤損壞的情況下,文件不丟失;并不能解決單點故障的問題,所以我們下面為了避免單點故障導致服務不可用,把minio服務改成分布式部署。

我們就部署四個機器,每個機器掛載四個磁盤,這樣的話,我們就形成了分布式糾刪碼模式了,這樣的話,我們文件存儲服務的可靠性就大大地增強了。

  • 首先準備四臺主機,ip地址分別為192.168.2.231,192.168.2.232,192.168.2.233,192.168.2.234;
  • 其次,我們分別在四臺機器上部署一個minio服務實例,參考以下docker-compose.yml:
version: "3.7"
services:
  minio:
 ?  image: "quay.io/minio/minio:RELEASE.2022-08-02T23-59-16Z"
 ?  ports:
 ? ?  - "9000:9000"
 ? ?  - "9001:9001"
 ?  volumes:
 ? ?  - "./minio/data1:/data1"
 ? ?  - "./minio/data2:/data2"
 ? ?  - "./minio/data3:/data3"
 ? ?  - "./minio/data4:/data4"
 ?  command: server --console-address ":9001" http://192.168.2.231:9000/data{1...4} http://192.168.2.232:9000/data{1...4} http://192.168.2.233:9000/data{1...4} http://192.168.2.234:9000/data{1...4}
 ?  environment:
 ? ?  - MINIO_ROOT_USER=admin
 ? ?  - MINIO_ROOT_PASSWORD=12345678
 ?  healthcheck:
 ? ?  test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
 ? ?  interval: 30s
 ? ?  timeout: 20s
 ? ?  retries: 3

在啟動命令中,我們需要把集群中所有的服務ip都寫進去,這樣的話,minio分布式服務才能正常通信。

  • 部署負載均衡服務nginx

當四臺機器上的服務全部起來后,我們需要提供一個負載均衡服務作為訪問minio分布式服務的統一的入口,首當其沖我們就想到了nginx,所以我們在使用docker compose部署一個nginx服務:

version: '3.7'
services:
  nginx:
 ?  image: nginx:1.19.2-alpine
 ?  hostname: nginx
 ?  volumes:
 ? ?  - ./nginx.conf:/etc/nginx/nginx.conf:ro
 ?  ports:
 ? ?  - "9000:9000"
 ? ?  - "9001:9001"

下面是nginx配置文件:

user  nginx;
worker_processes  auto;
error_log  /var/log/nginx/error.log warn;
pid ? ? ?  /var/run/nginx.pid;
?
events {
 ? ?worker_connections  4096;
}
?
http {
 ? ?include ? ? ? /etc/nginx/mime.types;
 ? ?default_type  application/octet-stream;
?
 ? ?log_format ?main ?'$remote_addr - $remote_user [$time_local] "$request" '
 ? ? ? ? ? ? ? ? ? ? ?'$status $body_bytes_sent "$http_referer" '
 ? ? ? ? ? ? ? ? ? ? ?'"$http_user_agent" "$http_x_forwarded_for"';
?
 ? ?access_log  /var/log/nginx/access.log  main;
 ? ?sendfile ? ? ?  on;
 ? ?keepalive_timeout  65;
?
 ? ?# include /etc/nginx/conf.d/*.conf;
?
 ? ?upstream minio {
 ? ? ? ?server 192.168.2.231:9000;
 ? ? ? ?server 192.168.2.232:9000;
 ? ? ? ?server 192.168.2.233:9000;
 ? ? ? ?server 192.168.2.234:9000;
 ?  }
?
 ? ?upstream console {
 ? ? ? ?ip_hash;
 ? ? ? ?server 192.168.2.231:9001;
 ? ? ? ?server 192.168.2.232:9001;
 ? ? ? ?server 192.168.2.233:9001;
 ? ? ? ?server 192.168.2.234:9001;
 ?  }
 ? ?server {
 ? ? ? ?listen ? ? ? 9000;
 ? ? ? ?listen  [::]:9000;
 ? ? ? ?server_name  localhost;
?
 ? ? ? ?# To allow special characters in headers
 ? ? ? ?ignore_invalid_headers off;
 ? ? ? ?# Allow any size file to be uploaded.
 ? ? ? ?# Set to a value such as 1000m; to restrict file size to a specific value
 ? ? ? ?client_max_body_size 0;
 ? ? ? ?# To disable buffering
 ? ? ? ?proxy_buffering off;
 ? ? ? ?proxy_request_buffering off;
?
 ? ? ? ?location / {
 ? ? ? ? ? ?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_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;
 ? ? ?  }
 ?  }?
 ? ?server {
 ? ? ? ?listen ? ? ? 9001;
 ? ? ? ?listen  [::]:9001;
 ? ? ? ?server_name  localhost;
?
 ? ? ? ?# To allow special characters in headers
 ? ? ? ?ignore_invalid_headers off;
 ? ? ? ?# Allow any size file to be uploaded.
 ? ? ? ?# Set to a value such as 1000m; to restrict file size to a specific value
 ? ? ? ?client_max_body_size 0;
 ? ? ? ?# To disable buffering
 ? ? ? ?proxy_buffering off;
 ? ? ? ?proxy_request_buffering off;
?
 ? ? ? ?location / {
 ? ? ? ? ? ?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_set_header X-NginX-Proxy true;
?
 ? ? ? ? ? ?# This is necessary to pass the correct IP to be hashed
 ? ? ? ? ? ?real_ip_header X-Real-IP;
?
 ? ? ? ? ? ?proxy_connect_timeout 300;
 ? ? ? ? ? ?
 ? ? ? ? ? ?# To support websocket
 ? ? ? ? ? ?proxy_http_version 1.1;
 ? ? ? ? ? ?proxy_set_header Upgrade $http_upgrade;
 ? ? ? ? ? ?proxy_set_header Connection "upgrade";
 ? ? ? ? ? ?
 ? ? ? ? ? ?chunked_transfer_encoding off;
?
 ? ? ? ? ? ?proxy_pass http://console;
 ? ? ?  }
 ?  }
}

啟動nginx服務,這樣所有的請求都通過nginx負載均衡到minio服務上。

這樣完成了minio服務的三種docker compose部署方式,逐次遞進地講解了每種方式的優勢。如果我們只是為了集成minio到我們的應用程序中,只需要搭建一個單機版的服務即可。更多相關Docker compose內容請搜索以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持!

分享到:
標簽:compose Docker 服務 服務器 部署
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定