前言
分布式文件存储,支持java API,选用minio,当然也可以使用阿里的OSS,azure S3等其他技术;
本地文件上传,下载文件可以使用s3cmd,所以本地安装下s3cmd.
提示:以下是本篇文章正文内容,下面案例可供参考
一、minio安装
对于中小型企业,如果不选择存储上云,那么 Minio 是个不错的选择,基于 Golang 编写的开源对象存储套件,虽然轻量,却拥有着不错的性能。minio安装分为单机部署和分布式部署,这里介绍单机部署。
1.文件下载
# minio version RELEASE.2021-04-18T19-26-29Z
wget https://dl.min.io/server/minio/release/linux-amd64/minio
2.安装文件
# 授予执行权限,直接启动
chmod +x minio
3.启动停止服务
# 指定用户名/密码
export MINIO_ACCESS_KEY=minio
export MINIO_SECRET_KEY=minio
# 启动
./minio server --address 0.0.0.0:9000 /opt/jeecg-boot/upload > /home/minio/minio.log 2>&1 &
# 多租户采用以下方式
minio --config-dir ~/tenant1 server --address :9001 /data/tenant1
minio --config-dir ~/tenant2 server --address :9002 /data/tenant2
minio --config-dir ~/tenant3 server --address :9003 /data/tenant3
–address 0.0.0.0:9000 外网可以访问
/opt/jeecg-boot/upload 制定数据目录
/home/minio/minio.log 制定日志目录
可以不使用nohup启动。
停止服务 kill -9 pid
二、s3cmd安装
1.下载安装包
mac os 下 使用brew安装,如果没有安装,可以参考brew官网安装,这里不再介绍。
安装本版本的s3cmd之前需要安装Python 2.7 or newer。
brew install s3cmd
2.安装配置
s3cmd –configure
Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.
Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
Access Key: minio
Secret Key: minio
Default Region [US]:
Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
S3 Endpoint [s3.amazonaws.com]: localhost:9000
Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
if the target S3 system supports dns based buckets.
DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: %(designreport)localhost:9000
Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password: minio
Path to GPG program:
When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP, and can only be proxied with Python 2.7 or newer
Use HTTPS protocol [Yes]: no
On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't connect to S3 directly
HTTP Proxy server name:
New settings:
Access Key: minio
Secret Key: minio
Default Region: US
S3 Endpoint: localhost:9000
DNS-style bucket+hostname:port template for accessing a bucket: %(designreport)localhost:9000
Encryption password: minio
Path to GPG program: None
Use HTTPS protocol: False
HTTP Proxy server name:
HTTP Proxy server port: 0
Test access with supplied credentials? [Y/n] y
Please wait, attempting to list all buckets...
Success. Your access key and secret key worked fine :-)
Now verifying that encryption works...
Not configured. Never mind.
Save settings? [y/N] y
Configuration saved to '/Users/zzz/.s3cfg'
3.使用
3.1 minio web端
浏览器访问 http://127.0.0.1:9000 ,登录的 用户名密码就是以上设置的MINIO_ACCESS_KEY 和 MINIO_SECRET_KEY。登录完成后,我们便进入了 Minio 的控制台,在控制台里我们可以创建 Bucket、上传文件。
3.2s3cmd上传下载文件
(base) localhost:bin zzz$ s3cmd ls s3://designreport/images
DIR s3://designreport/images/
(base) localhost:bin zzz$ s3cmd get s3://designreport/images/* ./
download: 's3://designreport/images/bg_1606894559245.jpg' -> './bg_1606894559245.jpg' [1 of 1]
258297 of 258297 100% in 0s 1156.11 KB/s done
总结
提示:这里对文章进行总结:主要应用于分布式文件存储和管理。