环境:单机 版本:v5.04 看起来代码重构了下,目录更规范了。 下载地址: http://sourceforge.net/projects/fastdfs/files/ 另外github地址:https://github.com/happyfish100/fastdfs 安装可以参考压缩包内的INSTALL文件。

所用软件: FastDFS_v5.04.tar.gz libfastcommon-master.zip fastdfs-nginx-module_v1.16.tar.gz nginx-1.6.2.tar.gz

与之前版本不同的是,v5.04首先需要安装libfastcommon 下载地址: https://github.com/happyfish100/libfastcommon.git

1.安装libfastcommon 在每一台服务器上,解压libfastcommon,进入libfastcommon-master目录执行 ./make.sh ./make.sh install

2.安装FastDFS 解压缩FastDFS_v5.04.tar.gz,进入FastDFS目录 执行 ./make.sh ./make.sh install

3.配置 配置文件在 /etc/fdfs/目录或者源码目录的conf下面 配置Tracker服务器
mv /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf cd /etc/fdfs/ 更改配置文件的base_path,这里改到/export/fastdfs下面。 sed -i ’s#/home/yuqing#/export#g’ *.conf 启动: fdfs_trackerd /etc/fdfs/tracker.conf

配置Storage服务器 主要改下以下几项 vim /etc/fdfs/storage.conf group_name=g1 base_path=/export/fastdfs store_path0=/export/fastdfs tracker_server=yourip:22122 启动: fdfs_storaged /etc/fdfs/storage.conf

测试,配置文件/etc/fdfs/client.conf 路径及tracker_server 上传图片: [root@ccj-sf fdfs]# fdfs_upload_file /etc/fdfs/client.conf /root/q.png g1/M00/00/00/aIOW-1RWILeADL_hAACfjC0jGBg627.png

3.解压fastdfs-nginx-module

修改fastdfs-nginx-module的config文件(因为fastcommon的一些include文件安装到 /usr/include/fastcommon下了) 原来的内容是 ``` CORE_INCS=“$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/”

vim /home/nginx/fastdfs-nginx-module/src/config,修改为 CORE_INCS=“$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon” ``` 各个版本的位置并不统一.所以需要根据自己的版本修改位置。

4.安装nginx 一些依赖包,如安装过可忽略。 yum -y install gcc automake autoconf libtool make gcc-c++ pcre* zlib openssl openssl-devel

添加fastdfs-nginx-module模块 ``` [root@ccj-sf dl]# cd nginx-1.6.2 [root@ccj-sf nginx-1.6.2]# ./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_gzip_static_module –with-ipv6 –add-module=../fastdfs-nginx-module/src

make -j cat /proc/cpuinfo | grep processor| wc -l && make install 复制fastdfs-nginx-module源码中的配置文件到/etc/fdfs cp /home/nginx/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs 修改该配置文件 group_name=group1 tracker_server=yourip:22122 store_path0=/export/fastdfs base_path=/export/fastdfs ``` 复制FastDFS的配置到/etc/fdfs

修改Nginx配置文件 location /M00 { root /export/fastdfs/data; ngx_fastdfs_module; } 上传文件测试: ``` [root@ccj-sf conf]# fdfs_test /etc/fdfs/client.conf upload /root/Jellyfish.jpg This is FastDFS client test program v5.04

Copyright © 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General Public License V3, which may be found in the FastDFS source kit. Please visit the FastDFS Home Page http://www.csource.org/ for more detail.

[2014-11-02 22:43:55] DEBUG - base_path=/export/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group: server 1. group_name=, ip_addr=x.x.x.x, port=23000

group_name=g1, ip_addr=x.x.x.x, port=23000 storage_upload_by_filename group_name=g1, remote_filename=M00/00/00/aIOW-1RWQyuAfSjjAAvWFkcZHjA219.jpg source ip address: x.x.x.x file timestamp=2014-11-02 22:43:55 file size=775702 file crc32=1192828464 example file url: http://x.x.x.x/g1/M00/00/00/aIOW-1RWQyuAfSjjAAvWFkcZHjA219.jpg storage_upload_slave_by_filename group_name=g1, remote_filename=M00/00/00/aIOW-1RWQyuAfSjjAAvWFkcZHjA219_big.jpg source ip address: x.x.x.x file timestamp=2014-11-02 22:43:55 file size=775702 file crc32=1192828464 example file url: http://x.x.x.x/g1/M00/00/00/aIOW-1RWQyuAfSjjAAvWFkcZHjA219_big.jpg ``` 实际环境中配置的是域名,并且group_name默认也是false的,这里的 group_name应该去掉的。 http://img.jiuduoyun.com/M00/00/00/aIOW-1RWQyuAfSjjAAvWFkcZHjA219_big.jpg

0 回复
需要 登录 后方可回复, 如果你还没有账号你可以 注册 一个帐号。