一、安裝開發環境nginx
# yum groupinstall "Development Tools" "Server platform Development"git
直接把這個組下,經常使用軟件,一次性裝好!github
二、安裝libfastcommonvim
# git clone https://github.com/happyfish100/libfastcommon.gitapp
# cd libfastcommon/測試
# ./make.shspa
# ./make.sh install命令行
三、安裝fastdfs日誌
# cd /root/orm
# git clone https://github.com/happyfish100/fastdfs.git
# cd fastdfs/
# ./make.sh
# ./make.sh install
四、tracker 配置
配置文件修改:根據需求修改
# cd /etc/fdfs
# cp tracker.conf.sample tracker.conf
# vim /etc/fdfs/tracker.conf
base_path=/storge/fastdfs/tracker # 存儲日誌及tracker的狀態信息
啓動服務(Centos6):
# mkdir -pv /storge/fastdfs/tracker
# service fdfs_trackerd start
查看狀態 ss -tnl|grep 22122
service fdfs_trackerd stop 關閉
五、storage 配置
根據需求修改
# cd /etc/fdfs
# cp storage.conf.sample storage.conf
# vim /etc/fdfs/storage.conf
group_name=group1 #指定組名
base_path=/storge/fastdfs/storage # 用於存儲數據
store_path_count=2 # 設置設備數量
store_path0=/storge/fastdfs/storage/m0 #指定存儲路徑0
store_path1=/storge/fastdfs/storage/m1 #指定存儲路徑1
# 注意:同一組內存儲路徑不能衝突,例如:下一個節點的存儲路徑就是m2,m3....等
tracker_server=182.92.131.35:22122 #指定tracker
啓動服務(Centos6):
# mkdir -pv /storge/fastdfs/storage/{m0,m1} # 建立數據目錄
# service fdfs_storaged start
查看是否啓動
ss -tnl|grep 23000
六、client配置
修改客戶端配置文件
# cd /etc/fdfs
# cp client.conf.sample client.conf
base_path=/storge/fastdfs/client
tracker_server=182.92.131.35:22122
七、測試FastDFS
一、上傳文件
fdfs_upload_file [storage_ip:port] [store_path_index]
# fdfs_upload_file /etc/fdfs/client.conf /etc/issue
group1/M00/00/00/CgEOxVeMxeuABKiEAAAAF30Ccq85795930
二、查看文件
fdfs_file_info
# fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/CgEOxVeMxeuABKiEAAAAF30Ccq85795930
經過命令行上傳文件時出現錯誤:tracker_query_storage_fail,error no:28, error info No space left on device
緣由:tracker.conf的配置項reserved_storage_space的值默認爲4GB,而當前環境下剩餘空間已不足4GB。
解決:根據實際空間狀況修改配置項reserved_storage_space的值。修改 tracker.conf
三、下載文件
fdfs_download_file [local_filename] [ ]
# fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/CgEOxVeMxeuABKiEAAAAF30Ccq85795930 /tmp/issue
四、查看存儲節點狀態
# fdfs_monitor /etc/fdfs/client.conf
八、配置nginx爲storage server提供http訪問接口
一、下載fastdfs-nginx-module
# git clone https://github.com/happyfish100/fastdfs-nginx-module.git
二、下載nginx源碼,並編譯支持fastdfs
# 安裝依賴程序
# yum install openssl-devel pcre-devel -y &>/dev/null
./configure --prefix=/usr/local/nginxfast --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module --with-pcre=/usr/local/software/pcre-8.35/ --add-module=/usr/local/software/fastdfs-nginx-module/src
而後配置nginx
# wget http://nginx.org/download/nginx-1.10.1.tar.gz &>/dev/null
# tar xf /root/nginx-1.10.1.tar.gz
# cd /root/nginx-1.10.1
# useradd -r nginx &>/dev/null