一、单节点单磁盘方式部署

二进制文件安装

1.下载MinIO

wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
# 安装路径
# 例子:sudo mv minio /usr/local/bin/
sudo mv minio <MINIO_PATH>

2.创建systemd服务文件

vim /usr/lib/systemd/system/minio.service

添加配置内容

[Unit]
Description=MinIO
Documentation=https://min.io/docs/minio/linux/index.html
Wants=network-online.target
After=network-online.target
# 下载的minio文件位置
# 例子:AssertFileIsExecutable=/usr/local/bin/minio
AssertFileIsExecutable=<MINIO_PATH>

[Service]
WorkingDirectory=/usr/local

# Linux用户
# 例子:User=minio-user
User=<USER>
# Linux用户组
# 例子:Group=minio-user
Group=<USER_GROUP>
ProtectProc=invisible

# 设置环境变量文件
# 例子:EnvironmentFile=-/etc/default/minio
EnvironmentFile=<MINO_ENV_FILE>

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

# MinIO RELEASE.2023-05-04T21-44-30Z adds support for Type=notify (https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=)
# This may improve systemctl setups where other services use `After=minio.server`
# Uncomment the line to enable the functionality
# Type=notify

# Let systemd restart this service always
Restart=always

# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536

# 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})

注意事项:

如果没有配置文件中的用户[USER]或用户组[USER_GROUP]需要添加用户和用户组

# 添加用户组
groupadd -r <USER_GROUP>
# 添加用户并指定用户组
useradd -M -r -g <USER_GROUP> <USER>

3.创建环境变量文件

# MINIO_ROOT_USER and MINIO_ROOT_PASSWORD sets the root account for the MinIO server.
# This user has unrestricted permissions to perform S3 and administrative API operations on any resource in the deployment.
# Omit to use the default values 'minioadmin:minioadmin'.
# MinIO recommends setting non-default values as a best practice, regardless of environment

# MinIO管理端超级用户
# 注:用户名 至少3位
# 例子:MINIO_ROOT_USER="admin"
MINIO_ROOT_USER=<USERNAME>
# 注:密码 至少8位
# MINIO_ROOT_PASSWORD="12345678"
MINIO_ROOT_PASSWORD=<PASSWORD>

# MINIO_VOLUMES sets the storage volume or path to use for the MinIO server.
# MinIO使用的磁盘或文件目录的路径
# 例子:MINIO_VOLUMES="/mnt/data"
MINIO_VOLUMES=<DATA_PATH>

# MINIO_SERVER_URL sets the hostname of the local machine for use with the MinIO Server
# MinIO assumes your network control plane can correctly resolve this hostname to the local machine

# Uncomment the following line and replace the value with the correct hostname for the local machine and port for the MinIO server (9000 by default).

#MINIO_SERVER_URL="http://minio.example.net:9000"

# 启动参数 配置MinIO服务访问端口和管理端访问端口
# 例子:MINIO_OPTS="--addresss :9000 --console-address :9090"
MINIO_OPTS="--address :<SERVICE_PORT> --console-address :<CONSOLE_PORT>"

注意事项:

如果步骤2中配置的用户没有MinIO存储路径[DATA_PATH]的使用权限,需要给用户添加权限

# 添加权限
# chown minio-user:minio-user /mnt/data
chown <USER:USER_GROUP> <DATA_PATH>

4.启动服务

sudo systemctl start minio.service

查看服务状态

sudo systemctl status minio.service
journalctl -f -u minio.service

5.访问管理界面

浏览器访问管理界面 http://127.0.0.1:[CONSOLE_PORT],并输入用户名和密码

2024-04-08T23_11_25-kraazzuv.png

Docker安装

1.拉取最新的MinIO镜像

docker pull minio/minio

2.创建环境变量文件

创建minio环境变量文件,如:/etc/default/minio,并写入如下内容:

# MINIO_ROOT_USER and MINIO_ROOT_PASSWORD sets the root account for the MinIO server.
# This user has unrestricted permissions to perform S3 and administrative API operations on any resource in the deployment.
# Omit to use the default values 'minioadmin:minioadmin'.
# MinIO recommends setting non-default values as a best practice, regardless of environment

# MinIO管理端超级用户
# 注:用户名 至少3位
# 例子:MINIO_ROOT_USER="admin"
MINIO_ROOT_USER=<USERNAME>

# 注:密码 至少8位
# MINIO_ROOT_PASSWORD="12345678"
MINIO_ROOT_PASSWORD=<PASSWORD>

# MINIO_VOLUMES sets the storage volume or path to use for the MinIO server.
# docker容器里存储路径可以不用改,可以映射到本地制定存储路径
MINIO_VOLUMES="/mnt/data"

# MINIO_OPTS sets any additional commandline options to pass to the MinIO server.
# For example, `--console-address :9001` sets the MinIO Console listen port
# 启动参数 配置MinIO服务访问端口和管理端访问端口,指定后启动容器时也要修改成对应端口
# 例子:MINIO_OPTS="--addresss :9000 --console-address :9001"
MINIO_OPTS="--console-address :9001"

# MINIO_SERVER_URL sets the hostname of the local machine for use with the MinIO Server
# MinIO assumes your network control plane can correctly resolve this hostname to the local machine

# Uncomment the following line and replace the value with the correct hostname for the local machine and port for the MinIO server (9000 by default).

#MINIO_SERVER_URL="http://minio.example.net:9000"

3.创建并运行容器

docker run -dt                                  \
  -p 9000:9000 -p 9001:9001                     \
  -v <PATH>:/mnt/data                             \
  -v <CONFIG_FILE>:/etc/config.env         \
  -e "MINIO_CONFIG_ENV_FILE=/etc/config.env"    \
  --name "minio_local"                          \
  minio server --console-address ":9001"
  • <PATH>可以指定MinIO容器映射到本地存储路径
  • <CONFIG_FILE>上面创建的环境变量的配置文件路径

4.访问管理界面

浏览器访问管理界面 http://127.0.0.1:9001,并输入用户名和密码

2024-04-08T23_11_25-kraazzuv.png