源码开放下载地址:https://github.com/happyfish100
早期源码开放下载地址:https://sourceforge.net/projects/fastdfs/files/
FastDFS系统架构:
FastDFS文件上传流程:
1、client询问tracker上传到的storage,不需要附加参数;
2、tracker返回一台可用的storage;
3、client直接和storage通讯完成文件上传。
FastDFS文件下载流程:
1、client询问tracker下载文件的storage,参数为文件标识(组名和文件名);
2、tracker返回一台可用的storage;
3、client直接和storage通讯完成文件下载。
术语
FastDFS两个主要的角色:Tracker Server 和 Storage Server
Tracker Server:跟踪服务器,主要负责调度storage节点与client通信,在访问上起负载均衡的作用,和记录storage节点的运行状态,是连接client和storage节点的枢纽。
Storage Server:存储服务器,保存文件和文件的meta data(元数据)
Group:文件组,也可以称为卷。同组内服务器上的文件是完全相同的,做集群时往往一个组会有多台服务器,上传一个文件到同组内的一台机器上后,FastDFS会将该文件即时同步到同组内的其它所有机器上,起到备份的作用。
meta data:文件相关属性,键值对(Key Value Pair)方式,如:width=1024, height=768。和阿里云OSS的meta data相似。
FastDFS单节点安装 - 服务器规划:
跟踪服务器(Tracker Server):192.168.0.200
存储服务器(Storage Server):192.168.0.201
操作系统:CentOS7
用户:root
数据存储目录:/fastdfs
安装包:
fastdfs-master-V5.05.zip:FastDFS源码
libfastcommon-master.zip:(从 FastDFS 和 FastDHT 中提取出来的公共 C 函数库)
fastdfs-nginx-module-master.zip:storage节点http服务nginx模块
nginx-1.10.0.tar.gz:Nginx安装包
ngx_cache_purge-2.3.tar.gz:图片缓存清除Nginx模块(集群环境会用到)
可以到Linux公社资源站下载所有安装包:
------------------------------------------分割线------------------------------------------
具体下载目录在 /2017年资料/2月/9日/FastDFS分布式文件系统安装与使用(单节点)/
------------------------------------------分割线------------------------------------------
你也可以从作者github官网去下载。
下载完成后,将压缩包解压到/usr/local/src
目录下
一、所有tracker和storage节点都执行如下操作
1、安装所需的依赖包
shell> yum install make cmake gcc gcc-c++
2、安装libfatscommon
shell> cd /usr/local/src
shell> unzip libfastcommon-master.zip
shell> cd libfastcommon-master
shell> ll
-rw-r--r--. 1 root root 6670 10月 8 09:39 HISTORY
-rw-r--r--. 1 root root 566 10月 8 09:39 INSTALL
-rw-r--r--. 1 root root 1438 10月 8 09:39 libfastcommon.spec
-rwxr-xr-x. 1 root root 3099 10月 8 09:39 make.sh
drwxr-xr-x. 2 root root 4096 10月 8 09:39 php-fastcommon
-rw-r--r--. 1 root root 812 10月 8 09:39 README
drwxr-xr-x. 3 root root 4096 10月 8 09:39 src
## 编译、安装
shell> ./make.sh
shell> ./make.sh install
3、安装FastDFS
shell> cd /usr/local/src
shell> unzip fastdfs-master-V5.05.zip
shell> cd fastdfs-master
shell> ll
[root@localhost fastdfs-master]# ll
drwxr-xr-x. 3 root root 4096 8月 8 15:17 client
drwxr-xr-x. 2 root root 4096 8月 8 15:17 common
drwxr-xr-x. 2 root root 4096 8月 8 15:17 conf
-rw-r--r--. 1 root root 35067 8月 8 15:17 COPYING-3_0.txt
-rw-r--r--. 1 root root 2881 8月 8 15:17 fastdfs.spec
-rw-r--r--. 1 root root 32259 8月 8 15:17 HISTORY
drwxr-xr-x. 2 root root 46 8月 8 15:17 init.d
-rw-r--r--. 1 root root 7755 8月 8 15:17 INSTALL
-rwxr-xr-x. 1 root root 5548 8月 8 15:17 make.sh
drwxr-xr-x. 2 root root 4096 8月 8 15:17 php_client
-rw-r--r--. 1 root root 2380 8月 8 15:17 README.md
-rwxr-xr-x. 1 root root 1768 8月 8 15:17 restart.sh
-rwxr-xr-x. 1 root root 1680 8月 8 15:17 stop.sh
drwxr-xr-x. 4 root root 4096 8月 8 15:17 storage
drwxr-xr-x. 2 root root 4096 8月 8 15:17 test
drwxr-xr-x. 2 root root 4096 8月 8 15:17 tracker
## 编译、安装
shell> ./make.sh
shell> ./make.sh install
采用默认安装方式,相应的文件与目录如下:
1> 服务脚本:
/etc/init.d/fdfs_storaged
/etc/init.d/fdfs_trackerd
2> 配置文件(示例配置文件):
/etc/fdfs
shell> ll /etc/fdfs/
总用量 20
-rw-r--r--. 1 root root 1461 10月 17 15:15 client.conf.sample
-rw-r--r--. 1 root root 7927 10月 17 15:15 storage.conf.sample
-rw-r--r--. 1 root root 7200 10月 17 15:15 tracker.conf.sample
3> 命令行工具(/usr/bin目录下)
shell> ll /usr/bin/ | grep fdfs
-rwxr-xr-x. 1 root root 315391 10月 17 15:15 fdfs_appender_test
-rwxr-xr-x. 1 root root 315168 10月 17 15:15 fdfs_appender_test1
-rwxr-xr-x. 1 root root 302016 10月 17 15:15 fdfs_append_file
-rwxr-xr-x. 1 root root 301692 10月 17 15:15 fdfs_crc32
-rwxr-xr-x. 1 root root 302075 10月 17 15:15 fdfs_delete_file
-rwxr-xr-x. 1 root root 302810 10月 17 15:15 fdfs_download_file
-rwxr-xr-x. 1 root root 302400 10月 17 15:15 fdfs_file_info
-rwxr-xr-x. 1 root root 316229 10月 17 15:15 fdfs_monitor
-rwxr-xr-x. 1 root root 1101974 10月 17 15:15 fdfs_storaged
-rwxr-xr-x. 1 root root 325327 10月 17 15:15 fdfs_test
-rwxr-xr-x. 1 root root 320448 10月 17 15:15 fdfs_test1
-rwxr-xr-x. 1 root root 447878 10月 17 15:15 fdfs_trackerd
-rwxr-xr-x. 1 root root 303002 10月 17 15:15 fdfs_upload_appender
-rwxr-xr-x. 1 root root 304022 10月 17 15:15 fdfs_upload_file