zoukankan      html  css  js  c++  java
  • FastDFS+Nginx安装配置

    下载相关包:

    libevent-2.0.22-stable.tar.gz =》 https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz

    https://sourceforge.net 下载相应的FASTDFS文件:

    fastdfs_client_java._v1.25.tar.gz

    fastdfs-nginx-module_v1.16.tar.gz

    FastDFS_v5.08.tar.gz

    nginx-1.11.6.tar.gz

    libfastcommon-master =》https://github.com/happyfish100/libfastcommon/archive/master.zip

    拓扑图

    1.解压安装

    a. libevent:

    rpm -e --nodepes `rpm -qa | grep libevent
    cd libevent1.4.14b
    ./configure --prefix=/usr 
    make clean
    make
    make install

    2.FastDFS_v5.08

    cd FastDFS
    ./make.sh  
    ./make.sh install  

    有报错信息

    compilation terminated.

    make: *** [../common/fdfs_global.o] Error 1

    需要安装 libfastcommon-master

    3. libfastcommon-master

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

    然后继续安装FASTDFS

    配置fastdfs:

    配置tracker:

    # cd /etc/fdfs/ # cp tracker.conf.sample tracker.conf 修改配置文件 disabled=false #启用配置文件 port=22122 #设置tracker的端口号 base_path=/data/fastdfs/trackerd #设置tracker的数据文件和日志目录(需预先创建) http.server_port=8090 #设置http端口号

    启动:

       # mkdir -p /data/fastdfs/trackerd

       # fdfs_trackerd /etc/fdfs/tracker.conf #启动

       # /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

    设置开机启动

    # echo '/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart' >> /etc/rc.d/rc.local

    配置storage:

    1.安装 与tracker 安装步骤相同

    disabled=false            #启用配置文件

    group_name=group1        #组名,根据实际情况修改

    port=23000                #设置storage的端口号

    base_path=/data/fastdfs/storage  #设置storage的日志目录(需预先创建)

    store_path_count=1        #存储路径个数,需要和store_path个数匹配

    store_path0=/data/fastdfs/storage  #存储路径

    tracker_server=172.16.8.8:22122 #tracker服务器的IP地址和端口号

    http.server_port=8090    #设置http端口号

    启动

    # mkdir -p /data/fastdfs/storage

    # /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

    设置开机启动

    # echo '/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart' >> /etc/rc.d/rc.local

    查看状态

    /usr/bin/fdfs_monitor /etc/fdfs/storage.conf

    # netstat -antp | grep storage


    上传测试(配置Client,client.conf)

    cp client.conf.sample client.conf
    base_path=/home/yuqing/fastdfs-> base_path=/data/fastdfs_tracker  
    tracker_server=192.168.209.121:22122 -> tracker_server=172.16.8.8:22122
    http.tracker_server_port=8080 ->http.tracker_server_port=8090

    然后测试上传

    fdfs_test /etc/fdfs/client.conf upload a.jpg
    /usr/bin/fdfs_upload_file /etc/fdfs/client.conf

    4. 安装Nginx

    cd useradd -r nginx
    useradd -r nginx
    ./configure --prefix=/usr/local/nginx --add-module=/data/fastdfs-nginx-module/src
    make
    make install

    NOTE:

    安装Nginx时报错

    ./configure: error: the HTTP rewrite module requires the PCRE library.

    安装pcre-devel解决问题
    yum -y install pcre-devel

    错误提示:./configure: error: the HTTP cache module requires md5 functions
    from OpenSSL library.   You can either disable the module by using
    --without-http-cache option, or install the OpenSSL library into the system,
    or build the OpenSSL library statically from the source with nginx by using
    --with-http_ssl_module --with-openssl=<path> options.

    解决办法:

    yum -y install openssl openssl-devel

    总结:

    yum -y install pcre-devel openssl openssl-devel

    ./configure --prefix=/usr/local/nginx

    make

    make install

    一切搞定




    Note:
    /usr/local/src/fastdfs-nginx-module/src/common.c:21:25: 错误:fdfs_define.h:没有那个文件或目录


    [root@server1 src]# cp -rf /usr/include/fast* /usr/local/include/
    [root@server1 src]# ls /usr/local/include/
    fastcommon  fastdfs
    然后再次编译Nginx

    配置:
    vim /usr/local/nginx/conf/nginx.conf
    location ~ /group[1-3]/M00 {
                root /data/fastdfs/storage/data;
                ngx_fastdfs_module;
            }
    /data/fastdfs/storage/data 这个是指向 真正存储文件的地方

       建立 M00 至存储目录的符号连接

    [root@server1 fdfs]# ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/M00
    [root@server1 fdfs]# ll /data/fastdfs/storage/data/M00


    配置mod_fastDfs.config:
    base_path=/data/fastdfs/storage      #保存日志目录
    tracker_server=10.10.10.124: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    #存储路径
    http.need_find_content_type=true     # 从文件 扩展 名查 找 文件 类型 ( nginx 时 为true)
    group_count = 1                      #设置组的个数
     启动存储服务器上的nginx时确报了下面的错误:
    ngx_http_fastdfs_process_init pid=17609
    [2014-12-10 11:52:07] ERROR - file: ini_file_reader.c, line: 315, include file "http.conf" not exists, line: "#include http.conf"

    解决方案:
    FDFS安装包的conf目录下,有几个配置文件,把http.conf,mime.types,拷贝到/etc/fdfs/下,http.conf里有
    个配置应该是token验证的功能,如果你要打开,应该把路径配置正确


    测试:

    [root@mobancentos70 data]# fdfs_upload_file /etc/fdfs/client.conf 1.png
    group1/M00/00/00/rBQN5lhI0VeAOOWNAAVg32hqxR4098.png

    http://172.20.13.230/group1/M00/00/00/rBQN5lhI0VeAOOWNAAVg32hqxR4098.png

    附录:

    在整个环境搭建过程中遇到一些问题,在此提交分享,供大家参考。

    1、 在Storage服务器上启动Nginx时出现 ERROR - file: /home/hadoop/dev/fastdfs/fastdfs-nginx-module/src/common.c, line: 103, section: group1, you must set parameter: group_name!

    问题原因:在配置mod_fastdfs.conf文件时要保证group_count=2的个数与下面配置的[group*]个数相一致。

    2、 安装GraphicsMagick进行配置时出现错误 configure: error: libltdl is required by modules build 问题原因:没有安装libltdl,通过yum install

    -ylibtoollibtool-devel安装后再重新

    3、 java客户端上传文件时出现错误 recvcmd: 100 is not correct, expect cmd: 10

    问题原因:版本问题,下载1.24版本的即可。

    4、 通过浏览器方式缩略图是出现

    gm convert: Request did not return an image.错误。

    问题原因:没有安装libjpeg和libpng包,导致在GM处理图时出现错误。安装libjpeg和libpng后重新安装GraphicsMagick即可。

    5、 安装FastDFS在 编译时出现

    /usr/local/lib/libfastcommon.so: undefined reference

    to sqrt' /usr/local/lib/libfastcommon.so: undefined reference

    tocos'错误

    问题原因:libfastcommon版本的问题,下载旧版本,重新安装,然后在编译FastDFS即可。

  • 相关阅读:
    Kafka官方文档翻译——实现
    什么是分布式消息中间件?
    Kafka官方文档翻译——设计
    Kafka官方文档翻译——简介
    Zore copy(翻译《Efficient data transfer through zero copy》)
    Netty轻量级对象池实现分析
    记一次查内存异常问题(续《记一次Web应用CPU偏高》)
    记一次Web应用CPU偏高
    Hive DDL DML SQL操作
    Memcache入门
  • 原文地址:https://www.cnblogs.com/owenma/p/6144216.html
Copyright © 2011-2022 走看看