Fastdfs 部署與使用


Fastdfs 介紹

Fastdfs 是一款流行的分布式文件系統,具有文件自動同步,防止單點故障等特性,官網地址:https://github.com/happyfish100/fastdfs

部署

采用 Docker 部署,使用官網提供的 Docker 文件稍加修改,截止 2021-11-09 日,在 github 官網項目中可以看見兩套部署方案,一套 local 和一套 network,local 就是將一些會提前用到的包下載到本地,防止國內訪問 dockerhub 網絡不好的情況,但是經過實際測試,這個方案會有問題,於是直接采用 network 方式:https://github.com/happyfish100/fastdfs/tree/master/docker/dockerfile_network

啟動 tracker

使用命令 fdfs_trackerd /etc/fdfs/tracker.conf restart 啟動 tracker

查看日志文件 cat /root/fastdfs/logs/trackerd.log 顯示 [2021-11-09 04:24:55] INFO - FastDFS v6.07, base_path=/home/dfs, ... 表示啟動成功

啟動 storage

使用命令 fdfs_storaged /etc/fdfs/storage.conf restart 啟動 storage

查看日志文件 cat /root/fastdfs/logs/storaged.log 顯示 [2021-11-09 04:24:55] INFO - FastDFS v6.07, base_path=/home/dfs, ... 表示啟動成功

服務啟動后進入容器內部,輸入命令 fdfs_monitor /etc/fdfs/storage.conf,可以查看 storage 是否已注冊到 tracker

Nat 網絡

大多數情況下 storage 是部署在內網當中,當其向 tracker 注冊時,tracker 拿到的只是 storage 的內網 ip,此時需要使用雙 ip 模式部署,參考 https://www.jianshu.com/p/b16922f71375#_Toc18054 中的 “Storage server服務器雙IP設置”

實際分離部署

官網的 docker 配置是把 trackerstoragenginx 通過 Dockerfile 打包在一起,我將 trackerstorage、nginx 分離成了兩個包,並且將配置文件也獨立出來,按照我的習慣,使用 docker-compose 配合 volumes 映射配置文件進行部署。tracker 地址 fengrui358/fastdfs_trackerstorage 地址 fengrui358/fastdfs_storage。配置文件以 github 官網為基礎修改,放在 conf 目錄下。

tracker docker compose config:

fastdfs_tracker:
    image: 'fengrui358/fastdfs_tracker'
    container_name: fastdfs_tracker
    restart: always
    networks:
        - "fastdfs_network"
    ports:
        - "22122:22122" # tracker_server
    volumes:
        - ./conf:/etc/fdfs # 配置
        - ./data:/home/dfs # 數據

storage docker compose config:

fastdfs_storage:
    image: 'fengrui358/fastdfs_storage'
    container_name: fastdfs_storage
    restart: always
    networks:
        - "fastdfs_network"
    ports:
        - "23000:23000" # stoage_server
        - "8011:80" #nginx web
    volumes:
        - ./conf:/etc/fdfs # 配置
        - ./data:/home/dfs # 數據
        - ./conf:/usr/local/nginx/conf # nginx 配置

客戶端測試

使用了一個 Dotnet 客戶端進行測試,https://github.com/caozhiyuan/FastDFSNetCore

參考:

http://www.ityouknow.com/fastdfs/2017/10/10/cluster-building-fastdfs.html
https://www.jianshu.com/p/b16922f71375#_Toc18054

原文地址:https://frhello.com/fastdfs-部署與使用/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM