适合场景,可用,怎么搭建使用
MinIO(注意该开源使用的AGPL-3.0协议)
https://www.minio.org.cn/
相关
- 使用场景:MinIO适用于需要快速、可扩展和高性能对象存储的场景。它可以用作私有云或公共云环境中的存储解决方案,并且与云原生应用程序和大数据分析平台兼容。
- 优点:高性能、可扩展、与Amazon S3 API兼容、轻量级、数据冗余和容错性。
- 缺点:不适用于复杂的目录结构和文件关联关系,不支持块级别的并行访问。
- 有免费的和收费的,建议至少使用4个节点来构建集群。采用了erasure code(纠删码)来保证集群的稳定,保证数据可用,所以建议至少使用4个节点来构建集群,原因是:如果一个N节点的分布式MinIO,只要有N/2节点在线,数据就是安全的。但是要保证至少有N/2+1个节点来创建新的对象。比如:我们的集群有4个节点,每个节点上一块盘,就算有2两个节点宕机,这个集群仍然是可读的,但是,我们需要3个节点才能让集群写数据。这就是为什么我们要有4个节点来构建集群。
MinIO搭建集群并且用SpringBoot调用
https://blog.csdn.net/z69183787/article/details/125561807
hdfs
内容
-
使用场景:HDFS适用于大规模数据处理和分析的场景,特别是与Hadoop生态系统集成的应用程序。它支持批处理作业、数据冗余和容错性。
-
优点:适用于海量数据存储和处理、高容错性、可靠性和扩展性。
-
缺点:
-
不适用于小型数据集和低延迟访问、存储大量小文件会占用NameNode大量的内存来存储文件目录和块信息,而NameNode的内存是有限的。小文件存储的寻址时间会超过读取时间,违反HDFS的设计目标
-
不支持并发写入、不适合频繁更新和修改文件,一个文件只能有一个写,不允许多个线程同时写
-
搭建
-
hdfs集群的搭建参考:https://blog.csdn.net/stupid_gentleman/article/details/126867228
-
SpringBoot整合hdfs集群参考1:https://blog.csdn.net/batterMRTAN/article/details/125233868
-
参考2:
-
添加依赖
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-hdfs</artifactId> <version>3.3.1</version> </dependency> </dependencies>
-
application.properties配置
# HDFS配置 hdfs.nameservices=mycluster hdfs.namenode.rpc-address.mycluster.namenode1=namenode1:8020 hdfs.namenode.rpc-address.mycluster.namenode2=namenode2:8020 hdfs.client.failover.proxy.provider.mycluster=org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider
-
创建操作类
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.io.IOException; @Service public class HdfsService { @Value("${hdfs.nameservices}") private String hdfsNameServices; private FileSystem fileSystem; public void init() throws IOException { Configuration configuration = new Configuration(); configuration.set("dfs.nameservices", hdfsNameServices); fileSystem = FileSystem.get(configuration); } public void uploadFile(String localFilePath, String hdfsFilePath) throws IOException { fileSystem.copyFromLocalFile(false, true, new Path(localFilePath), new Path(hdfsFilePath)); } // 其他HDFS操作方法... }
-
JuiceFS
https://juicefs.com/
内容
- 使用场景:JuiceFS适用于分布式文件系统和云原生应用程序的场景。它提供了高性能、可扩展和具有版本控制的文件系统。
- 优点:支持多种云存储后端、高性能、可靠性和数据冗余、适合云原生应用程序。
- 缺点:相对较新的项目,生态系统可能不如其他文件系统完善。
搭建
-
集群搭建参考:https://juicefs.com/docs/zh/community/getting-started/for_distributed
-
添加依赖
-
添加依赖
<dependencies> <dependency> <groupId>io.juicefs</groupId> <artifactId>juicefs-sdk</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
-
application.properties配置
# JuiceFS配置 juicefs.accessKey=your-access-key juicefs.secretKey=your-secret-key juicefs.endpoint=https://juicefs-example.endpoint.com
-
创建操作类
import io.juicefs.client.JuiceFS; import io.juicefs.client.JuiceFSFileSystem; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Service public class JuiceFSService { @Value("${juicefs.accessKey}") private String accessKey; @Value("${juicefs.secretKey}") private String secretKey; @Value("${juicefs.endpoint}") private String endpoint; private JuiceFS juiceFS; public void init() { juiceFS = new JuiceFSFileSystem(accessKey, secretKey, endpoint); } public void uploadFile(String localFilePath, String juiceFSFilePath) { juiceFS.copyFromLocalFile(localFilePath, juiceFSFilePath); } // 其他JuiceFS操作方法... }
-
gridfs
https://docs.mongoing.com/cun-chu/journaling/guan-li-ri-zhi-ji-lu/gridfs
内容
- 使用场景:GridFS适用于MongoDB数据库中存储大文件的场景。它将大文件切分成小块存储,并将其与MongoDB文档关联。
- 优点:与MongoDB无缝集成、支持大文件存储和查询、适用于网站内容和多媒体文件存储。
- 缺点:性能可能不如专门的分布式文件系统、存储效率较低、不适合频繁更新和修改文件。
搭建
- 要先搭建MongoDB集群
- SpringBoot整合参考:https://www.jb51.net/article/226106.htm
总结
- MainIO建议使用4台服务器部署集群,此软件是使用AGPL-3.0开源,用于商业的时候,必须开放源码。
- hdfs不建议大量小文件使用且需要装Hadoop环境。
- JuiceFS比较新,网上的东西较少。
- GridFS适用于MongoDB数据库,基于MongoDB并且不支持mysql。
其他
- ceph好像不错,但是部署复杂麻烦。
- fastDFS也不错,但是是个人开发运营。部署整合参考:https://blog.csdn.net/G0_hw/article/details/106245968