ubuntu16.04安装FastDFS-5.08

 fastdfs github地址: https://github.com/happyfish100/

1.FastDFS上传原理
 - storage定时向tracker上传状态信息
 - client上传连接请求到tracker
 - tracker查询可用的storage,并返回storage的ip和端口
 - 上传文件fIlecontent和meta data
 - 生成file_id,将上传的内容写入磁盘,并返回file_id路径和文件名

安装之前先安装所需要的插件

 libevent   

 http://libevent.org/   下载 libevent-2.0.22-stable.tar

 libfastcommon 

 https://github.com/happyfish100/libfastcommon.git   下载libfastcommon

 fastdfs 

 https://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/FastDFS%20Server%20with%20PHP%20Extension%20Source%20Code%20V5.08/    下载 fastdfs 

一.安装libevent

  解压;tar  -zxvf  libevent-2.0.22-stable.tar.gz
  进入目录;
  ./configure --prefix=/usr         配置目录
  make 
  make install
  验证   ls -al /usr/lib |grep libevent

二.安装libfastcommon

  unzip libfastcommon-master.zip
  cd  libfastcommon-master 
  ./make.sh
  ./make.sh install

三.安装fastdfs
  解压 tar  -zxvf  FastDFS.tar.gz
  cd FastDFS
  ./make.sh
  ./make.sh install

四.配置 tracker.conf
  cd /etc/fdfs/
  cp tracker.conf.sample tracker.conf
  vi tracker.conf
  base_path=/data/fastdfs/tracker #设置 tracker 的数据文件和日志目录(需预先创建) mkdir -p      /home/fastdfs/tracker 
  store_group=group1   #修改组名

五. 配置 storage.conf
  cp storage.conf.sample storage.conf
  vi storage.conf
  group_name=group1                                          #组名,根据实际情况修改
  base_path=/home/fastdfs/storage          #设置 storage 的日志目录(需预先创建)mkdir -p  /home/fastdfs/storage 
  store_path_count=1                       #存储路径个数,需要和 store_path 个数匹配
  store_path0=/home/fastdfs/storage/datas          #存储路径(需预先创建)mkdir -p  /home/fastdfs/storage/datas
  tracker_server=10.10.10.81:22122                     #tracker 服务器的 IP 地址和端口号
六.配置 client.conf 
  cp client.conf.sample client.conf
  vi client.conf
  base_path=/data/fastdfs/fdfs_client        # 日志路径
  tracker_server=172.16.1.40:22122         # 追踪服务器的IP,有多个服务器可以另一行

启动

启动 fdfs_trackerd /etc/fdfs/tracker.conf
启动 fdfs_storaged /etc/fdfs/storage.conf

重启
[root@fedora15 user]#/usr/local/bin/restart.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
[root@fedora15 user]#/usr/local/bin/restart.sh/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

停止
直接kill即可让server进程正常退出,可以使用killall命令,例如: 
killall fdfs_trackerd 
killall fdfs_storaged 

测试上传
fdfs_upload_file /etc/fdfs/client.conf /etc/a.jpg

七:安装fastdfs-nginx-module(安装之前已经安装好nginx。地址:nginx源码安装

   下载 fastdfs-nginx-module_v1.16.tar.gz

   地址:https://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/ 

   解压   tar -zxvf  fastdfs-nginx-module_v1.16.tar.gz  
   1. 修改文件 xx/fastdfs-nginx-module_v1.16/src/config, 去除CORE_INCS 中的local , 因为fastdfs 和  fastcommon 在/usr/include
   2.  进入nginx 源码目录:cd  /home/mirror/software/java/nginx/nginx-1.11.2
   3. 执行命令:./configure --add-module=/home/mirror/software/java/nginx/fastdfs-nginx-module/src
   4. 执行命令:  make
   5. 执行命令:  make install
八. fastdfs里nginx配置文件
   cd /usr/local/src/fastdfs-nginx-module/src
   cp mod_fastdfs.conf /etc/fdfs
   cd /usr/local/src/FastDFS/conf/
   cp anti-steal.jpg http.conf mime.types /etc/fdfs


九. 配置mod_fastdfs.conf,配置文件加入
  cd /etc/fdfs/
  vim mod_fastdfs.conf
  base_path=/home/fastdfs/storage      #保存日志目录
  tracker_server=10.10.10.80:22122     #tracker 服务器的 IP 地址以及端口号
  storage_server_port=23000            #storage服务器的端口号
  group_name=group1                    #当前服务器的group名
  url_have_group_name = true           #文件url中是否有group 名
  store_path_count=1                   #存储路径个数,需要和store_path 个数匹配
  store_path0=/data/fastdfs/storage    #存储路径
  group_count = 1                      #设置组的个数
  #然后在末尾添加分组信息,目前只有一个分组,就只写一个
  [group1]
  group_name=G1
  storage_server_port=23000
  store_path_count=1
  store_path0=/data/fastdfs/storage


十.nginx配置文件加入


 location ~ /group[1-3]/M00 {
                root /data2/;
                ngx_fastdfs_module;
      }


启动nginx  /usr/local/nginx/sbin/nginx


参考资料 :
      http://fredlong.iteye.com/blog/2288039    
      https://www.cnblogs.com/sunmmi/p/5798803.html
      http://www.cnblogs.com/sunmmi/articles/5799692.html

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值