fastdfs搭建docker

  一、fastdfs國產分佈式文件存儲。FastDFS是一個開源的輕量級分佈式文件系統,它對文件進行管理,功能包括:文件存儲、文件同步、文件訪問(文件上傳、文件下載)等,解決了大容量存儲和負載均衡的問題。特別適合以文件爲載體的在線服務,如相冊網站、視頻網站等等。

  二、搭建

version: "2"
services:
  fastdfs-tracker:
    image: season/fastdfs:1.2
    container_name: fastdfs-tracker
    restart: always
    privileged: true
    ports:
      - 22122:22122
    environment:
      - TZ=Asia/Shanghai
    volumes:
      - /fastdfs/tracker:/fastdfs/tracker
    command: "tracker"

  fastdfs-storage:
    image: season/fastdfs:1.2
    container_name: fastdfs-storage
    restart: always
    privileged: true
    ports:
      - 23000:23000
    environment:
      - TZ=Asia/Shanghai
      - GROUP_NAME=group1
      - TRACKER_SERVER=172.17.230.10:22122
    volumes:
      - /fastdfs/storage/data:/fastdfs/storage/data
      - /fastdfs/store_path:/fastdfs/store_path
    command: "storage"
    depends_on:
      - fastdfs-tracker

  fastdfs-nginx:
    image: season/fastdfs:1.2
    container_name: fastdfs-nginx
    restart: always
    privileged: true
    ports:
      - 8888:8888
    environment:
      - TZ=Asia/Shanghai
      - TRACKER_SERVER=172.17.230.10:22122
    volumes:
      - ./nginx.conf:/etc/nginx/conf/nginx.conf
      - /fastdfs/store_path:/fastdfs/store_path
    command: "nginx"
    depends_on:
      - fastdfs-tracker

  nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       8888;
        server_name  localhost;
        location / {
            ngx_fastdfs_module;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

  三、問題

  1、TRACKER_SERVER,不能配置docker域名,nginx有IP跳轉,不能識別docker內部的IP,也可以改變網絡形式network_mode: host,但是IP還是得配置成物理IP。這裏網上說需要改成host的網絡類型,實際可以通過bridge模式。

  2、nginx的配置不能配置組名,親測運行時/etc/fdsf/mod_fastdfs.conf被修改的很奇怪。

  3、nginx代理通過ngx_fastdfs_module模塊進行,所以需要代理實際的文件路徑,比如:/fastdfs/store_path。主要是通過該路徑進行文件查詢。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章