fastdfs詳細安裝教程


前言

最近開始搞的項目涉及到 fastdfs,工欲善其事,必先利其器,於是我自己搭了一台 fastdfs 服務器。坑已經幫大家都踩過了。按照該教程100%能安裝成功。

前期准備

一個centos7
一個FastDFS_v5.05.tar.gz
一個libfastcommon

開始安裝

安裝tracker

(1)安裝gcc

yum install gcc-c++

(2)安裝libevent

yum -y install libevent

(3)安裝libfastcommon
將libfastcommonV1.0.7.tar.gz拷貝至/usr/local/下

cd /usr/local
tar -zxvf libfastcommonV1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install

注意如果./make.sh失敗,報perl未找到,執行下方的方法。

yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl 
openssl-devel libevent libevent-devel perl unzip net-tools wget

(4)將/usr/lib64下的庫文件libfastcommon.so拷貝至/usr/lib下
(5)將FastDFS_v5.05.tar.gz拷貝至/usr/local/下

tar -zxvf FastDFS_v5.05.tar.gz
cd FastDFS
./make.sh
./make.sh install

安裝成功將安裝目錄下的conf下的文件拷貝到/etc/fdfs/下。
client,http,mime,storage,storage_ids,tracker
(6)安裝成功后進入/etc/fdfs目錄:
拷貝一份新的tracker配置文件:

cp tracker.conf.sample tracker.conf

修改tracker.conf
vi tracker.conf
base_path=/home/yuqing/FastDFS  
改為:
base_path=/home/FastDFS
(7)啟動

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

(8)設置開機自動啟動

 vim /etc/rc.d/rc.local

將運行命令行添加進文件:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

安裝 Storage

(0)如果在一台服務器上,之前的tracker,libevent,libfastcommon
解壓 fastdfs,這些步驟可以不用進行,如果兩台的話,需要進行。
(1)安裝成功后進入/etc/fdfs目錄
拷貝一份新的storage配置文件:
cp storage.conf.sample storage.conf

(2)修改storage.conf

vi storage.conf

group_name=group1

base_path=/home/yuqing/FastDFS改為:base_path=/home/FastDFS

store_path0=/home/yuqing/FastDFS改為:store_path0=/home/FastDFS/fdfs_storage

/#如果有多個掛載磁盤則定義多個store_path,如下
/#store_path1=.....
/#store_path2=......tracker_server=192.168.101.3:22122   #配置tracker服務器:IP
/#如果有多個則配置多個tracker
tracker_server=192.168.20.1:22122
上面的地址寫你自己的詳細地址。
(3)啟動
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
(4)設置開機啟動

 vim /etc/rc.d/rc.local

將運行命令行添加進文件

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

上傳測試

修改/etc/fdfs/client.conf

base_path=/home/fastdfs

tracker_server=192.168.20.1:22122

使用格式:

/usr/bin/fdfs_test 客戶端配置文件地址  upload  上傳文件

比如將/home下的圖片上傳到FastDFS中:

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/1.png


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM