一、下载安装文件
wget http://dl.minio.org.cn/server/minio/release/linux-amd64/minio
二、创建数据文件夹
mkdir /opt/minio/data
三、启动
# 赋予权限
chmod 777 minio
# 启动命令
./minio server /opt/minio/data
# 后台启动
nohup ./minio server /opt/minio/data >/dev/null &
如发下以下问题是发生端口占用:
请更换端口或杀死占用端口的进程。
启动成功如下所示:
访问console直接ip:9000就可以了,会直接跳转到控制台。
四、设置永久访问链接
很多情况下,我们的图片是需要浏览器直接访问的,这里通过minio的客户端进行设置。
下载客户端:
wget https://dl.minio.io/client/mc/release/linux-amd64/mc
赋予权限
chmod 777 mc
添加server
./mc config host add minio http://172.16.3.28:9000/ minioadmin minioadmin
设置需要开放下载的bucket, 注意需要带minio
./mc policy set download minio/graph-editor
访问图片:
http://172.16.3.28:9000/graph-editor/img/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20210820174907.jpg
五、修改用户名密码:
export MINIO_ROOT_USER=admin
export MINIO_ROOT_PASSWORD=12345678
注意,minio的密码要求达到8个字符,否则会启动失败,如下所示:
[root@public-server9 minio]# ./minio server /opt/minio/data1
ERROR Unable to validate credentials inherited from the shell environment: Invalid credentials
> Please provide correct credentials
HINT:
Access key length should be at least 3, and secret key length at least 8 characters
六、集群部署
需要在每台节点执行以下的命令,如下所示,共三个节点,每个节点三个目录
nohup ./minio server --console-address ":10001" http://172.16.3.28/opt/minio/data1 http://172.16.3.28/opt/minio/data2 http://172.16.3.28/opt/minio/data3 \
http://172.16.3.29/opt/minio/data1 http://172.16.3.29/opt/minio/data2 http://172.16.3.29/opt/minio/data3 \
http://172.16.3.30/opt/minio/data1 http://172.16.3.30/opt/minio/data2 http://172.16.3.30/opt/minio/data3 \
>/dev/null &
设置永久访问权限和前面一样,不同是在一台节点设置,访问其他节点,会自动跳到被设置的访问节点。
添加nginx负载:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
upstream minio {
server 172.16.3.28:9000 fail_timeout=10s max_fails=2 weight=1;
server 172.16.3.29:9000 fail_timeout=10s max_fails=2 weight=1;
server 172.16.3.30:9000 fail_timeout=10s max_fails=2 weight=1;
}
upstream minio-console {
server 172.16.3.28:10001 fail_timeout=10s max_fails=2 weight=1;
server 172.16.3.29:10001 fail_timeout=10s max_fails=2 weight=1;
server 172.16.3.30:10001 fail_timeout=10s max_fails=2 weight=1;
}
server {
listen 10000;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://minio;
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 $remote_addr;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 11000;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://minio-console;
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 $remote_addr;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}