fast dfs 和 nginx 的集成

安装了fast dfs, tracker 和 storage 在一台机器上,只有一个group, 名字叫group1.

下载了fastdfs-nginx-module.tar.gz, 解压缩后按照其中的INSTALL文档安装,需注意以下几点:

  1. 如果以前安装了nginx则需要重新安装,我是yum安装的,卸载了重新下载nginx安装

  2. 需要拷贝mod_fastdfs.conf到/etc/fdfs下,然后修改其中的配置项

    2.1. 先摘抄一段其他贴在看到的话:“Nginx服务器是安装在Storeage服务器上的,也就是说,一般情况下它只提供对本Storeage服务器上的资源提供服务。只有在本机并没有需要获取的资源的情况下,才会进行特殊的处理。当同组内其他Storeage新上传的图片本机并没有及时同步的时候,Nginx会根据url寻找上传的Storeage源服务器,进行redirect或者proxy两种方式之一的转发”

    2.2 配置项需要注意:
    
     group_count = 0 和
     url_have_group_name = false  --访问路径带group时为true否则为false,多个group的情况下,必须为true,为false时,group_count必须为0
    


     storage只有一个group的情况:
  
   group=group1                           --storage对应的group
   store_path0=/webapp/fastdfs/storage        --storage存储路径
   group_count = 0
   


      storage对应有多个group的情况:
  
   url_have_group_name = true      --必须设置为true才能支持多个group
   group_count = 2                 --storage的group个数
   

       
     我一开始将url_have_group_name设置为true,group_count为0, 这样设置使我遇到了两个错:

   错误1: 我的nginx 配置是
       
        location /M00 {
            root /data/fastdfs/storage/data;
            ngx_fastdfs_module;
        }
        

     当我访问路径是http://192.168.88.203/group1/M00/F1/8B/wKhYy1MmbKaAJ5UPAAAAFBub64E395_big.txt(路径带group name)
      出现404错误, 查看nginx日志,应该改请求没有和/M00匹配而拦截,

    错误2:然后我去掉了group name,访问http://192.168.88.203/M00/F1/8B/wKhYy1MmbKaAJ5UPAAAAFBub64E395_big.txt
    错误如下
   
    2014/03/17 14:25:25 [error] 30887#0: *1 upstream timed out (110: Connection timed out) while connecting to upstream, client: 192.168.88.109, server: localhost, request: "GET /M00/0A/85/wKhYy1MhtUiAYqeHAAIIrIDdTuc1_big.1.jar HTTP/1.1", upstream: "http://203.83.33.181:80/M00/0A/85/wKhYy1MhtUiAYqeHAAIIrIDdTuc1_big.1.jar?redirect=1", host: "192.168.88.203"
    

    这个问题不知道什么原因,我以后解决吧,我并没有203.83.33.181这个地址。
修改配置group_count = 0 和 url_have_group_name = false, 使用http://192.168.88.203/M00/F1/8B/wKhYy1MmbKaAJ5UPAAAAFBub64E395_big.txt访问成功
     
   

   

猜你喜欢

转载自jingtao416.iteye.com/blog/2032369