unzip unzip libfastcommon-master.zip cd libfastcommon-master ./make.sh ./make.sh install
tar xf FastDFS_v5.04.tar.gz cd fastdfs-5.05 ./make.sh ./make.sh install
mkdir -pv /data/fastdfs/tracker
mkdir: 已建立目錄 "/data"mkdir: 已建立目錄 "/data/fastdfs"mkdir: 已建立目錄 "/data/fastdfs/tracker"
編輯 tracker.conf 文件,測試的時候只須要修改如下參數便可nginx
disabled=false #啓用配置文件 port=22122 #設置 tracker 的端口號 base_path=/data/fastdfs/tracker #設置 tracker 的數據文件和日誌目錄(需預先建立) http.server_port=8080 #設置 http 端口號
這個http.server_port=8080 指的是在tracker服務器上啓動http服務進程,如:apache或者nginx 啓動時所監聽的端口,這個彷佛是能夠不用管的,由於tracker自己就沒有安裝http服務git
直接使用 fdfs_trackerd 來啓動tracker進程,而後使用netstat 查看端口是否起來。github
[root@wangyinxiang fdfs]# fdfs_trackerd /etc/fdfs/tracker.conf restart [root@wangyinxiang fdfs]# netstat -antp | grep trackerd tcp 000.0.0.0:22122 0.0.0.0:*LISTEN14520/fdfs_trackerd

4. 配置storage apache
進入到 /etc/fdfs 目錄下,複製/usr/fastdfs/fastdfs-5.05/conf/* 下面的全部文件到當前目錄下(/etc/fdfs)vim
[root@wangyinxiang /etc/fdfs]# cd /etc/fdfs/ [root@wangyinxiang /etc/fdfs]# cp /usr/fastdfs/fastdfs-5.05/conf/* . [root@wangyinxiang /etc/fdfs]# ll 總用量 64 -rw-r--r-- 1 root root 146110月 2914:33 client.conf -rw-r--r-- 1 root root 85810月 2914:33 http.conf -rw-r--r-- 1 root root 3117210月 2914:33 mime.types -rw-r--r-- 1 root root 369710月 2914:34 mod_fastdfs.conf -rw-r--r-- 1 root root 764610月 2814:34 storage.conf -rw-r--r-- 1 root root 10510月 2914:33 storage_ids.conf -rw-r--r-- 1 root root 710210月 2914:33 tracker.conf
編輯配置文件 storage.conf 測試的時候,只需修改如下內容便可:服務器
[root@wangyinxiang /etc/fdfs]# vim storage.conf disabled=false#啓用配置文件 group_name=group1 #組名,根據實際狀況修改 port=23000 #設置 storage 的端口號 base_path=/data/fastdfs/storage #設置 storage 的日誌目錄(需預先建立) store_path_count=1 #存儲路徑個數,須要和 store_path 個數匹配 store_path0=/data/fastdfs/storage #存儲路徑 tracker_server=10.1.20.245:22122 #tracker 服務器的 IP 地址和端口號 http.server_port=8080 #設置storage上啓動的http服務的端口號,如安裝的nginx的端口號
[root@wangyinxiang /etc/fdfs]# fdfs_storaged /etc/fdfs/storage.conf restart
#查看端口是否起來 [root@wangyinxiang /etc/fdfs]# netstat -antp | grep storage tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 10333/fdfs_storaged tcp 0 0 10.1.20.245:57886 10.1.20.245:22122 ESTABLISHED 10333/fdfs_storaged
5. 可使用 fdfs_monitor 來查看一下storage的狀態,看是否已經成功註冊到了trackerapp
[......]# fdfs_monitor /etc/fdfs/storage.conf
#也能夠如下命令來監控服務器的狀態:
[......]# fdfs_monitor /etc/fdfs/client.conf

注:看到ACTIVE,就說明已經成功註冊到了tracker。
6. 客戶端上傳文件
FastDFS安裝包中,自帶了客戶端程序,經過程序能夠進行文件上傳。在使用這個客戶端程序以前,首先須要配置client.conf,而後再進行文件上傳及下載。
a、修改/etc/fdfs/client.conf文件,修改以下:
#支持httptcp
b、進入/usr/local/bin/目錄,上傳文件,執行 測試
sudo fdfs_test /etc/fdfs/client.conf upload a.txt
注:a.txt能夠在/usr/local/bin/目錄下本身建立一個spa