码迷,mamicode.com
首页 > 其他好文 > 详细

FastDFS安装配置

时间:2016-04-07 18:43:30      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:fastdfs

Tracker server: 10.2.84.200

Storage server: 10.2.84.202 10.2.84.204


一、安装部署

1.配置tracker server、storage server

# unzip libfastcommon-master.zip

# cd libfastcommon-master

# ./make.sh

# ./make.sh install

Libfastcommon.so安装到了/usr/lib64/libfastcommon.so,但是FastDFS主程序设置的lib目录是/usr/local/lib,所以需要创建软链接

# ln -s /usr/lib64/libfastcommon.so /usr/local/bin/libfastcommon.so

# ln -s /data/usr/lib64/libfdfsclient.so /usr/local/bin/libfdfsclient.so

# ln -s /data/usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so 


# tar zxvf FastDFS_v5.05.tar.gz

# cd FastDFS

# vim make.sh

    DESTDIR=/data

# ./make.sh

# ./make.sh install

创建存储目录

# mkdir -pv /data/fastdfs

二、修改配置tracker server端文件

# cd /data/etc/fdfs/

# cp client.conf.sample client.conf

# cp tracker.conf.sample tracker.conf

# vim tracker.conf

    bind_addr=10.2.84.200

    base_path=/data/fastdfs

# vim client.conf

    base_path=/data/fastdfs

    tracker_server=10.2.84.200:22122

启动:

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

三、修改storage server端文件

# cd /data/etc/fdfs/

# cp client.conf.sample client.conf

# cp storage.conf.sample storage.conf

# vim storage.conf

    bind_addr=10.2.84.202

    base_path=/data/fastdfs

    store_path0=/data/fastdfs

tracker_server=10.2.84.200:22122

# vim client.conf

    base_path=/data/fastdfs

    tracker_server=10.2.84.200:22122

启动:

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

四、在storage server上安装ngxin、fastdfs-nginx-module

FastDFS通过Tracker服务器,将文件放在Storage服务器存储,但是同组之间的服务器需要复制文件,有延迟的问题.假设Tracker服务器将文件上传到了10.2.84.202,文件ID已经返回客户端,

这时,后台会将这个文件复制到10.2.84.204,如果复制没有完成,客户端就用这个ID在10.2.84.204取文件,肯定会出现错误

这个fastdfs-nginx-module可以重定向连接到源服务器取文件,避免客户端由于复制延迟的问题,出现错误。


# mkdir -pv /data/nginx/

# mv fastdfs-nginx-module /soft/nginx/

# tar /root/zxvf fastdfs-nginx-module_v1.16.tar.gz

# cd fastdfs-nginx-module

# vim src/config

    CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"

修改为:其实就是去掉/local目录

    CORE_INCS="$CORE_INCS /data/usr/include/fastdfs /usr/include/fastcommon/"


# yum install -y pcre-devel openssl-devel

# tar zxvf /root/nginx-1.9.12.tar.gz

# cd /root/nginx-1.9.12

# ./configure --prefix=/soft/nginx --conf-path=/soft/nginx/conf/nginx.conf --with-select_module --with-poll_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_stub_status_module --with-http_auth_request_module --add-module=/soft/nginx/fastdfs-nginx-module/src

# make

# make install

# cp /soft/nginx/fastdfs-nginx-module/src/mod_fastdfs.conf /data/etc/fdfs/

# vim /data/etc/fdfs/mod_fastdfs.conf

    base_path=/data/fastdfs

    tracker_server=10.2.84.200:22122

    url_have_group_name = true

    store_path0=/data/fastdfs

# cp /root/FastDFS/conf/http.conf /data/etc/fdfs/

# cp /root/FastDFS/conf/mime.types /data/etc/fdfs/

# vim /data/etc/fdfs/http.conf

http.anti_steal.token_check_fail=/data/fastdfs/conf/anti-steal.jpg

# vim /soft/nginx/conf/nginx.conf

 location /M00 {

            root /data/fastdfs;

            ngx_fastdfs_module;

        }

# ln -s /data/fastdfs/data /data/fastdfs/M00


# vim /etc/ld.so.conf

/usr/local/lib

# /sbin/ldconfig

# /soft/nginx/sbin/nginx -t

# /soft/nginx/sbin/nginx


关闭:

# /data/usr/bin/stop.sh /data/etc/fdfs/storage.conf

开启:

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

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


测试上传:

# /data/usr/bin/fdfs_upload_file /data/etc/fdfs/client.conf /root/a.txt



FastDFS安装配置

标签:fastdfs

原文地址:http://ngames.blog.51cto.com/3187187/1761387

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!