系统配置MinIO对象存储集群 系统默认使用本地存储,含有第三方文件存储功能的版本可以配置接入使用MinIO对象存储,下面演示MinIO集群的配置方法,演示主机操作系统为CentOS 8.2,对象存储MinIO版本为2020-08-08T04:50:06Z。本次演示使用4台服务器。
实现规划
主机名称
IP地址
安装软件
开放端口
绑定域名
V1
***.100.100.152(公网) 172.26.188.173(内网)
MinIO Nginx
80 (公网开放) 9000 (内网开放)
img1.diyhi.com
V2
***.100.241.36(公网) 172.26.188.174(内网)
MinIO Nginx
80 (公网开放) 9000 (内网开放)
img2.diyhi.com
V3
***.100.159.63(公网) 172.26.188.175(内网)
MinIO Nginx
80 (公网开放) 9000 (内网开放)
img3.diyhi.com
V4
***.92.127.117(公网) 172.26.188.176(内网)
MinIO Nginx
80 (公网开放) 9000 (内网开放)
img4.diyhi.com
S1
***.100.153.26(公网) 172.26.188.178(内网)
JDK 1.8 Tomcat 8.5 MySQL 5.7 Nginx
80
bbs.diyhi.com
美女测试
测试图片2
主机配置:V1 安装配置MinIO 1、创建并进入安装目录
输入命令 mkdir /usr/local/minio 输入命令 cd /usr/local/minio
2、下载对应当前系统版本的安装包
输入命令 wget https://dl.min.io/server/minio/release/linux-amd64/minio
3、创建minio启动用户并授权
输入命令 getent group minio || groupadd -r minio 输入命令 getent passwd minio || useradd -r -d /opt -s /bin/nologin -g minio minio
4、minio文件赋予750权限
输入命令 chmod 750 /usr/local/minio/minio
5、创建存放数据目录
输入命令 mkdir /usr/local/minio/data
6、编辑minio配置文件
输入命令 vim /usr/local/minio/minio.conf
将下面的配置内容复制到minio.conf文件中。请按实际情况更改下面的参数,集群下所有节点的账号密码必须一致。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 MINIO_VOLUMES="http://172.26.188.173/usr/local/minio/data http://172.26.188.174/usr/local/minio/data http://172.26.188.175/usr/local/minio/data http://172.26.188.176/usr/local/minio/data" MINIO_OPTS="--address :9000" MINIO_ACCESS_KEY="test" MINIO_SECRET_KEY="diEvRU6eQez123456Dkkpo4srS"
7、更改文件、目录属主属组
输入命令 chown -R minio:minio /usr/local/minio
8、设置命令启动服务
输入命令 vim /usr/lib/systemd/system/minio.service
将下面的配置内容复制到minio.service文件中。
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 [Unit] Description=MinIO Documentation=https://docs.min.io Wants=network-online.target After=network-online.target AssertFileIsExecutable=/usr/local/minio/minio [Service] User=minio Group=minio EnvironmentFile=/usr/local/minio/minio.conf 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/minio/minio server $MINIO_OPTS $MINIO_VOLUMES Restart=always LimitNOFILE=65536 TimeoutStopSec=infinity SendSIGKILL=no [Install] WantedBy=multi-user.target
保存配置文件后执行systemctl daemon-reload命令刷新
输入命令 systemctl daemon-reload
使用配置好的系统服务管理MinIO
systemctl enable minio
配置开机启动
systemctl start minio
启动
systemctl stop minio
停止
systemctl restart minio
重启
systemctl disable minio
删除开机启动
systemctl daemon-reload
刷新
安装配置Nginx 1.下载并安装nginx
输入命令 yum install nginx
2.启动nginx
输入命令 systemctl start nginx
使用配置好的系统服务管理Nginx
systemctl enable nginx
配置开机启动
systemctl start nginx
启动nginx
systemctl stop nginx
停止nginx
systemctl restart nginx
重启nginx
systemctl disable nginx
删除开机启动
systemctl daemon-reload
刷新
3.配置nginx
默认的配置文件在 /etc/nginx 路径下,使用该配置已经可以正确地运行nginx;如需要自定义,修改其下的 nginx.conf 等文件即可
输入命令 vim /etc/nginx/conf.d/default.conf
配置Nginx参数 请按实际情况更改下面的参数。
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 proxy_cache_path /etc/nginx/cache levels=1 :2 keys_zone=img_cache:10m inactive=1d max_size=50G ;server { listen 80 ; server_name _; return 404 ; } server{ listen 80 ; server_name img1.diyhi.com; location /{ proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; client_max_body_size 100M ; } location ~ /(file/topic|file/help)/.*\.(m3u8|ts|mp4|avi|mkv|wmv|wav|rm|rmvb|mp3|flac|ape|zip|rar|7z|txt|docx|doc|pptx|ppt|xlsx|xls)$ { if ($request_method ~ ^(GET|POST|HEAD|OPTIONS|PUT|TRACE|CONNECT)$ ) { return 302 ; error_page 302 = @process_secure_link ; } proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; } location @process_secure_link { secure_link $arg_md5 ,$arg_expires ; secure_link_md5 1234567890123456 $uri $arg_expires ; if ($secure_link = "" ) { return 403 ; } if ($secure_link = "0" ) { return 410 ; } if ($arg_filename != "" ) { add_header Content-Disposition 'attachment; filename="$arg_filename "' ; } proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; } location ~ /(file/topic)/.*\.(jpg|jpeg|gif|png|bmp)$ { proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; client_max_body_size 100M ; if ($request_method = GET) { return 302 ; error_page 302 = @process_image_filter ; } } location @process_image_filter { proxy_pass http://127.0.0.1:9000; set $flag 0 ; set $width $arg_width ; set $originalImage 0 ; if ($width != '' ){ set $flag "${flag} 1" ; } if ($arg_width !~ ^(240|400)$) { set $flag "${flag} 1" ; } if ($flag = "011" ){ set $width '240' ; } if ( $width = '' ) { set $width '-' ; } if ( $width = '-' ) { set $originalImage 1 ; } proxy_no_cache $originalImage ; proxy_cache_key $host $uri $width ; proxy_cache img_cache; proxy_cache_valid 200 1d ; proxy_cache_lock on ; proxy_cache_lock_timeout 5s ; proxy_cache_revalidate on ; add_header Nginx-Cache "$upstream_cache_status " ; image_filter resize $width -; image_filter_buffer 100M ; image_filter_jpeg_quality 90 ; image_filter_transparency on ; } }
配置完成保存。 调用nginx -t测试配置文件是否正确
7.日志
访问日志默认路径 /var/log/nginx/access.log 错误日志默认路径 /var/log/nginx/error.log
防火墙开放端口配置 仅允许内网IP访问指定端口
#(1)允许172.26.188.0 IP段访问9000端口 输入命令 firewall-cmd –permanent –add-rich-rule=’rule family=”ipv4” source address=”172.26.188.0/24” port protocol=”tcp” port=”9000” accept’ #(2)允许公网访问80端口 输入命令 firewall-cmd –permanent –zone=public –add-port=80/tcp #(3)执行完命令要刷新才能生效 输入命令 firewall-cmd –reload #(4)列出所有的开放端口 输入命令 firewall-cmd –list-all
移除策略
firewall-cmd –permanent –remove-rich-rule=’rule family=”ipv4” source address=”IP地址” port protocol=”tcp” port=”端口号” accept’ #例如移除9000端口策略 firewall-cmd –permanent –remove-rich-rule=’rule family=”ipv4” source address=”172.26.188.0/24” port protocol=”tcp” port=”9000” accept’ 输入命令 firewall-cmd –reload 执行完命令要刷新才能生效
主机配置:V2 … … … … 省略的教程和上面的主机V1配置相同 … … … …
配置Nginx参数 请按实际情况更改下面的参数。
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 proxy_cache_path /etc/nginx/cache levels=1 :2 keys_zone=img_cache:10m inactive=1d max_size=50G ;server { listen 80 ; server_name _; return 404 ; } server{ listen 80 ; server_name img2.diyhi.com; location /{ proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; client_max_body_size 100M ; } location ~ /(file/topic|file/help)/.*\.(m3u8|ts|mp4|avi|mkv|wmv|wav|rm|rmvb|mp3|flac|ape|zip|rar|7z|txt|docx|doc|pptx|ppt|xlsx|xls)$ { if ($request_method ~ ^(GET|POST|HEAD|OPTIONS|PUT|TRACE|CONNECT)$ ) { return 302 ; error_page 302 = @process_secure_link ; } proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; } location @process_secure_link { secure_link $arg_md5 ,$arg_expires ; secure_link_md5 1234567890123456 $uri $arg_expires ; if ($secure_link = "" ) { return 403 ; } if ($secure_link = "0" ) { return 410 ; } if ($arg_filename != "" ) { add_header Content-Disposition 'attachment; filename="$arg_filename "' ; } proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; } location ~ /(file/topic)/.*\.(jpg|jpeg|gif|png|bmp)$ { proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; client_max_body_size 100M ; if ($request_method = GET) { return 302 ; error_page 302 = @process_image_filter ; } } location @process_image_filter { proxy_pass http://127.0.0.1:9000; set $flag 0 ; set $width $arg_width ; set $originalImage 0 ; if ($width != '' ){ set $flag "${flag} 1" ; } if ($arg_width !~ ^(240|400)$) { set $flag "${flag} 1" ; } if ($flag = "011" ){ set $width '240' ; } if ( $width = '' ) { set $width '-' ; } if ( $width = '-' ) { set $originalImage 1 ; } proxy_no_cache $originalImage ; proxy_cache_key $host $uri $width ; proxy_cache img_cache; proxy_cache_valid 200 1d ; proxy_cache_lock on ; proxy_cache_lock_timeout 5s ; proxy_cache_revalidate on ; add_header Nginx-Cache "$upstream_cache_status " ; image_filter resize $width -; image_filter_buffer 100M ; image_filter_jpeg_quality 90 ; image_filter_transparency on ; } }
… … … … … …
主机配置:V3 … … … … 省略的教程和上面的主机V1配置相同 … … … …
配置Nginx参数 请按实际情况更改下面的参数。
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 proxy_cache_path /etc/nginx/cache levels=1 :2 keys_zone=img_cache:10m inactive=1d max_size=50G ;server { listen 80 ; server_name _; return 404 ; } server{ listen 80 ; server_name img3.diyhi.com; location /{ proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; client_max_body_size 100M ; } location ~ /(file/topic|file/help)/.*\.(m3u8|ts|mp4|avi|mkv|wmv|wav|rm|rmvb|mp3|flac|ape|zip|rar|7z|txt|docx|doc|pptx|ppt|xlsx|xls)$ { if ($request_method ~ ^(GET|POST|HEAD|OPTIONS|PUT|TRACE|CONNECT)$ ) { return 302 ; error_page 302 = @process_secure_link ; } proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; } location @process_secure_link { secure_link $arg_md5 ,$arg_expires ; secure_link_md5 1234567890123456 $uri $arg_expires ; if ($secure_link = "" ) { return 403 ; } if ($secure_link = "0" ) { return 410 ; } if ($arg_filename != "" ) { add_header Content-Disposition 'attachment; filename="$arg_filename "' ; } proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; } location ~ /(file/topic)/.*\.(jpg|jpeg|gif|png|bmp)$ { proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; client_max_body_size 100M ; if ($request_method = GET) { return 302 ; error_page 302 = @process_image_filter ; } } location @process_image_filter { proxy_pass http://127.0.0.1:9000; set $flag 0 ; set $width $arg_width ; set $originalImage 0 ; if ($width != '' ){ set $flag "${flag} 1" ; } if ($arg_width !~ ^(240|400)$) { set $flag "${flag} 1" ; } if ($flag = "011" ){ set $width '240' ; } if ( $width = '' ) { set $width '-' ; } if ( $width = '-' ) { set $originalImage 1 ; } proxy_no_cache $originalImage ; proxy_cache_key $host $uri $width ; proxy_cache img_cache; proxy_cache_valid 200 1d ; proxy_cache_lock on ; proxy_cache_lock_timeout 5s ; proxy_cache_revalidate on ; add_header Nginx-Cache "$upstream_cache_status " ; image_filter resize $width -; image_filter_buffer 100M ; image_filter_jpeg_quality 90 ; image_filter_transparency on ; } }
… … … … … …
主机配置:V4 … … … … 省略的教程和上面的主机V1配置相同 … … … …
配置Nginx参数 请按实际情况更改下面的参数。
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 proxy_cache_path /etc/nginx/cache levels=1 :2 keys_zone=img_cache:10m inactive=1d max_size=50G ;server { listen 80 ; server_name _; return 404 ; } server{ listen 80 ; server_name img4.diyhi.com; location /{ proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; client_max_body_size 100M ; } location ~ /(file/topic|file/help)/.*\.(m3u8|ts|mp4|avi|mkv|wmv|wav|rm|rmvb|mp3|flac|ape|zip|rar|7z|txt|docx|doc|pptx|ppt|xlsx|xls)$ { if ($request_method ~ ^(GET|POST|HEAD|OPTIONS|PUT|TRACE|CONNECT)$ ) { return 302 ; error_page 302 = @process_secure_link ; } proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; } location @process_secure_link { secure_link $arg_md5 ,$arg_expires ; secure_link_md5 1234567890123456 $uri $arg_expires ; if ($secure_link = "" ) { return 403 ; } if ($secure_link = "0" ) { return 410 ; } if ($arg_filename != "" ) { add_header Content-Disposition 'attachment; filename="$arg_filename "' ; } proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; } location ~ /(file/topic)/.*\.(jpg|jpeg|gif|png|bmp)$ { proxy_set_header Host $host ; proxy_set_header X-Real-Ip $remote_addr ; proxy_set_header X-Forwarded-For $remote_addr ; proxy_pass http://127.0.0.1:9000; client_max_body_size 100M ; if ($request_method = GET) { return 302 ; error_page 302 = @process_image_filter ; } } location @process_image_filter { proxy_pass http://127.0.0.1:9000; set $flag 0 ; set $width $arg_width ; set $originalImage 0 ; if ($width != '' ){ set $flag "${flag} 1" ; } if ($arg_width !~ ^(240|400)$) { set $flag "${flag} 1" ; } if ($flag = "011" ){ set $width '240' ; } if ( $width = '' ) { set $width '-' ; } if ( $width = '-' ) { set $originalImage 1 ; } proxy_no_cache $originalImage ; proxy_cache_key $host $uri $width ; proxy_cache img_cache; proxy_cache_valid 200 1d ; proxy_cache_lock on ; proxy_cache_lock_timeout 5s ; proxy_cache_revalidate on ; add_header Nginx-Cache "$upstream_cache_status " ; image_filter resize $width -; image_filter_buffer 100M ; image_filter_jpeg_quality 90 ; image_filter_transparency on ; } }
… … … … … …
巡云轻论坛系统管理后台设置 1、打开‘文件存储系统接口列表’–‘添加文件系统接口’,接口产品选择‘MinIO’
本地文件存储和MinIO文件存储互相迁移 1、打开‘系统设置’–‘维护数据’,选择‘MinIO文件同步到本地’或‘本地文件同步到MinIO’