天天看點

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