MinIO - 安装
单节点客户端搭建
Minio 的官方网站是 https://min.io ,
Minio 的官方文档是 https://docs.min.io/cn/ ,
GitHub 仓库地址是:https://github.com/minio/minio
中文文档:
http://docs.minio.org.cn/docs/
Minio 的 benchmark 说明:
https://min.io/resources/docs/MinIO-vs-HDFS-MapReduce-performance-comparison.pdf
https://min.io/resources/docs/MinIO-throughput-benchmarks-on-NVMe-SSD.pdf
https://min.io/resources/docs/Performance-comparison-Starburst-Presto-SQL.pdf
https://min.io/resources/docs/MinIO-throughput-benchmarks-on-HDD.pdf
https://min.io/resources/docs/Performance-comparison-Apache-Spark.pdf
下载MinIo
当前所在目录 /app
wget https://dl.minio.io/server/minio/release/linux-amd64/minio
chmod +x minio
mkdir -p /app/minio-release/data
mkdir -p /app/minio-release/conf
mkdir -p /app/minio-release/sbin
mkdir -p /app/minio-release/work
mkdir -p /app/minio-release/logs
mv minio /app/minio-release/sbin
minio server /app/minio-release/data //后面的是数据目录
将Minio设置成服务
以上步骤中,如果Ctrl+C退出之后,这个Minio服务也就同时停止了,所以如果需要它在后台进行服务,需要将它添加到后台服务中。(默认你在root权限=-=,不加sudo)
1、首先需要添加minio用户,以及建一个Minio文件夹
# adduser minio-user
# mkdir -p /app/minio-release/data
# chown minio-user:minio-user /app/minio-release/data
2、建立一个配置文件,并更新你的Key值
vim /app/minio-release/conf/minio.conf
MINIO_VOLUMES="/app/minio-release/data"
MINIO_OPTS="-C /app/minio-release/conf --address 0.0.0.0:9000"
MINIO_ACCESS_KEY="admin"
MINIO_SECRET_KEY="admin123"
## 新版本服务和控制台端口独立开了,后台服务默认9000,控制台页面需要自己设置,不设置就是一个随机的端口号,每次启动需要查看日志
MINIO_OPTS="-C /app/minio-release/conf --console-address '0.0.0.0:9999'
#集群配置
# MINIO_CLUSTER=http://192.168.1.5:9000/usr/local/minio/data http://192.168.1.6:9000/usr/local/minio/data http://192.168.1.7:9000/usr/local/minio/data http://192.168.1.8:9000/usr/local/minio/data
3、新建一个minio.service 在 /etc/systemd/system
执行:vim /etc/systemd/system/minio.service
ps: minio.service 文件必须放在 /etc/systemd/system 否则启动不了
将下面的配置复制到 minio.service
# 名称
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/app/minio-release/sbin/minio
[Service]
# User and group
# User=minio
# Group=minio
EnvironmentFile=/app/minio-release/conf/minio.conf
ExecStart=/app/minio-release/sbin/minio server $MINIO_OPTS $MINIO_VOLUMES
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
4、正式启用和查看状态
systemctl daemon-reload
systemctl enable minio.service
systemctl start minio
systemctl status minio.service
systemctl stop minio
直接启动方式
nohup ./minio server /app/minio-release/data/ > /app/minio-release/logs/minio.log 2>&1 &
查看日志 获取登陆用户名和密码
- shell 脚本
vim /app/minio-release/sbin/start.sh
nohup /app/minio-release/sbin/minio server /app/minio-release/data/ > /app/minio-release/logs/minio.log 2>& 1 &
vim /app/minio-release/sbin/stop.sh
#!/bin/bash
PID=$(ps -ef | grep minio | grep -v grep | awk '{ print $2 }')
if [ ${PID} ];
then
echo 'Application is stpping...'
echo kill $PID DONE
kill $PID
else
echo 'Application is already stopped...'
fi
此时我们的脚本还是不能用的,必须要给两个脚本相应的执行权限,我们通过下面的命令来给两个脚本权限:
chmod +x ./start.sh
chmod +x ./stop.sh
运行容器
docker run -p 9090:9000 --name minio \
-d --restart=always \
-e MINIO_ACCESS_KEY=minio \
-e MINIO_SECRET_KEY=minio@321 \
-v /data/docker/minio/data:/data \
-v /data/docker/minio/config:/root/.minio \
minio/minio server /data \
--console-address ":9000" --address ":9090"
容器编排(docker-compose)
version: '3.7'
services:
minio:
image: minio/minio:RELEASE.2021-07-30T00-02-00Z
container_name: minio
ports:
- "9000:9000"
- "9009:9009"
restart: always
command: server /data --console-address ":9009"
environment:
MINIO_ROOT_USER: minioa
MINIO_ROOT_PASSWORD: minio123
logging:
options:
max-size: "50M" # 最大文件上传限制
max-file: "10"
driver: json-file
volumes:
- ${MINIO_DATA_DIR}:/data # 映射文件路径
- /etc/localtime:/etc/localtime:ro
- /etc/timezone/timezone:/etc/timezone:ro
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
客户端mc
客户端部署
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
alias mc="./mc"
./mc config host add minio http://ip:9000 用户名 密码 --api S3v4
如果执行上述步骤没有报错信息,会有成功的信息显示:"Added `minio` successfully."
设置永久访问桶:
mc policy set public minio/桶名
这个桶名就是你要设置永久链接的桶名,
成功会有提示:"Access permission for `minio/syne` is set to `public`"