雲計算

FastDFS安裝手冊

FastDFS原理簡介

Trackerserver作用是負載均衡和調度,通過Trackerserver在文件上傳時可以根據一些策略找到Storageserver提供文件上傳服務。可以將tracker稱為追蹤服務器或調度服務器。

     Storageserver作用是文件存儲,客戶端上傳的文件最終存儲在Storage服務器上,Storage server沒有實現自己的文件系統而是利用操作系統 的文件系統來管理文件。可以將storage稱為存儲服務器。  

image.png
通信原理
文件上傳

image.png

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
wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz -SO fastdfs.tar.gz
wget 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
./make.sh
./make.sh install

安裝好後,程序是在/usr/bin目錄下:

which fdfs_trackerd
image.png

而配置文件是在/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
image.png
修改/etc/fdfs/storage.conf
橫向擴展:多臺storage即配置基本一致,變更group_name即可
縱向擴展:如果有多個掛載磁盤,則定義多個store_path即可
修改項:group_name base_path store_path0 tracker_server
image.png
image.png
修改client.cnf
修改項:base_path tracker_server
image.png
修改/etc/fdfs/mod_fastdfs.conf:
修改項:base_path tracker_server group_name
image.png
啟動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
如果日誌顯示有錯誤信息,需要根據信息來查找錯誤原因
查看狀態:
image.png

上傳文件

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

參考資料:
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

Leave a Reply

Your email address will not be published. Required fields are marked *