系统环境:CentOS 6.8 x64 软件:nginx-1.10.2 FastDFS-5.0.2
一、单机部署
1、#yum install –y gcc gcc-c++ libevent 下载 libfastcommon-master.zip #unzip libfastcommon-master.zip #cd libfastcommon-master #./make.sh #./make.sh install
2、下载FastDFS和fastdfs-nginx-module 3、安装FastDFS
#tar –zxf FastDFS-v5.08.tar.gz #cd FastDFS #./make.sh #./make.sh install
安装成功后可以在看/usr/local/bin目录下看到一系列fastDFS命令
https://sourceforge.net/projects/fastdfs/files/
https://github.com/happyfish100/libfastcommon
4、配置tracker #cd /etc/fdfs/
# cp tracker.conf.sample tracker.conf #vim /etc/fdfs/tracker.conf
base_path=/home/yuqing/fastdfs
#存储tracker信息目录,此目录可以自己定义
5、配置storage #cd /etc/fdfs/
# cp storage.conf.sample storage.conf #vim /etc/fdfs/storage.conf
tracker_server=192.168.12.41:22122 base_path=/home/yuqing/fastdfs
#指定tracker服务的地址 #存储storage信息的目录
6、启动服务
#/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf #启动tracker服务 #/usr/loca/bin/fdfs_storaged /etc/fdfs/storage.conf #启动storage服务 7、安装、配置nginx服务
# yum install -y pcre-devel libxml2-devel libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed openssl openssl-devel zlib zlib-devel #cd /usr/src/
#我下载的安装包都放在此目录下,这里根据自己的情况来
#tar –zxf fsatdfs-nginx-module_v1.15.tar.gz #tar –zxf nginx-1.10.2.tar.gz #cd nginx-1.10.2 #./configure
--without-http_rewrite_module
--with-http_ssl_module
--with-http_stub_status_module
--add-module=/usr/src/fastdfs-nginx-module/src/--add-module=/usr/src/ngx_cache_purge-master/ #make && make install
#cp /usr/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ #vim /etc/fdfs/mod_fastdfs.conf
tracker_server=192.168.12.41:22122
url_have_group_name = true location /group1/M00 { }
root /home/yuqing/fastdfs/data; ngx_fastdfs_module;
#启动nginx服务
#vim /usr/local/nginx/conf/nginx.conf
#/usr/local/nginx/sbin/nginx 9、配置client
#vim /etc/fdfs/client.conf
8、多个tracker、storage的话参照前面的配置在不同的服务器上配置
tracker_server = 192.168.12.41:22122
10、测试
#/usr/local/bin/fdfs_upload_file /etc/fdfs/client.conf 799182183250427301.jpg group1/M00/00/00/wKgMKVjl_I2AP6CrAOuhMUOHeJU210.jpg
#组名/虚拟磁盘名/一级目录/二级目录/文件名
通过http://192.168.12.41/ group1/M00/00/00/wKgMKVjl_I2AP6CrAOuhMUOHeJU210.jpg 可以访问到该图片
二、多点部署
以下操作需要在所有tracker、storage上进行
------------------------------------------------------------------------------------------------------------------------------------------------------ 1、#yum install –y gcc gcc-c++ libevent
2、下载 libfastcommon-master.zip https://github.com/happyfish100/libfastcommon #unzip libfastcommon-master.zip #cd libfastcommon-master #./make.sh #./make.sh install
3、下载FastDFS和fastdfs-nginx-module 4、安装FastDFS
#tar –zxf FastDFS-v5.08.tar.gz #cd FastDFS #./make.sh #./make.sh install
安装成功后可以在看/usr/bin目录下看到一系列fastDFS命令,有的版本可能是在/usr/local/bin目录
https://sourceforge.net/projects/fastdfs/files/
------------------------------------------------------------------------------------------------------------------------------------------------------ 5、配置tracker节点,多个节点配置一样 #cd /etc/fdfs
#cp tracker.conf.sample tracker.conf #vim tracker.conf
disabled=false # 启用配置文件 port=22122# tracker服务器端口(默认22122) base_path=/fastdfs/tracker # 存储日志和数据的根目录
其它设置保持默认即可 #参数详解http://bbs.chinaunix.net/thread-1941456-1-1.html #mkdir –p /fastdfs/tracker
#fdfs_trackerd /etc/fdfs/tracker.conf #启动tracker服务
#iptables –I INPUT –p tcp –dport 22122 –j ACCEPT #开放iptables端口 #cp /usr/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ #vim /etc/fdfs/mod_fastdfs.conf
tracker_server=192.168.100.124:22122 tracker_server=192.168.100.128:22122
注:#iptables –I INPUT –s 192.168.100.130 –d 192.168.100.124 –p tcp –dport 22122 –j ACCEPT #指定源跟目标IP,只有对应的IP才能访问
6、配置storage节点,多个节点配置一样 #cd /etc/fdfs
#cp storage.conf.sample storage.conf #vim storage.conf
disabled=false # 启用配置文件 port=23000# storage服务端口
group_name=group1 # 组名(第一组为group1,第二组为group2,依次类推...) base_path=/fastdfs/storage# 数据和日志文件存储根目录
store_path0=/fastdfs/storage# 第一个存储目录,第二个存储目录起名为:store_path1=xxx,其它存储目录名依次类推...