1.基本定义
由于是非常轻量级的软件,所以架构上也没有这么复杂,他使用操作系统的文件系统作为存储介质,我们在向任意节点写数据的时候,minio会自动同步数据到另外的节点,而机制叫做erasure code(纠删码)来保证集群的稳定,保证数据可用,所以我们建议至少使用4个节点来构建集群。
如果一个N节点的分布式minio,只要有N/2节点在线,数据就是安全的。但是要保证至少有N/2+1个节点来创建新的对象。比如:我们的集群有4个节点,每个节点上一块盘,就算有2两个节点宕机,这个集群仍然是可读的,但是,我们需要3个节点才能让集群写数据。这就是为什么我们要有4个节点来构建集群。
2.机器列表
机器资源 | 挂载磁盘路径 |
---|---|
172.30.0.2 | /home/minio/data1 |
172.30.0.3 | /home/minio/data2 |
172.30.0.4 | /home/minio/data3 |
172.30.0.5 | /home/minio/data4 |
3.网络
# 创建bridge
docker network create -d bridge --subnet 172.30.0.0/16 --gateway 172.30.0.1 minio-network
# 查看信息
docker network ls
docker network inspect minio-network
# 删除
docker network rm networkId
4.mioio安装
# 拉去镜像:指定版本
docker pull minio:RELEASE.2023-02-27T18-10-45Z
docker run \-p 8500:9000 \-p 8600:9090 \-d \--name minio1 \--network minio-network \--ip 172.30.0.2 \-v /home/minio/data1:/data1 \-e "MINIO_ROOT_USER=minioadmin" \-e "MINIO_ROOT_PASSWORD=minioadmin" \minio/minio:RELEASE.2023-02-27T18-10-45Z 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 ":9090"
docker run \-p 8501:9000 \-p 8601:9090 \-d \--name minio2 \--network minio-network \--ip 172.30.0.3 \-v /home/minio/data2:/data1 \-e "MINIO_ROOT_USER=minioadmin" \-e "MINIO_ROOT_PASSWORD=minioadmin" \docker.io/minio/minio:RELEASE.2023-02-27T18-10-45Z 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 ":9090"
docker run \-p 8502:9000 \-p 8602:9090 \-d \--name minio3 \--network minio-network \--ip 172.30.0.4 \-v /home/minio/data3:/data1 \-e "MINIO_ROOT_USER=minioadmin" \-e "MINIO_ROOT_PASSWORD=minioadmin" \docker.io/minio/minio:RELEASE.2023-02-27T18-10-45Z 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 ":9090"
docker run \-p 8503:9000 \-p 8603:9090 \-d \--name minio4 \--network minio-network \--ip 172.30.0.5 \-v /home/minio/data4:/data1 \-e "MINIO_ROOT_USER=minioadmin" \-e "MINIO_ROOT_PASSWORD=minioadmin" \docker.io/minio/minio:RELEASE.2023-02-27T18-10-45Z 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 ":9090"
docker run \-p 8504:9000 \-p 8604:9090 \-d \--name minio5 \--network minio-network \--ip 172.30.0.5 \-v /home/minio/data4:/data1 \-e "MINIO_ROOT_USER=minioadmin" \-e "MINIO_ROOT_PASSWORD=minioadmin" \docker.io/minio/minio:RELEASE.2023-02-27T18-10-45Z 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 ":9090"
5.nginx负载
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {include 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 logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;upstream minio_console {server 172.30.0.2:9090 max_fails=3 fail_timeout=5s;server 172.30.0.3:9090 max_fails=3 fail_timeout=5s;server 172.30.0.4:9090 max_fails=3 fail_timeout=5s;server 172.30.0.5:9090 max_fails=3 fail_timeout=5s;}upstream minio_api {server 172.30.0.2:9000 max_fails=3 fail_timeout=5s;server 172.30.0.3:9000 max_fails=3 fail_timeout=5s;server 172.30.0.4:9000 max_fails=3 fail_timeout=5s;server 172.30.0.5:9000 max_fails=3 fail_timeout=5s;}server {listen 80;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}server {listen 9001;server_name localhost;ignore_invalid_headers off;client_max_body_size 0;proxy_buffering off; #access_log /var/log/minio.com_access.log main;#error_log /var/log/minio.com_error.log warn;location / {# 添加了websocket支持proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";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_pass http://minio_console;}}server {listen 9000; server_name localhost;ignore_invalid_headers off; client_max_body_size 0;proxy_buffering off; #access_log /var/log/minio.com_access.log main;#error_log /var/log/minio.com_error.log warn;location / {# 添加了websocket支持proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";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_pass http://minio_api;}}}