分布式存储MINIO集群部署实例
简介:
MinIO是根据Apache许可v2.0发布的高性能对象存储。它与Amazon S3云存储服务兼容。使用MinIO可以构建用于机器学习,分析和应用程序数据工作负载的高性能基础架构。
数据保护:
分布式MinIO 使用擦除代码提供针对多个节点/驱动器故障和位腐烂的保护。由于分布式MinIO所需的最小磁盘为4(与擦除编码所需的最小磁盘相同),因此在启动分布式MinIO时,擦除代码会自动启动。
高可用:
如果托管磁盘的服务器脱机,则独立的MinIO服务器将关闭。相反,只要m / 2个服务器或m * n / 2个或更多磁盘在线,具有m个服务器和n个磁盘的分布式MinIO设置将使您的数据安全。
例如,一个16台服务器的分布式设置(每个节点200个磁盘)将继续提供文件,即使在默认配置中最多有8台服务器处于脱机状态,即,大约1600个磁盘可以关闭,MinIO也会继续提供文件。但是,您至少需要在线9台服务器才能创建新对象。
环境准备
Centos7.6 3台
分别添加两块20G磁盘
192.168.3.63
192.168.3.64
192.168.3.64
关闭防火墙,selinux
systemctl disable firewalld && systemctl stop firewalld
sed -i s#SELINUX=enforce#SELINUX=disable# /etc/selinux/config
注:selinux 重启生效
设置时间同步
ntpdate time.nist.gov
crontab -e
* */1 * * * root ntpdatetime.nuri.net;
systemctl restart crond
下载地址:
服务端:
wget https://dl.minio.io/server/minio/release/linux-amd64/minio
客户端
wget https://dl.minio.io/client/mc/release/linux-amd64/mc
3台服务器一样
mkdir /opt/minio/data1 -p
mkdir /opt/minio/data2 -p
192.168.3.63 挂载磁盘路径: /opt/minio/data1
192.168.3.64 挂载磁盘路径:/opt/minio/data1
192.168.3.65 挂载磁盘路径:/opt/minio/data1 /opt/minio/data2
注意:文件路径可任意指定,但是必须挂载
3台服务器一样磁盘格式化及挂载
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x75c7ab8f.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): w
[root@localhost ~]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x78033711.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): w
mkfs.xfs /dev/sdb1
mkfs.xfs /dev/sdc1
[root@localhost ~]# mount /dev/sdc1 /opt/minio/data1
[root@localhost ~]# mount /dev/sdc1 /opt/minio/data2
[root@localhost ~]# df -Th | grep data
永久挂载
[root@localhost ~]# vi /etc/fstab
/dev/sdb1 /opt/minio/data1 xfs fefaults 0 0
/dev/sdc1 /opt/minio/data2 xfs fefaults 0 0
将minio移动到/home/minio下 ,创建run.sh启动脚本并chmod + x 赋予 minio和run.sh 可执行权限
启动脚本:三台服务器一致
cat /home/minio/run.sh
#!/bin/bash
#浏览器访问的账号和密码,各节点要保持一致,密码不能过于简单否则启动失败
export MINIO_ACCESS_KEY=minioroot
export MINIO_SECRET_KEY=minioabc
/home/minio/minio server --config-dir /home/minio \
http://192.168.3.63/opt/minio/data1 \
http://192.168.3.64/opt/minio/data1 \
http://192.168.3.65/opt/minio/data1 \
http://192.168.3.65/opt/minio/data2
设置命令启动服务vi /usr/lib/systemd/system/minio.service
[Unit]
Description=Minio service
Documentation=https://docs.minio.io/
[Service]
WorkingDirectory=/home/minio/
ExecStart=/home/minio/run.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
[root@localhost ~]# systemctl daemon-reload && systemctl start minio
#查看启动情况
systemctl status minio
注意:可能出现服务器提示等待另外磁盘连接的情况 ,关闭防火墙
访问 任意节点的ip地址:9000 即可访问,输入上面定义的账号密码即可
单台启动:nohup ./minio server /opt/minio/data > /home/minio/minio.log 2>&1 &