操作系统:CentOS 7.3
Minio下载
将下载好的minio移动到 /opt/minio/文件夹下 或 者进入到/opt/minio/文件夹下使用下面的命令下载:
wget https://dl.minio.io/server/minio/release/linux-amd64/minio
2.1、机器资源
192.168.129.133 挂载磁盘路径:/data/minio_data
192.168.129.135 挂载磁盘路径:/data/minio_data
192.168.129.136 挂载磁盘路径:/data/minio_data
192.168.129.137 挂载磁盘路径:/data/minio_data
生成环境强烈建议最少四台机器,这也是官方的建议要求,这样的话就可以做到挂掉一台机器集群依然可以读写,挂掉两台机器集群依然可读,本文仅以两台机器为例子说明如何搭建集群
2.2、创建相关目录(所有节点,上面四台机器都创建相同路径的文件夹)
[root@localhost /]# mkdir /data/minio_data/
注意:需要将新建的目录挂在到对应的磁盘下,磁盘不挂在好,集群启动会报错:找不到磁盘,如下:
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 475M 0 475M 0% /dev
tmpfs 487M 0 487M 0% /dev/shm
tmpfs 487M 7.7M 479M 2% /run
tmpfs 487M 0 487M 0% /sys/fs/cgroup
/dev/mapper/centos-root 17G 7.4G 9.6G 44% /
/dev/sda1 1014M 137M 878M 14% /boot
tmpfs 98M 0 98M 0% /run/user/0
[root@localhost /]# mount /dev/sda1 /data/minio_data/
mount: /dev/sda1 is already mounted or /data/minio_data busy
/dev/sda1 is already mounted on /boot
/dev/sda1 is already mounted on /data/minio_data
[root@localhost /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /data/minio_data
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sr0 11:0 1 4.4G 0 rom
[root@localhost /]#
创建启动脚本目录
[root@localhost /]# mkdir /opt/minio/
三、编写集群启动脚本(所有节点配置文件相同)
脚本如下:
[root@localhost /]# vim /opt/minio/run.sh
#!/bin/bash
export MINIO_ACCESS_KEY=Xxyminio
export MINIO_SECRET_KEY=Test123456
/opt/minio/minio server \
http://192.168.129.133/data/minio_data/data1 http://192.168.129.135/data/minio_data/data1 \
http://192.168.129.136/data/minio_data/data1 http://192.168.129.137/data/minio_data/data1
其中,“MINIO_ACCESS_KEY”为用户名,“MINIO_SECRET_KEY”为密码,密码不能设置过于简单,不然minio会启动失败
创建好的/opt/minio/目录下的结构如下图:
[root@localhost minio]# vim /usr/lib/systemd/system/minio.service
[Unit]
Description=Minio service
Documentation=https://docs.minio.io/
[Service]
WorkingDirectory=/opt/minio/
ExecStart=/opt/minio/run.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
其中,“WorkingDirectory”为启动脚本目录,“ExecStart”为指定集群启动脚本
5.1、将下载好的minio文件赋予权限
[root@localhost minio]# chmod +x /opt/minio/minio
5.2、赋予启动文件权限
[root@localhost minio]# chmod +x /opt/minio/run.sh
5.3、依次启动每个服务器的minio
[root@localhost minio]# systemctl daemon-reload
[root@localhost minio]#
[root@localhost minio]# systemctl start minio
[root@localhost minio]#
[root@localhost minio]# systemctl status minio
● minio.service - Minio service
Loaded: loaded (/usr/lib/systemd/system/minio.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2020-04-22 10:32:54 CST; 44s ago
Docs: https://docs.minio.io/
Main PID: 1569 (run.sh)
CGroup: /system.slice/minio.service
├─1569 /bin/bash /opt/minio/run.sh
└─1570 /opt/minio/minio server http://192.168.129.133/data/minio_data/data1 http://192.168.129.135/data/minio_data/data1 http://192....
Apr 22 10:32:54 localhost.localdomain systemd[1]: Started Minio service.
Apr 22 10:33:17 localhost.localdomain run.sh[1569]: Waiting for a minimum of 2 disks to come online (elapsed 18s)
Apr 22 10:33:20 localhost.localdomain run.sh[1569]: Waiting for a minimum of 2 disks to come online (elapsed 21s)
Apr 22 10:33:23 localhost.localdomain run.sh[1569]: Waiting for a minimum of 2 disks to come online (elapsed 24s)
Apr 22 10:33:26 localhost.localdomain run.sh[1569]: Waiting for a minimum of 2 disks to come online (elapsed 27s)
Apr 22 10:33:29 localhost.localdomain run.sh[1569]: Waiting for a minimum of 2 disks to come online (elapsed 30s)
Apr 22 10:33:32 localhost.localdomain run.sh[1569]: Waiting for a minimum of 2 disks to come online (elapsed 33s)
Apr 22 10:33:35 localhost.localdomain run.sh[1569]: Waiting for a minimum of 2 disks to come online (elapsed 36s)
Apr 22 10:33:38 localhost.localdomain run.sh[1569]: Waiting for a minimum of 2 disks to come online (elapsed 39s)
[root@localhost minio]#
5.4、测试
浏览器输入集群任意节点地址+9000端口,即可访问minio,用户名密码为前面设置的“MINIO_ACCESS_KEY”和“MINIO_SECRET_KEY”,可创建“bucket”并上传文件测试