MinIO自建对象存储
分类:
入门到放弃
日期: 2024-01-18 | 作者: 七七
| 浏览:
102
之前使用django-ckeditor,可以直接上传图片,改用Tinymce后,只支持图片链接,无自带图片上传功能,但又懒得自行实现,就想着用图床实现。
看了下七牛云、腾讯云、阿里云啥的,多多少少要付出点RMB,既然已经有一个服务器了,为啥不自己搭建套呢,反正就个人用用,也不用考虑太多其他啥的。
遂开始对比minio、SeaweedFS、Ceph、Garage等等,看了文档后,还是minio最称心,开始上手记录下。
1. 下载安装(基于Ddebian系统)
# minio有各Linux系统的安装包
# 可以在 https://dl.min.io/server/minio/release/linux-amd64/archive/ 地址下,自行寻找对应系统最新的安装包
wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20240101163633.0.0_amd64.deb
2. 安装
# 直接安装
dpkg -i minio_20240101163633.0.0_amd64.deb
3. 配置系统启动文件
# 安装完成后,自动会生成相应服务配置文件
# /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
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
WorkingDirectory=/usr/local
# 懒人,不加用户的话,直接注释掉用户及ProtectProc
# User=minio-user
# Group=minio-user
# ProtectProc=invisible
EnvironmentFile=-/etc/default/minio
……
4. 添加自启动服务
# 添加minio为自启动服务
systemctl enable minio.server
# 查看minio运行状态
systemctl status minio.server
5. 配置系统变量
# 创建 /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=admin
MINIO_ROOT_PASSWORD=********
# MINIO_VOLUMES sets the storage volume or path to use for the MinIO server.
# 对象存储路径
MINIO_VOLUMES="/var/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
# 控制台默认端口为9001,api地址默认为9000,按需更改,注意防火墙相应端口号的限制解除
MINIO_OPTS="--console-address :9001 --addresss :9000"
# 默认跳转到控制台域名(按需,如无域名,可以直接通过IP+端口号访问)
MINIO_BROWSER_REDIRECT_URL="https://控制台域名"
# API域名(按需,如无域名,可以直接通过IP+端口号访问)
MINIO_SERVER_URL = "https://API域名"
6. nginx参考配置
# /etc/nginx/site-avalables/xxxx.conf
……
# Minio控制面板
server {
listen 443 ssl;
server_name 控制台域名;
ssl_certificate /etc/nginx/cert/SSL证书.pem;
ssl_certificate_key /etc/nginx/cert/SSL证书.key;
location / {
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;
proxy_pass http://127.0.0.1:9001;
proxy_redirect off;
}
# WebSocket支持
location /ws {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
proxy_pass http://127.0.0.1:9001;
}
}
# Minio API端口
server {
listen 443 ssl;
server_name API域名;
ssl_certificate /etc/nginx/cert/SSL证书.pem;
ssl_certificate_key /etc/nginx/cert/SSL证书.key;
location / {
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_pass http://127.0.0.1:9001;
proxy_redirect off;
}
}