一、安装开发环境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