FastDFS是一个轻量级的开源分布式文件系统 FastDFS主要解决了大容量的文件存储和高并发访问的问题,文件存取时实现了负载均衡 FastDFS实现了软件方式的RAID,可以使用廉价的IDE硬盘进行存储 支持存储服务器在线扩容 支持相同内容的文件只保存一份,节约磁盘空间 FastDFS只能通过Client API访问,不支持POSIX访问方式;FastDFS特别适合大中型网站使用,用来存储资源文件(如:图片、文档、音频、视频等等)。
架构图
系统架构-上传文件流程图
1. client询问tracker上传到的storage,不需要附加参数;
2. tracker返回一台可用的storage;
3. client直接和storage通讯完成文件上传。
同步机制
同一组内的storage server之间是对等的,文件上传、删除等操作可以在任意一台storage server上进行; 文件同步只在同组内的storage server之间进行,采用push方式,即源服务器同步给目标服务器; 源头数据才需要同步,备份数据不需要再次同步,否则就构成环路了; 上述第二条规则有个例外,就是新增加一台storage server时,由已有的一台storage server将已有的所有数据(包括源头数据和备份数据)同步给该新增服务器。
运行时目录结构-tracker server
运行时目录结构-storage server
安装和运行
#step 1. download FastDFS source package and unpack it,
# if you use HTTP to download file, please download libevent 1.4.x and install it
tar xzf FastDFS_v1.x.tar.gz #for example:
tar xzf FastDFS_v1.20.tar.gz
#step 2. enter the FastDFS dir cd FastDFS
#step 3. if HTTP supported, modify make.sh, uncomment the line:
# WITH_HTTPD=1, then execute: ./make.sh #step
4. make install ./make.sh install #step
5. edit/modify the config file of tracker and storage
#step 6. run server programs #start thetracker server:
/usr/local/bin/fdfs_trackerd <tracker_conf_filename>
#start the storage server:
/usr/local/bin/fdfs_storaged <storage_conf_filename>
安装到maven仓库
<dependency>
<groupId>org.csource</groupId>
<artifactId>fastdfs-client-java</artifactId>
<version>1.27-SNAPSHOT</version>
</dependency>