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

分布式文件系统fastDFS部署

时间:2017-05-01 21:04:02      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:fastdfs;分布式文件系统

一、部署环境:(CentOS 6.9)

    tracker server:10.10.1.105

    storage server:10.10.1.106  10.10.1.107

    client:10.10.1.105


二、FastDFS: 开源的轻量级分布式文件系统;

    三个角色:

    tracker server :跟踪服务器,调度,在内存中记录所有存储组和存储服务器的状态信息; tracker.conf

    storage server :存储服务器,文件(data)和文件属性(metadata),一组服务器; storage.conf

    client :客户端,业务请求发起方,通过专用接口基于TCP协议与tracker以及storage server进行交互;client.conf

    

    存储:

    group_name/M##/&&/&&/file_name

    group_name :存储组的组名;上传完成后,需要客户端自行保存;

    M## :服务器配置的虚拟路径,与磁盘选项store_path#对应;

    两级以两位16进制数字名字的目录;

    文件名:与原文件名并不相同;由storage server根据特定信息生成,文件名包含:源存储服务器的IP地址、文件创建时间戳、文件大小、随机数和文件扩展名等;


三、安装

    1、安装依赖包libfastcommon

    2、安装fastDFS

    3、需要关闭iptables、selinux

    安装方式一:

    # git clone https://github.com/happyfish100/fastdfs.git

    # git clone https://github.com/happyfish100/libfastcommon.git

    # git clone https://github.com/happyfish100/fastdfs-nginx-module.git

    

    mv libfastcommon libfastcommon-1.0.36

    tar zcf libfastcommon-1.0.36.tar.gz libfastcommon-1.0.36

     

    mv fastdfs fastdfs-5.0.10

    tar zcf fastdfs-5.0.10.tar.gz fastdfs-5.0.10

    

    mkdir rpmbuild/{SOURCES,SPECS} -pv

    cp /tools/libfastcommon-1.0.36.tar.gz rpmbuild/SOURCES/

    cp /tools/fastdfs-5.0.10.tar.gz rpmbuild/SOURCES/

    

    cp /tools/libfastcommon-1.0.36/libfastcommon.spec rpmbuild/SPECS/

    cp /tools/fastdfs-5.0.10/fastdfs.spec rpmbuild/SPECS/

    

    yum install rpm-build

    rpmbuild -ba libfastcommon.spec 

    rpmbuild -ba fastdfs.spec 

    生成rpm包直接安装即可

    安装方式二:

    tar xzf libfastcommon_v1.23.tar.gz

    cd libfastcommon

    ./make.sh

    ./make.sh install

    

    tar xzf FastDFS_v5.08.tar.gz

    cd FastDFS

    ./make.sh

    ./make.sh install

    

    tracker和storage配置完成后测试上传:

    

    # fdfs_upload_file ./client.conf /usr/share/backgrounds/centos_2048x1536_logoonly.jpg

    group1/M00/00/00/CgoBalkG2PmAThTWAAD_7aV8rDY985.jpg

    

四、安装fastdfs-nginx-module模块,通过http协议访问文件

    注:以下两个文件需要复制到storage的目录

    cp fastdfs-5.0.10/conf/{http.conf,mime.types}   /etc/fdfs/

    

    安装此模块需要重新编译nginx

    1、./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module  --with-http_gzip_static_module --with-http_sub_module --add-module=/root/soft/fastdfs-nginx-module/src

    

    2、nginx.conf 文件加入以下配置

            location ~ /group[0-9]+/M00 {

                root /home/fastdfs/data;

                ngx_fastdfs_module;

            }

    3、ln -s /home/fastdfs/data  /home/fastdfs/data/M00

    

    4、配置mod_fastdfs.conf文件

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

    

    mod_fastdfs.conf重点配置项:

    tracker_server=10.10.1.105:22122

    url_have_group_name = true   ***开启组名访问

    

    group_count = 1

    [group1]

    group_name=group1

    storage_server_port=23000

    store_path_count=1

    store_path0=/home/fastdfs

    

    5、重载nginx服务器

    

    以组名访问时:

            location ~ /group[0-9]+/M00 {

                root /home/fastdfs/data;

                ngx_fastdfs_module;

            }

    http://10.10.1.106/group1/M00/00/00/CgoBalj9wqaAeNaJAA44dR-dxTs490.jpg

    

本文出自 “轻歌墨染” 博客,转载请与作者联系!

分布式文件系统fastDFS部署

标签:fastdfs;分布式文件系统

原文地址:http://hongxuan.blog.51cto.com/4514606/1920962

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