温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

分布式文件系统fastDFS部署

发布时间:2020-07-21 21:04:23 来源:网络 阅读:984 作者:轻歌墨染 栏目:建站服务器

一、部署环境:(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/happyfish200/fastdfs.git

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

    # git clone https://github.com/happyfish200/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;

            }

    https://cache.yisu.com/upload/information/20200309/32/49826.jpg

    

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI