一、Minio介绍
MinIO 是一个开源的分布式对象存储服务。它允许用户构建高性能、可扩展的存储基础设施,用于存储和检索大量的数据,例如文本数据、图像、视频和其他多媒体文件,由于其开源性质和与 S3 API 的兼容性,MinIO 也成为许多开发人员和组织在构建云原生应用程序时的首选对象存储解决方案之一。比较类似于云存储,比如阿里的oss、腾讯的COS、AWS的s3存储。
#二、部署
#2.1 单机二进制部署
#2.1.1 下载准备
下载地址: linux-amd64/" target="_blank" rel="noopener noreferrer" style="outline: none; -webkit-tap-highlight-color: rgba(255, 255, 255, 0); text-decoration-line: none; color: rgb(17, 168, 205);">点击直达
# 下载 二进制文件
[root@minio-server ~]# wget https://dl.min.io/server/minio/release/linux-amd64/minio
# 移动至系统可加载路径
[root@minio-server ~]# chmod +x minio
[root@minio-server ~]# mv minio /usr/local/bin/
# 创建数据目录
[root@minio-server ~]# mkdir /opt/minio/data -p
2.1.2 配置文件
将
Minio
设置成服务 配置Systemd
服务启动
创建minio变量文件:
/etc/default/minio
[root@minio-server ~]# vim /etc/default/minio
# S3 API端口和MinIO Console 地址端口
MINIO_OPTS="--address :9002 --console-address :9001"
# 访问用户名密码
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
# 存储路径
MINIO_VOLUMES="/opt/minio/data"
# S3-API 地址 一般用于程序连接 默认即可
# MINIO_SERVER_URL=""
# MinIO Console 访问地址 如果想通过nginx 使用同一个域名同时代理9000和90001端口
# 则需要配置该变量,然后在nginx中的location块指定 /minio/ui 即可
MINIO_BROWSER_REDIRECT_URL="http://minio.tbchip.com/minio/ui"
配置文件参考:点击直达
变量参考:点击直达
创建
Service File
:/etc/systemd/system/minio.service
[root@minio-server ~]# vim /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=/opt/minio/data
User=root
Group=root
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=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、Group: 这里如果想要使用非root用户,则需要新建对应的用户,并且授权数据目录有用户访问权限即可
EnvironmentFile:指定加载的变量文件
address: S3 API端口,一般用来与程序进行对接
console-address: web端访问端口
#2.1.3 设置开启自启动
[root@minio-server ~]# systemctl daemon-reload
[root@minio-server ~]# systemctl enable minio.service
[root@minio-server ~]# systemctl start minio.service
三、Nginx反向代理
#3.1 说明
这里我们准备一个域名: http://minio.tbchip.com,s3 与 console 端口我们都使用同一个域名进行代理
#3.2 nginx配置
/etc/nginx/conf.d/minio.conf
server {
listen 80;
listen [::]:80;
server_name minio.tbchip.com;
# Allow special characters in headers
ignore_invalid_headers off;
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0;
# Disable buffering
proxy_buffering off;
proxy_request_buffering off;
# s3 api 地址
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_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://172.100.1.94:9000; # This uses the upstream directive definition to load balance
}
# web 访问地址
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://172.100.1.94:9001; # This uses the upstream directive definition to load balance
}
}
注意
location /minio/ui/
是console访问地址,这里如果想要使用同一个域名进行代理S3的9000和console的9001端口,则必须配置环境变量MINIO_BROWSER_REDIRECT_URL
的值,设置的值也必须是真实的访问地址,比如我这边: MINIO_BROWSER_REDIRECT_URL="http://minio.tbchip.com/minio/ui"
参考文档:官方配置文档
#3.3 访问
当进行以上配置后,我们通过web端访问就不用在指定端口,直接浏览器输入: http://minio.tbchip.com/minio/ui 即可。
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://www.hqyman.cn/post/7843.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
休息一下~~