linux搭建分布式文件系统FastDFS并整合spring boot

本文详细介绍了如何在Linux CentOS系统中安装和配置分布式文件系统FastDFS,并将其与Spring Boot应用程序集成,以实现文件上传和下载功能。内容包括FastDFS的角色解析、安装步骤、配置Tracker和Storage节点、Spring Boot的集成方法以及FastDFS通过Nginx提供外部访问的配置。此外,还提到了在配置过程中可能遇到的问题及解决方案。
摘要由CSDN通过智能技术生成

linux搭建分布式文件系统FastDFS并整合spring boot

目录

  • FastDFS是什么
  • FastDFS安装
  • spring boot集成FastDFS上传下载文件
  • FastDFS配置nginx
  • 问题&注意事项

FastDFS是什么:

是由C语言实现的开源轻量级分布式文件系统,实现了对文件管理,同步,访问,下载等功能,解决了大容量存储和负载均衡。其包含两个角色:Tracker(跟踪器)和Storage(存储节点)

  • Tracker:资源调度,负载均衡,管理所有的group和storage,每一个storage启动就会链接Tracker
  • Storage:存储节点,提供存储和备份服务,以group为单位,每组可以有多台Storage,数据互相备份。

    官网架构图:
    

    架构图

FastDFS安装

多台服务器都需要安装FastDFS,为了方便测试单机安装也可以,配置相差不多。本次环境centos,如果安装过程中出现问题翻到最后查看注意事项可能会找到解决方法。

  • 下载安装libfastcommon:

    cd /opt/fastdfs
    
    wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
    
    tar -zxvf V1.0.7.tar.gz
    
    cd libfastcommon-1.0.7
    
    ./make.sh
    
    //安装:
    ./make.sh install
    
    //设置软连接:
    ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
    ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
    ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
    ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
    
  • 下载安装FastDFS,每台文件服务器都需要安装:

    wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
    
    tar -zxvf V5.05.tar.gz
    
    cd fastdfs-5.05
    
    ./make.sh
    
    ./make.sh install
    

    安装成功后会在/etc/fdfs 目录下生成三个示例配置文件

  • 配置Tracker服务器

    cp tracker.conf.sample tracker.conf
    
    //创建文件夹留后用
    mkdir -p /data/fastdfs/tracker
    
    vim tracker.conf
    

    编辑tracker.conf配置文件,修改:

    # the base path to store data and log files
    base_path=/data/fastdfs/tracker     
    
    http.server_port=8055
    

    保存退出,启动tracker服务:

    fdfs_trackerd /etc/fdfs/tracker.conf start
    

    启动成功,查看监听服务:

    netstat -unltp|grep fdfs
    

    可以看到tracker默认端口为22122,并且在/data/fastdfs/tracker文件夹下新增数据和日志存储文件。

  • 配置Storage服务器:

    cd /etc/fdfs
    
    cp storage.conf.sample storage.conf
    
    mkdir -p /data/fastdfs/storage
    
    vim storage.conf
    

    修改storage.conf配置文件:

    # the base path to store data and log files
    base_path=/data/fastdfs/storage
    
    # store_path#, based 0, if store_path0 not exists, it's value is base_path
    # the paths must be exist
    store_path0=/data/fastdfs/storage
    
    # tracker_server can ocur more than once, and tracker_server format is
    #  "host:port", host can be hostname or ip address
    #配置tracker跟踪器ip端口
    tracker_server=192.168.5.26:22122
    

    保存退出,并启动Storage:

    fdfs_storaged /etc/fdfs/storage.conf start
    

    如果启动过慢或卡死,查看日志文件:

    /data/fastdfs/storage/logs
    

    查看端口监听,发现Storage默认端口号为23000

    netstat -unltp|grep fdfs
    

    所有节点都安装成功后可以在任意一个节点查看集群的状态:

    /usr/bin/fdfs_monitor /etc/fdfs/s
  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值