minio集群服务器规划为一共10台服务器分别为8台minio,2台nginx代理,服务器配置如下:
服务器角色 | 数量 | CPU/内存 | 数据磁盘 |
---|---|---|---|
minio服务器 | 8 | 8C16G | 4块1.5T磁盘 |
nginx代理服务器 | 2 | 4C8G | 无 |
minio扩容资源(后期扩容) | 8 | 8C16G | 4块1.5T磁盘 |
minio备份资源 | 不限 | 不限 | 需要满足存放minio集群所有对象数据的空间容量 |
注意事项
#修改方法
[zhangzhuo@minio1 ~]$ cat /etc/updatedb.conf
#在这里添加排除的目录
PRUNEPATHS = "/afs /media /mnt /net /sfs /tmp /udev /var/cache/ccache /var/lib/yum/yumdb /var/spool/cups /var/spool/squid /var/tmp /data1"
#!/bin/bash
cat > sysctl.conf <
minio数据磁盘
minio配置文件
cat /etc/default/minio.conf
MINIO_ROOT_USER=minio
MINIO_ROOT_PASSWORD=minio123
MINIO_PROMETHEUS_AUTH_TYPE="public"
MINIO_VOLUMES="http://minio{1...8}:9000/data/minio{1...4}"
MINIO_OPTS='--console-address \":9001\"'
注意事项
MINIO_VOLUMES="http://10.100.16.{1...8}:9000/data1/minio"
minio启动service文件
[root@minio1 default]# cat /etc/systemd/system/minio.service
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-noline.target
After=network-noline.target
[Service]
WorkingDirectory=/usr/local/minio
User=root
Group=root
EnvironmentFile=-/etc/default/minio.conf
ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]";then echo \"Variable MINIO_VOLUEMS not set in /etc/default/minio\";exit 1;fi"
ExecStart=/usr/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
Restart=always
[Install]
WantedBy=multi-user.target
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 10.202.40.183:9000;
server 10.202.40.83:9000;
server 10.202.41.126:9000;
server 10.202.41.174:9000;
}
upstream console {
ip_hash;
server 10.202.40.183:9001;
server 10.202.40.83:9001;
server 10.202.41.126:9001;
server 10.202.41.174: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;
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;
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;
# 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://console;
}
}
}
keepalived服务配置文件
监测脚本
[14:14:51 root@centos7 ~]#cat check_nginx_minio.sh
#!/bin/bash
/usr/bin/killall -0 nginx && [ 200 == `curl -I http://127.0.0.1:9000/minio/health/cluster | head -n1 | awk '{print $2}'` ] && exit
systemctl restart nginx && [ 200 == `curl -I http://127.0.0.1:9000/minio/health/cluster | head -n1 | awk '{print $2}'` ] && exit
keepalived具体配置
vrrp_script check_nginx {
script "/root/check_nginx_minio.sh"
interval 5
weight -30
fall 3
rise 2
timeout 2
}
vrrp_instance minio_lb {
state MASTER
interface eth0
virtual_router_id 80
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
unicast_src_ip 192.168.10.71
unicast_peer{
192.168.10.72
}
virtual_ipaddress {
192.168.10.100/24 dev eth0 label eth0:1
}
track_script {
check_nginx
}
}
mc
将所有的配置信息都存储在~/.mc/config.json
文件中
mc config host add [--api API-SIGNATURE]
#示例
mc config host add minio http://192.168.10.100:9000 minio minio123 --api s3v4
由于预计数据量过大,这里使用rclone工具进行数据同步,把minio集群bucket的对象数据同步到备份服务器,备份服务器配置可以低一些,但是存储空间需要满足minio集群存储空间的一半(如果minio集群存储空间一共48T那备份服务器需要24T的空间来备份数据)
具体备份方法
#配置rclone工具
[root@minio01 ~]# cat ~/.config/rclone/rclone.conf
[minio]
type = s3
evn_auth = false
access_key_id = minio
secret_access_key = minio123
region = us-east-1
endpoint = http://192.168.10.100:9000
#验证是否可以正常使用
[root@minio01 ~]# rclone lsd minio:
-1 2021-09-13 02:56:25 -1 s3testqwer1
#备份命令
[root@minio01 ~]# rclone sync minio:/s3testqwer1 minio/ #全量备份
[root@minio01 ~]# rclone sync minio:/s3testqwer1 minio/ --checksum #使用md5判断文件是否需要重新同步,即增量备份
其他备份参数,根据自己需求可以添加
--transfers=N
- 并行文件数,默认为4,根据内存,以及带宽调整推荐同步备份数据命令
rclone sync minio:/bucket名称 /data/minio --transfers=8 --update -v --log-file=rclone.log
推荐恢复备份数据命令
rclone sync /data/minio minio:/bucket名称 --transfers=8 --update -v --log-file=rclone.log
扩容推荐在集群容量使用到70%时进行扩容。
扩容需要准备一个跟原有minio服务器相同规格的集群,进行服务器初始化以及安装minio,但是配置文件需要进行修改,所有minio服务器全部修改,重启所有服务,之后在nginx代理中添加新服务器。
修改后配置文件示例:
cat /etc/default/minio.conf
MINIO_ROOT_USER=minio
MINIO_ROOT_PASSWORD=minio123
MINIO_PROMETHEUS_AUTH_TYPE="public"
MINIO_VOLUMES="http://minio{1...8}:9000/data/minio{1...4} http://minio{9...16}:9000/data/minio{1...4}"
MINIO_OPTS='--console-address \":9001\"'
注意
例如:集群部署时使用4块1T的磁盘使用逻辑卷的方式部署四个数据目录,之后扩容时在安装4块1T磁盘把四个数据目录扩容到2T,相应的minio集群容量也扩充1倍
逻辑卷创建,扩容示例
逻辑卷创建
#创建PV
#pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
#创建卷组
#vgcreate minio /dev/sdb
Volume group "minio" successfully created
#创建逻辑卷
lvcreate -l 100%FREE -n minio minio
Logical volume "minio" created.
#格式化挂载
mkfs.xfs /dev/minio/minio
mount /dev/minio/minio /mnt/
扩容逻辑卷
#添加磁盘到pv
#pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
#把pv添加到卷组
#vgextend minio /dev/sdc
Volume group "minio" successfully extended
#扩容逻辑卷
lvresize -r -l +100%FREE /dev/minio/minio
minio集群有纠删码机制,即使在集群数据盘挂掉一半的情况下,你集群中数据也是安全的。但是如果集群想要正常读写你需要有N/2+1的节点数才可以正常读写如果现有minio集群由于节点损坏或节点物理故障需更换节点时,请直接进行更换节点。
注意事项
更换的新节点没有数据
更换步骤
#验证当前节点状态,已经挂掉一个节点
[root@minio01 ~]# mc admin info minio
● minio2:9000
Uptime: offline
Drives: 0/2 OK
● minio1:9000
Uptime: 16 minutes
Version: 2021-07-12T02:44:53Z
Network: 1/2 OK
Drives: 2/2 OK
9.5 GiB Used, 1 Bucket, 10,000 Objects
2 drives online, 2 drives offline
#修改hosts文件
[root@minio01 ~]# vim /etc/hosts
192.168.10.51 minio1
192.168.10.52 minio2
#在新节点与旧节点重启服务
[root@minio01 ~]# systemctl restart minio
[root@minio02 ~]# systemctl status minio
#验证集群状态
[root@minio01 ~]# mc admin info minio
● minio2:9000
Uptime: 1 minute
Version: 2021-07-12T02:44:53Z
Network: 2/2 OK
Drives: 2/2 OK
● minio1:9000
Uptime: 2 minutes
Version: 2021-07-12T02:44:53Z
Network: 2/2 OK
Drives: 2/2 OK
9.5 GiB Used, 1 Bucket, 10,000 Objects
4 drives online, 0 drives offline
注意事项
验证更换的新节点是否有数据
更换的节点在启动后,会自动进行同步数据
在写入数据时挂掉一个节点
数据写完后正常节点的数据
数据写完后错误节点的数据
启动挂掉的节点,验证集群状态
这里可以看到集群状态已经恢复正常
故障节点启动后,会自动修复数据,数据修复后数据目录
注意事项
minio监控推荐使用Prometheus+grafana进行监控
[zhangzhuo@gs-server-10562 ~]$ cat /usr/local/prometheus/prometheus.yml
scrape_configs:
#这里为minio集群监控指标收集
- job_name: minio-job
metrics_path: /minio/v2/metrics/cluster
scheme: http
static_configs:
- targets: ['10.201.60.115:9000']
#这里为minio节点node_exporter主机监控指标
- job_name: node
static_configs:
- targets: ['10.201.60.115:9100','10.201.82.139:9100','10.201.83.162:9100','10.201.83.159:9100','10.201.50.61:9100','10.201.60.142:9100','10.201.60.183:9100','10.201.60.175:9100',]
**minio集群grafana模板:**MinIO Dashboard dashboard for Grafana | Grafana Labs
**minio节点主机grafana模板:**Node Exporter Quickstart and Dashboard dashboard for Grafana | Grafana Labs
测试说明
测试结果数据
读写测试结果
集群监控
集群节点负载数据
节点名称 | CPU15分负载值 | 内存使用 | 磁盘读写速率 | 磁盘延迟 |
---|---|---|---|---|
minio1 | 5.3 | 14.33G | 16M/s | 450ms |
minio2 | 13.68 | 13.66G | 15M/s | 963ms |
minio3 | 13.35 | 15.24G | 15M/s | 955ms |
minio4 | 14.12 | 14.26G | 16M/s | 988ms |
minio5 | 14.71 | 14G | 14.28M/s | 999ms |
minio6 | 4.76 | 13.54G | 15.35M/s | 887ms |
minio7 | 17.29 | 14.1G | 13.34M/s | 994ms |
minio8 | 17.59 | 15.69G | 13.84M/s | 997ms |
测试结果