天天看点

FastDFS安装手册FastDFS搭建

FastDFS原理简介

Trackerserver作用是负载均衡和调度,通过Trackerserver在文件上传时可以根据一些策略找到Storageserver提供文件上传服务。可以将tracker称为追踪服务器或调度服务器。
Storageserver作用是文件存储,客户端上传的文件最终存储在Storage服务器上,Storage server没有实现自己的文件系统而是利用操作系统 的文件系统来管理文件。可以将storage称为存储服务器。  
           
FastDFS安装手册FastDFS搭建

通信原理

文件上传

FastDFS安装手册FastDFS搭建

FastDFS搭建

下载

下载的包都存放在/root/目录下。

下载libfastcommon、fastdfs、fastdfs-nginx-module:

cd /root/

wget

https://github.com/happyfish100/libfastcommon/archive/V1.0.39.tar.gz

-SO libfastcommon.tar.gz

https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz

-SO fastdfs.tar.gz

https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz

-SO fastdfs-nginx-module.tar.gz

解压

tar -zxf fastdfs.tar.gz

tar -zxf fastdfs-nginx-module.tar.gz

tar -zxf libfastcommon.tar.gz

安装

安装基础包:

yum install gcc-c++ libevent -y

安装libfastcommon

cd libfastcommon-1.0.39

./make.sh

./make.sh install

安装fastdfs

cd fastdfs-5.11

安装好后,程序是在/usr/bin目录下:

which fdfs_trackerd

FastDFS安装手册FastDFS搭建

而配置文件是在/etc/fdfs目录下:

ls /etc/fdfs

client.conf.sample storage_ids.conf.sample tracker.conf.sample storage.conf.sample

但是这些配置文件是不全的,而且都是模板,所以需要从fastdfs包中拷贝过来,并修改配置:

cd /root/fastdfs-5.11/conf

ls

anti-steal.jpg client.conf http.conf mime.types storage.conf storage_ids.conf tracker.conf

cp /root/fastdfs-5.11/conf/* /etc/fdfs

cp /root/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf /etc/fdfs

修改配置文件

修改/etc/fdfs/tracker.conf

必改项:base_path

FastDFS安装手册FastDFS搭建

修改/etc/fdfs/storage.conf

横向扩展:多台storage即配置基本一致,变更group_name即可

纵向扩展:如果有多个挂载磁盘,则定义多个store_path即可

修改项:group_name base_path store_path0 tracker_server

FastDFS安装手册FastDFS搭建
FastDFS安装手册FastDFS搭建

修改client.cnf

修改项:base_path tracker_server

FastDFS安装手册FastDFS搭建

修改/etc/fdfs/mod_fastdfs.conf:

修改项:base_path tracker_server group_name

FastDFS安装手册FastDFS搭建

启动tracker和storage:

启动

fdfs_trackerd /etc/fdfs/tracker.conf start

fdfs_storaged /etc/fdfs/storage.conf start

查看日志

tail -10f /root/fdfs-5.11/logs/trackerd.log

tail 10f /root/fdfs-5.11/logs/storaged.log

如果日志显示有错误信息,需要根据信息来查找错误原因

查看状态:

FastDFS安装手册FastDFS搭建

上传文件

fdfs_test /etc/fdfs/client.conf upload /root/fastdfs-5.11/INSTALL

FastDFS安装手册FastDFS搭建

参考资料:

https://www.cnblogs.com/gugibv/p/8585616.html https://blog.csdn.net/xingjiarong/article/details/50559768 https://segmentfault.com/a/1190000018251300?utm_source=tag-newest https://blog.csdn.net/kamroselee/article/details/80334621 https://sourceforge.net/projects/fastdfs/ https://github.com/happyfish100/libfastcommon