MinIO安装与配置指南
MinIO 是一款开源的基于 Go 语言发开的高性能、分布式的对象存储系统。可以作为一个私有化的对象存储部署方案。
2.1. 单机部署
Section titled “2.1. 单机部署”- 安装
# 服务器wget https://dl.min.io/server/minio/release/linux-amd64/miniochmod +x miniosudo mv minio /usr/local/bin/# 客户端wget https://dl.min.io/client/mc/release/linux-amd64/mcchmod +x mcsudo mv mc /usr/local/bin/mc- 配置 systemd
[Unit]Description=MinIODocumentation=https://min.io/docs/minio/linux/index.htmlWants=network-online.targetAfter=network-online.targetAssertFileIsExecutable=/usr/local/bin/minio
[Service]WorkingDirectory=/usr/local
#User=minio-user#Group=minio-user#ProtectProc=invisible
EnvironmentFile=/etc/minio/envExecStartPre=/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 alwaysRestart=always
# Specifies the maximum file descriptor number that can be opened by this processLimitNOFILE=65536
# Specifies the maximum number of threads this process can createTasksMax=infinity
# Disable timeout logic and wait until process is stoppedTimeoutStopSec=infinitySendSIGKILL=no
[Install]WantedBy=multi-user.target
# Built for ${project.name}-${project.version} (${project.name})- 配置环境变量
# 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=adminMINIO_ROOT_PASSWORD=example
# MINIO_VOLUMES sets the storage volume or path to use for the MinIO server.
MINIO_VOLUMES="/data/minio"
# MINIO_OPTS sets any additional commandline options to pass to the MinIO server.# For example, `--console-address :9001` sets the MinIO Console listen portMINIO_OPTS="--console-address :9001"
MINIO_BROWSER_REDIRECT_URL="https://minio.example.com/minio/ui"- nginx 配置
server { listen 443 ssl; server_name minio.example.com; # 替换为您的服务器IP或域名
ssl_certificate /opt/software/gogs/custom/https/cert.crt; ssl_certificate_key /opt/software/gogs/custom/https/key.key;
location / { proxy_pass http://127.0.0.1:9000; # 后端服务地址 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;
real_ip_header X-Real-IP;
proxy_connect_timeout 300;
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
location /minio/ui/ { rewrite ^/minio/ui/(.*) /$1 break; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-NginX-Proxy true;
# This is necessary to pass the correct IP to be hashed real_ip_header X-Real-IP;
proxy_connect_timeout 300;
# To support websockets in MinIO versions released after January 2023 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # Some environments may encounter CORS errors (Kubernetes + Nginx Ingress) # Uncomment the following line to set the Origin request to an empty string # proxy_set_header Origin '';
chunked_transfer_encoding off;
proxy_pass http://127.0.0.1:9001; # This uses the upstream directive definition to load balance }}2.2. 集群部署
Section titled “2.2. 集群部署”- 安装
# 服务器wget https://dl.min.io/server/minio/release/linux-amd64/miniochmod +x miniosudo mv minio /usr/local/bin/# 客户端wget https://dl.min.io/client/mc/release/linux-amd64/mcchmod +x mcsudo mv mc /usr/local/bin/mc- 挂载 driver
apt install parted xfsprogs# 创建分区parted /dev/sdb --script mkpart primary xfs 0% 10GBparted /dev/sdb --script mkpart primary xfs 10G 100%# 格式化文件系统mkfs.xfs /dev/sdb1mkfs.xfs /dev/sdb2# 挂载文件mount -t xfs /dev/sdb1 /mnt/minio1mount -t xfs /dev/sdb2 /mnt/minio2# 初始化挂载 /etc/fstab/dev/sdb1 /mnt/minio1 xfs defaults 0 0/dev/sdb2 /mnt/minio2 xfs defaults 0 0- systemd 配置
参考单机部署部分。
- 环境配置
MINIO_ROOT_USER=adminMINIO_ROOT_PASSWORD=[密码已隐藏]
# MINIO_VOLUMES sets the storage volume or path to use for the MinIO server.
MINIO_VOLUMES="http://slave{1...3}:9000/mnt/minio{1...2}"
# MINIO_OPTS sets any additional commandline options to pass to the MinIO server.# For example, `--console-address :9001` sets the MinIO Console listen portMINIO_OPTS="--console-address :9001"
MINIO_BROWSER_REDIRECT_URL="https://minio.example.com/minio/ui"- nginx 配置
upstream minio_server { least_conn; server slave1:9000; server slave2:9000; server slave3:9000;}
upstream minio_console { ip_hash; server slave1:9001; server slave2:9001; server slave3:9001;}
server { listen 443 ssl; server_name minio.example.com; # 替换为您的服务器IP或域名
ssl_certificate /opt/software/gogs/custom/https/cert.crt; ssl_certificate_key /opt/software/gogs/custom/https/key.key;
location / { proxy_pass http://minio_server; # 后端服务地址 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;
real_ip_header X-Real-IP;
proxy_connect_timeout 300;
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
location /minio/ui/ { rewrite ^/minio/ui/(.*) /$1 break; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-NginX-Proxy true;
# This is necessary to pass the correct IP to be hashed real_ip_header X-Real-IP;
proxy_connect_timeout 300;
# To support websockets in MinIO versions released after January 2023 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # Some environments may encounter CORS errors (Kubernetes + Nginx Ingress) # Uncomment the following line to set the Origin request to an empty string # proxy_set_header Origin '';
chunked_transfer_encoding off;
proxy_pass http://minio_console; # This uses the upstream directive definition to load balance }}3.1. 管理
Section titled “3.1. 管理”- 服务端
minio server /data/minio --console-address :9001 # 启动服务- systemd
systemctl status miniosystemctl start miniosystemctl stop miniosystemctl restart minio- 客户端
curl http://127.0.0.1:9001 # 访问 web 页面mc alias set local http://127.0.0.1:9000 minioadmin minioadmin # 注册链接mc admin info local # 查看信息4. 拓展信息
Section titled “4. 拓展信息”…