MinIO搭建

单节点搭建
Minio 的官方网站是 https://min.io
Minio 的官方文档是 https://docs.min.io/cn/
GitHub 仓库地址是:https://github.com/minio/minio ,目前有 18.8k Stars (2019.11.9)

中文文档:
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/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"

# 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]
# 名称
[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

5、直接启动方式
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

服务端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`"
 
posted @ 2021-03-20 18:21  栋_RevoL  阅读(160)  评论(0编辑  收藏  举报