1.简介
MinIO 是一款基于Go语言发开的高性能、分布式的对象存储系统。客户端支持Java,Net,Python,Javacript, Golang语言。
2.部署
2.1单机器单节点(docker)
官网教程:https://min.io/docs/minio/container/index.html
mkdir -p ~/minio/data
docker run \
-p 9000:9000 \
-p 9090:9090 \
--name minio \
-v ~/minio/data:/data \
-e "MINIO_ROOT_USER=ROOTNAME" \
-e "MINIO_ROOT_PASSWORD=CHANGEME123" \
quay.io/minio/minio server /data --console-address ":9090"
2.2单机器多节点(docker-compose)
参考:https://blog.csdn.net/ac1992122633/article/details/124135515
docker-compose.yaml
version: '3.7'
# 所有容器通用的设置和配置
x-minio-common: &minio-common
image: minio/minio
command: server --console-address ":9001" http://minio{1...4}/data
expose:
- "9000"
# environment:
# MINIO_ROOT_USER: minioadmin
# MINIO_ROOT_PASSWORD: minioadmin
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
# 启动4个docker容器运行minio服务器实例
# 使用nginx反向代理9000端口,负载均衡, 你可以通过9001、9002、9003、9004端口访问它们的web console
services:
minio1:
<<: *minio-common
hostname: minio1
ports:
- "9001:9001"
volumes:
- ./data/data1:/data
minio2:
<<: *minio-common
hostname: minio2
ports:
- "9002:9001"
volumes:
- ./data/data2:/data
minio3:
<<: *minio-common
hostname: minio3
ports:
- "9003:9001"
volumes:
- ./data/data3:/data
minio4:
<<: *minio-common
hostname: minio4
ports:
- "9004:9001"
volumes:
- ./data/data4:/data
nginx:
image: nginx:1.19.2-alpine
hostname: nginx
volumes:
- ./config/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "9000:9000"
depends_on:
- minio1
- minio2
- minio3
- minio4
2.3多机器多节点(docker)
https://www.jianshu.com/p/62be21930f97
https://www.jianshu.com/p/f1f56fe9f479
docker run -d --name minio \
-p 9000:9000 \
-p 9001:9001 \
--restart=always --net=host \
-e MINIO_ACCESS_KEY=minio \
-e MINIO_SECRET_KEY=123456 \
-v /home/minio/config:/root/.minio \
-v /home/minio/data1:/data1 \
-v /home/minio/data2:/data2 \
-v /home/minio/data3:/data3 \
-v /home/minio/data4:/data4 \
minio/minio server http://minio{1...2}/data{1...4} \
--console-address ":9001"
3.java
https://min.io/docs/minio/linux/developers/java/minio-java.html#minio-java-quickstart
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>MinIO</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MinIO</name>
<description>MinIO</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.4.6</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.10.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.3.70</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
FileUploader
package com.example.minio;
import io.minio.BucketExistsArgs;
import io.minio.MakeBucketArgs;
import io.minio.MinioClient;
import io.minio.UploadObjectArgs;
import io.minio.errors.MinioException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class FileUploader {
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException {
try {
// Create a minioClient with the MinIO server playground, its access key and secret key.
MinioClient minioClient =
MinioClient.builder()
.endpoint("http://10.86.97.145:9000")
.credentials("ROOTNAME", "CHANGEME123")
.build();
// Make 'asiatrip' bucket if not exist.
boolean found =
minioClient.bucketExists(BucketExistsArgs.builder().bucket("asiatrip").build());
if (!found) {
// Make a new bucket called 'asiatrip'.
minioClient.makeBucket(MakeBucketArgs.builder().bucket("asiatrip").build());
} else {
System.out.println("Bucket 'asiatrip' already exists.");
}
// Upload '/home/user/Photos/asiaphotos.zip' as object name 'asiaphotos-2015.zip' to bucket
// 'asiatrip'.
minioClient.uploadObject(
UploadObjectArgs.builder()
.bucket("asiatrip")
.object("asiaphotos-2015.zip")
.filename("D:/Desktop/minIO-test.zip")
.build());
System.out.println(
"'D:/Desktop/minIO-test.zip' is successfully uploaded as "
+ "object 'asiaphotos-2015.zip' to bucket 'asiatrip'.");
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
System.out.println("HTTP trace: " + e.httpTrace());
}
}
}
4.使用
https://www.cnblogs.com/lwqstyle/p/16587503.html
5.资源访问
https://www.shuzhiduo.com/A/Ae5RNEk35Q/
chmod +x mc
./mc config host add minio http://minio1:9000 minio(MINIO_ROOT_USER) 123456(MINIO_ROOT_PASSWORD) --api S3v4
./mc anonymous set public minio/ebrms(mc policy set public minio连接名称/桶名)
6.适用场景
Minio对象存储系统适用于大文件场景,海量小文件的场景下并不适合。
- Minio的类似于glusterfs是一个无中心元数据服务器的设计。其index还是依赖底层本地文件系统,导致当bucket 保存大量对象时, bucket list操作很慢。
- Minio目前只支持EC的模式。
①针对大文件的场景比较合适,由于设计简单,能发挥出磁盘等硬件的性能。目前看到的minio的应用场景也主要是替代HDFS的大数据的场景。
②EC默认推荐的配置是EC(M+N),其中M=N的模式,也就是数据盘和冗余盘相等的模式。例如 EC(4+4),EC(8+8)等模式,这种配置磁盘空间的利用率只有50%左右。对于大文件,大容量的情况,似乎空间浪费还是比较严重。社区后续也支持自己设置EC的模式,考虑到可靠性,目前官方不推荐使用。
③针对海量小文件场景,EC显然不合适,无论是元数据还是数据存储模式都不合适,性能比较差,空间利用率比较差。 - Minio的扩容也只支持集群扩容。并且新的集群只能存储新创建的bucket的数据。这对应用来说很不友好。
- 故障恢复:在单个集群里,节点或者磁盘都是固定的,不能动态的增加。所以磁盘或者节点失效后需要管理员人工介入,及时更换新的磁盘或者修改未能成功启动的磁盘,然后管理员通过命令才能在后台恢复数据。
- 其它对象存储的功能支持的比较全: 存储分级,生命周期,WORM,压缩加密,多版本,桶策略,桶复制等功能。
7.性能测试
7.1 minIO
https://max.book118.com/html/2022/0412/6121130212004133.shtm
7.2 fastDFS
https://www.jianshu.com/p/c084ed1057c9