MinIO【部署 02】Linux集群版本及Windows单机版、单机多目录版、分布式版(cmd启动脚本及winsw脚本分享)
Linux集群版及Windows单机版分布式版
- 1.Linux集群版
- 1.1 安装启动停止
- 1.2 将MinIO添加到服务
- 2.Windows
- 2.1 官网安装
- 2.2 本地测试
- 2.2.1 cmd启动脚本
- 2.2.2 winsw脚本
- 3.总结
1.Linux集群版
官网下载地址 https://min.io/download#/linux;
官网安装文档 https://min.io/docs/minio/linux/index.html。
1.1 安装启动停止
每个节点的安装可参考Linux单机版,集群版的启动脚本:
#!/bin/bash
export MINIO_ROOT_USER=minioadmin
export MINIO_ROOT_PASSWORD=minioadmin
/usr/local/bin/minio server --config-dir /home/minio/data \
--address "0.0.0.0:9029" --console-address ":9000" \
http://xxx.xxx.xx.xxx:9029/home/minio/data \
http://xxx.xxx.xx.xxx:9029/home/minio/data \
http://xxx.xxx.xx.xxx:9029/home/minio/data > /home/minio/data/minio.log
集群版的停止脚本:
#!/bin/bash
ps -ef | grep minio | grep -v 'grep' | awk '{print $2}'| xargs kill -9
if [ $? -ne 0 ];then
echo "MinIO service stop failed."
exit 1
fi
1.2 将MinIO添加到服务
创建minio.service
vim /etc/systemd/system/minio.service
添加内容:
[Unit]
Description=Minio service
Documentation=https://docs.minio.io/
[Service]
WorkingDirectory=/opt/minio/run/
ExecStart=/opt/minio/run/run.sh
ExecStop=/opt/minio/run/stop.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
修改权限:
chmod +x /etc/systemd/system/minio.service && chmod +x /opt/minio/run/minio && chmod +x /opt/minio/run/run.sh && chmod +x /opt/minio/run/stop.sh
使用systemctl
启动集群:
# 是配置文件 minio.service 生效
systemctl daemon-reload
# 启动服务
systemctl start minio
# 设置开机启动
systemctl enable minio
# 查看集群状态
systemctl status minio.service
# 端口号
ufw allow 9029
# 重置
systemctl restart ufw
2.Windows
2.1 官网安装
PS> Invoke-WebRequest -Uri "https://dl.min.io/server/minio/release/windows-amd64/minio.exe" -OutFile "C:\minio.exe"
PS> setx MINIO_ROOT_USER admin
PS> setx MINIO_ROOT_PASSWORD admin123
PS> C:\minio.exe server F:\Data --console-address ":9001"
2.2 本地测试
2.2.1 cmd启动脚本
- 单机版的启动:
@echo off
rem setx MINIO_ROOT_USER admin
rem setx MINIO_ROOT_PASSWORD admin123
minio.exe server D:\minio_data --console-address ":9001"
exit
- 单机多目录的举例:
@echo off
rem setx MINIO_ROOT_USER admin
rem setx MINIO_ROOT_PASSWORD admin123
minio.exe server C:\minio_data E:\minio_data --console-address ":9001"
exit
- 分布式的启动:
@echo off
rem setx MINIO_ROOT_USER admin
rem setx MINIO_ROOT_PASSWORD admin123
minio.exe server --config-dir E:\minio_data http://tcloud:9000/data/minio/data --console-address ":9001"
exit
2.2.2 winsw脚本
<service>
<id>minio-server</id>
<name>MinIO-Server</name>
<description>This service runs MINIO OBJECT STORE.</description>
<env name="MINIO_HOME" value="%BASE%"/>
<executable>%BASE%\minio.exe</executable>
<arguments>server D:\minio_data --console-address ":9001"</arguments>
<logpath>%BASE%\logs</logpath>
<log mode="roll-by-size-time">
<sizeThreshold>1024</sizeThreshold>
<pattern>yyyyMMdd</pattern>
<autoRollAtTime>00:00:00</autoRollAtTime>
<zipOlderThanNumDays>5</zipOlderThanNumDays>
<zipDateFormat>yyyyMMdd</zipDateFormat>
</log>
<env name="MINIO_ROOT_USER" value="admin" />
<env name="MINIO_ROOT_PASSWORD" value="admin123" />
</service>
3.总结
- MinIO的安装部署还是比较简单的;
- 部署方式比较多样。