- 环境准备
- 每台节点上不同目录挂在不同磁盘
- 除一台做nginx代理外剩余3台操作一样
节点 | 目录 |
192.168.80.153 | /data/minio/{data1,data2,run,conf} |
192.168.80.154 | /data/minio/{data1,data2,run,conf} |
192.168.80.155 | /data/minio/{data1,data2,run,conf} |
192.168.80.156 | 部署nginx转发集群 |
- 每台节点创建磁盘并挂载
注:正式环境可将磁盘做成卷组
mount /dev/sdb1 /data/minio/data1/
mount /dev/sdc1 /data/minio/data2/
---------------------------------------------------------------------------------------
[root@bogon ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 898M 0 898M 0% /dev
tmpfs tmpfs 910M 0 910M 0% /dev/shm
tmpfs tmpfs 910M 9.6M 901M 2% /run
tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 17G 1.5G 16G 9% /
/dev/sda1 xfs 1014M 153M 862M 16% /boot
tmpfs tmpfs 182M 0 182M 0% /run/user/0
/dev/sdb1 ext4 20G 45M 19G 1% /data/minio/data1
/dev/sdc1 ext4 20G 45M 19G 1% /data/minio/data2
##开机自动挂载
cat >> /etc/fstab << EOF
/dev/sdb1 /data/minio/data1/ ext4 defaults 0 0
/dev/sdc1 /data/minio/data2/ ext4 defaults 0 0
EOF
##重载配置
mount -a
##查看磁盘UUID
ls -l /dev/disk/by-uuid/
- 安装包下载
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
- 创建对应目录
data:数据存储目录
run:启动脚本及二进制文件
conf:配置文件
mkdir -p /data/minio/{data1,data2,run,conf}
#将二进制文件移动到run下
mv minio /data/minio/run/
- 集群启动文件
-
MINIO_ACCESS_KEY:用户名,长度最小是5个字符;
-
MINIO_SECRET_KEY:密码,密码不能设置过于简单,不然minio会启动失败,长度最小是8个字符;
-
–config-dir:指定集群配置文件目录;
-
--console-address: 指定web端口(新版本需要指定,老版本应该是9000
-
######这里使用3台机器6块磁盘######
[root@bogon run]# cat /data/minio/run/run.sh
#!/bin/bash
export MINIO_ROOT_USER=minio
export MINIO_ROOT_PASSWORD=minio2023
/data/minio/run/minio server --console-address ":50000" --config-dir /data/minio/conf \
http://192.168.80.153/data/minio/data1 http://192.168.80.153/data/minio/data2 \
http://192.168.80.154/data/minio/data1 http://192.168.80.154/data/minio/data2 \
http://192.168.80.155/data/minio/data1 http://192.168.80.155/data/minio/data2 \
[root@bogon run]# chmod +x run.sh
######测试可使用多节点单磁盘######
[root@bogon run]# cat /data/minio/run/run.sh
#!/bin/bash
export MINIO_ROOT_USER=minio
export MINIO_ROOT_PASSWORD=minio2023
/data/minio/run/minio server --console-address ":50000" --config-dir /data/minio/conf \
http://192.168.80.153/data/minio/data
http://192.168.80.154/data/minio/data
http://192.168.80.155/data/minio/data
[root@bogon run]# chmod +x run.sh
- 配置为系统服务
[root@bogon ~]# cat /usr/lib/systemd/system/minio.service
[Unit]
Description=Minio service
Documentation=https://docs.minio.io/
[Service]
WorkingDirectory=/data/minio/run/
ExecStart=/data/minio/run/run.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
- 启动集群
systemctl daemon-reload && systemctl enable minio && systemctl start minio
- 集群状态查看
- status:6节点存活,0节点离线
[root@bogon ~]# systemctl status minio
● minio.service - Minio service
Loaded: loaded (/usr/lib/systemd/system/minio.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2023-02-01 14:29:18 CST; 2h 9min ago
Docs: https://docs.minio.io/
Main PID: 12172 (run.sh)
CGroup: /system.slice/minio.service
├─12172 /bin/bash /data/minio/run/run.sh
└─12173 /data/minio/run/minio server --console-address :50000 --config-dir /data/minio/conf http://192.168.80.153/data/minio/data...
Feb 01 14:29:18 bogon run.sh[12172]: Automatically configured API requests per node based on available memory on the system: 20
Feb 01 14:29:18 bogon run.sh[12172]: All MinIO sub-systems initialized successfully in 102.728042ms
Feb 01 14:29:18 bogon run.sh[12172]: MinIO Object Storage Server
Feb 01 14:29:18 bogon run.sh[12172]: Copyright: 2015-2023 MinIO, Inc.
Feb 01 14:29:18 bogon run.sh[12172]: License: GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
Feb 01 14:29:18 bogon run.sh[12172]: Version: RELEASE.2023-01-31T02-24-19Z (go1.19.4 linux/amd64)
Feb 01 14:29:18 bogon run.sh[12172]: Status: 6 Online, 0 Offline.
Feb 01 14:29:18 bogon run.sh[12172]: API: http://192.168.80.153:9000 http://127.0.0.1:9000
Feb 01 14:29:18 bogon run.sh[12172]: Console: http://192.168.80.153:50000 http://127.0.0.1:50000
Feb 01 14:29:18 bogon run.sh[12172]: Documentation: https://min.io/docs/minio/linux/index.html
[root@bogon ~]#
- 集群访问
- 当前是集群模式,所以访问任意节点都是一样的。这里使用nginx代理集群
- 需要添加websocket支持,否则无法访问桶
upstream minio_service{
server 192.168.80.153:50000 weight=1;
server 192.168.80.154:50000 weight=1;
server 192.168.80.155:50000 weight=1;
}
server {
listen 9001;
server_name localhost;
location / {
client_max_body_size 1000m;
proxy_pass http://minio_service;
# 添加了websocket支持
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
-
输入ip及监听端口
http://192.168.80.156:9001
-
可以看到每个节点都有上传过后的数据