Centos7搭建minio
# 一、Minio介绍
MinIO 是一个开源的分布式对象存储服务。它允许用户构建高性能、可扩展的存储基础设施,用于存储和检索大量的数据,例如文本数据、图像、视频和其他多媒体文件,由于其开源性质和与 S3 API 的兼容性,MinIO 也成为许多开发人员和组织在构建云原生应用程序时的首选对象存储解决方案之一。比较类似于云存储,比如阿里的oss、腾讯的COS、AWS的s3存储。
# 二、部署
# 2.1 单机二进制部署
# 2.1.1 下载准备
下载地址: 点击直达 (opens new window)
# 下载 二进制文件
[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
1
2
3
4
5
6
7
2
3
4
5
6
7
# 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"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
配置文件参考:点击直达 (opens new window)
- 创建
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})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
参数说明
- 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
1
2
3
2
3
# 三、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
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
注意
location /minio/ui/
是console访问地址,这里如果想要使用同一个域名进行代理S3的9000和console的9001端口,则必须配置环境变量MINIO_BROWSER_REDIRECT_URL
的值,设置的值也必须是真实的访问地址,比如我这边: MINIO_BROWSER_REDIRECT_URL="http://minio.tbchip.com/minio/ui"
参考文档:官方配置文档 (opens new window)
# 3.3 访问
当进行以上配置后,我们通过web端访问就不用在指定端口,直接浏览器输入: http://minio.tbchip.com/minio/ui 即可。
编辑 (opens new window)
上次更新: 2024/01/25, 16:23:24