minio本地服务搭建

neevop 六月 20, 2023

前提条件

  • ubuntu 22.04

搭建步骤

  1. 下载并安装minio包,此处安装包选择的是Linux on an Intel or AMD 64-bit processor版本,如果在树莓派或者mac这类ARM 64-bit processor硬件上安装,需要更换不同的版本。安装包的版本持续更新,建议去官方网站下载最新版,此处为示例。
wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20230616024106.0.0_amd64.deb -O minio.deb
sudo dpkg -i minio.deb
  1. 在合适位置新建minio存储路径,例如/data/minio。打开/etc/default/minio文件修改其中配置。
MINIO_VOLUMES=/data/minio
MINIO_OPTS="--console-address :9090"
MINIO_ROOT_USER=xxx
MINIO_ROOT_PASSWORD=xxxxxxxx
CONSOLE_MAX_CONCURRENT_UPLOADS=2
MINIO_API_REQUESTS_DEADLINE=10m
  1. /etc/systemd/system路径下配置minio.service服务,新建该文件,并填写如下内容。
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio

[Service]
WorkingDirectory=/usr/local

User=neevop
Group=neevop
ProtectProc=invisible

EnvironmentFile=-/etc/default/minio
ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi"
ExecStart=/usr/local/bin/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=1048576

# Specifies the maximum number of threads this process can create
TasksMax=infinity

# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

# Built for ${project.name}-${project.version} (${project.name})

文件中UserGroup更换为服务器用户,或者新建专用的用户minio-user

groupadd -r minio-user

useradd -M -r -g minio-user minio-user

sudo chown minio-user:minio-user -R /data/minio
  1. 启动minio服务。
sudo systemctl enable minio.service

systemctl start minio.service

检查minio服务日志。

systemctl status minio.service  

# or
journalctl -e -u minio.service
  1. 登陆minio的网页服务台。浏览器打开如下页面。并使用/etc/default/minio文件中配置的MINIO_ROOT_USERMINIO_ROOT_PASSWORD登陆服务。
http://localhost:9001/

# or 
http://<server_host_ip>:9001/
  1. 安装minio命令行工具。
wget https://dl.min.io/client/mc/release/linux-amd64/mc

chmod +x mc

sudo mv mc /usr/local/bin/mc

配置命令行工具链接minio服务器,配置命令行中minioadmin替换为对应的用户名和密码。

mc alias set local http://127.0.0.1:9000 minioadmin minioadmin

# check
mc admin info local

参考文献

  1. minio官方文档
  2. systemd托管minio服务官方文档