目录
什么是MinIO
MinIO是一个对象存储解决方案,它提供了与Amazon Web Services S3兼容的API,并支持所有核心S3功能。 MinIO有能力在任何地方部署 - 公有云或私有云,裸金属基础设施,编排环境,以及边缘基础设施。在这个网站的文档上记录和说明了在Linux平台上进行MinIO部署的操作、管理和开发,适用于最新的稳定版MinIO:RELEASE.2024-04-18T19-09-19Z。
单节点单硬盘部署MinIO
Linux环境
下载MinIO二进制文件
wget https://dl.minio.org.cn/server/minio/release/linux-amd64/minio
chmod +x minio
sudo mv minio /usr/local/bin/
启动MinIO服务
mkdir ~/minio
minio server ~/minio --console-address :9090
- mkdir 命令 在指定路径创建文件夹。
- minio server 命令启动MinIO服务器. 这个路径参数 ~/minio 确定服务器操作的文件夹。
- minio server 进程将其输出打印到系统控制台,类似于以下内容:
API: http://192.168.207.131:9000 http://127.0.0.1:9000
RootUser: minioadmin
RootPass: minioadmin
Console: http://192.168.207.131:9090 http://127.0.0.1:9090
RootUser: minioadmin
RootPass: minioadmin
Command-line: https://minio.org.cn/docs/minio/linux/reference/minio-mc.html
$ mc alias set myminio http://192.168.207.131:9000 minioadmin minioadmin
Documentation: https://minio.org.cn/docs/minio/linux/index.html
WARNING: Detected default credentials 'minioadmin:minioadmin', we recommend that you change these values with 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment variables.
Docker环境
mkdir -p ${HOME}/minio/data
docker run \
-p 9000:9000 \
-p 9001:9001 \
--user $(id -u):$(id -g) \
--name minio1 \
-e "MINIO_ROOT_USER=ROOTUSER" \
-e "MINIO_ROOT_PASSWORD=CHANGEME123" \
-v ${HOME}/minio/data:/data \
quay.io/minio/minio server /data --console-address ":9001"
- mkdir 创建一个新的本地目录 ~/minio/data 映射给容器内部的 /data 使用。
- docker run 启动运行容器。
- -p 为容器绑定一个本地的端口.
- -name 为容器创建一个本地的名字。
- -v 将文件路径设置为容器使用的持久卷位置。 当MinIO将数据写入 /data 时,该数据会镜像到本地路径 ~/minio/data, 使其能够在容器重新启动时保持持久化。 您可以设置任何具有读取、写入和删除权限的文件路径来使用。
- -e 分别为用户名和密码设置环境变量 MINIO_ROOT_USER 和 MINIO_ROOT_PASSWORD. 这些说明了如下设置: 如何修改默认管理员的用户名和密码. 将示例值更改为您要用于容器的值。
单节点多硬盘部署MinIO
Linux环境
下载MinIO二进制文件
wget https://dl.minio.org.cn/server/minio/release/linux-amd64/minio
chmod +x minio
sudo mv minio /usr/local/bin/
启动MinIO服务
mkdir /data{1..4}
# 准备4块硬盘分别挂载到/data1 /data2 /data3 /data4
# 格式化成xfs类型
[root@bogon ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 13M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 54G 1.7G 52G 4% /
/dev/sda1 xfs 1.1G 160M 904M 16% /boot
/dev/mapper/centos-home xfs 49G 34M 49G 1% /home
tmpfs tmpfs 396M 0 396M 0% /run/user/0
/dev/sde1 xfs 22G 34M 22G 1% /data4
/dev/sdc1 xfs 22G 34M 22G 1% /data2
/dev/sdb1 xfs 22G 34M 22G 1% /data1
/dev/sdd1 xfs 22G 34M 22G 1% /data3
minio server /data1 /data2 /data3 /data4 --console-address :9090
[root@bogon ~]# minio server /data1 /data2 /data3 /data4 --console-address :9090
Formatting 1st pool, 1 set(s), 4 drives per set.
WARNING: Host local has more than 2 drives of set. A host failure will result in data becoming unavailable.
MinIO Object Storage Server
Copyright: 2015-2024 MinIO, Inc.
License: GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
Version: RELEASE.2024-05-01T01-11-10Z (go1.21.9 linux/amd64)
API: http://192.168.207.131:9000 http://127.0.0.1:9000
RootUser: minioadmin
RootPass: minioadmin
WebUI: http://192.168.207.131:9090 http://127.0.0.1:9090
RootUser: minioadmin
RootPass: minioadmin
CLI: https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart
$ mc alias set 'myminio' 'http://192.168.207.131:9000' 'minioadmin' 'minioadmin'
Docs: https://min.io/docs/minio/linux/index.html
Status: 4 Online, 0 Offline.
STARTUP WARNINGS:
- Detected Linux kernel version older than 4.0.0 release, there are some known potential performance problems with this kernel version. MinIO recommends a minimum of 4.x.x linux kernel version for best performance
- Detected default credentials 'minioadmin:minioadmin', we recommend that you change these values with 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment variables
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ You are running an older version of MinIO released 1 week before the latest release ┃
┃ Update: Run `mc admin update ALIAS` ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Docker环境
# 在宿主机上创建四个目录
mkdir /data-{1..4}
# 编写minio配置文件
[root@bogon ~]# cat /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_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
# MINIO_VOLUMES sets the storage volumes or paths to use for the MinIO server.
# The specified path uses MinIO expansion notation to denote a sequential series of drives between 1 and 4, inclusive.
# All drives or paths included in the expanded drive list must exist *and* be empty or freshly formatted for MinIO to start successfully.
MINIO_VOLUMES="/data-{1...4}"
# MINIO_OPTS sets any additional commandline options to pass to the MinIO server.
# 例如, `--console-address :9001` sets the MinIO Console listen port
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.
#MINIO_SERVER_URL="http://minio.example.net"
# 运行容器
docker run -dt \
-p 9000:9000 -p 9001:9001 \
-v /data-1:/data-1 \
-v /data-2:/data-2 \
-v /data-3:/data-3 \
-v /data-4:/data-4 \
-v /etc/default/minio:/etc/config.env \
-e "MINIO_CONFIG_ENV_FILE=/etc/config.env" \
--name "minio_local" \
quay.io/minio/minio server --console-address ":9001"
[root@bogon ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3399d0e44d25 quay.io/minio/minio "/usr/bin/docker-ent…" 4 minutes ago Up 4 minutes 0.0.0.0:9000-9001->9000-9001/tcp, :::9000-9001->9000-9001/tcp minio_local
分布式部署MinIO(多节点多硬盘)
Linux环境
下载MinIO二进制文件
wget https://dl.minio.org.cn/server/minio/release/linux-amd64/minio
chmod +x minio
sudo mv minio /usr/local/bin/
启动MinIO服务
mkdir /data{1..4}
# 准备4块硬盘分别挂载到/data1 /data2 /data3 /data4
# 格式化成xfs类型
# 每台机器都要4块硬盘,一共4台机器
[root@bogon ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 13M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 54G 1.7G 52G 4% /
/dev/sda1 xfs 1.1G 160M 904M 16% /boot
/dev/mapper/centos-home xfs 49G 34M 49G 1% /home
tmpfs tmpfs 396M 0 396M 0% /run/user/0
/dev/sde1 xfs 22G 34M 22G 1% /data4
/dev/sdc1 xfs 22G 34M 22G 1% /data2
/dev/sdb1 xfs 22G 34M 22G 1% /data1
/dev/sdd1 xfs 22G 34M 22G 1% /data3
# 执行启动命令
# 4台机器都要执行
/usr/local/bin/minio server http://192.168.207.131:9000/data1 http://192.168.207.131/data2 \
http://192.168.207.131/data3 http://192.168.207.131/data4 \
http://192.168.207.165:9000/data1 http://192.168.207.165/data2 \
http://192.168.207.165/data3 http://192.168.207.165/data4 \
http://192.168.207.166:9000/data1 http://192.168.207.166/data2 \
http://192.168.207.166/data3 http://192.168.207.166/data4 \
http://192.168.207.167:9000/data1 http://192.168.207.167/data2 \
http://192.168.207.167/data3 http://192.168.207.167/data4 \
--console-address :9001
将MinIO添加为系统服务
MinIO可以命令行启动也可以添加为系统服务
编写服务文件
cat > /usr/lib/systemd/system/minio.service << 'EOF'
[Unit]
Description=MinIO
Documentation=https://minio.org.cn/docs/minio/linux/index.html
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
WorkingDirectory=/usr/local
User=minio-user
Group=minio-user
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
# 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})
EOF
创建用户
# 创建用户
groupadd -r minio-user
useradd -M -r -g minio-user minio-user
# 把minio会使用到的目录都修改一下归属用户
chown minio-user:minio-user /mnt/disk1 /mnt/disk2 /mnt/disk3 /mnt/disk4
编写环境变量文件
cat > /etc/default/minio << 'EOF'
# 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_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
# MINIO_VOLUMES sets the storage volume or path to use for the MinIO server.
MINIO_VOLUMES="/data1 /data2 /data3 /data4"
# MINIO_OPTS sets any additional commandline options to pass to the MinIO server.
# 例如, `--console-address :9001` sets the MinIO Console listen port
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"
EOF
启动服务
systemctl daemon-reload
systemctl start minio.service
systemctl enable minio.service