FastDFS是一個開源的輕量級分佈式文件系統,它對文件進行管理,功能包括:文件存儲、文件同步、文件訪問(文件上傳、文件下載)等,解決了大容量存儲和負載均衡的問題。特別適合以文件爲載體的在線服務,如相冊網站、視頻網站等等。html
FastDFS爲互聯網量身定製,充分考慮了冗餘備份、負載均衡、線性擴容等機制,並注重高可用、高性能等指標,使用FastDFS很容易搭建一套高性能的文件服務器集羣提供文件上傳、下載等服務。nginx
docker-compose.yml 文件編寫docker
docker-compose.yml
version: '2'
services:
fastdfs-nginx:
image: season/fastdfs:1.2
hostname: fastdfs-nginx
environment:
TRACKER_SERVER: 10.42.113.136:22122
volumes:
- /root/rancher/develop/fastdfs/nginx.conf:/etc/nginx/conf/nginx.conf
- /root/rancher/develop/fastdfs/store_path:/fastdfs/store_path
command:
- nginx
fastdfs-tracker:
image: season/fastdfs:1.2
hostname: fastdfs-tracker
volumes:
- /root/rancher/develop/fastdfs/tracker_data:/fastdfs/tracker/data
command:
- tracker
fastdfs-storage:
image: season/fastdfs:1.2
hostname: fastdfs-storage
environment:
TRACKER_SERVER: 10.42.113.136:22122
volumes:
- /root/rancher/develop/fastdfs/storage_data:/fastdfs/storage/data
- /root/rancher/develop/fastdfs/store_path:/fastdfs/store_path
command:
- storage
複製代碼
nginx配置bash
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /group1/M00 {
root /fastdfs/storage/data;
ngx_fastdfs_module;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}複製代碼
啓動服務
服務器
驗證app
進入docker,查看tracker地址,若是錯誤,請修改主機中的 storage.conf後重啓服務負載均衡
上傳成功,訪問nginx
tcp
http://10.42.169.170/group1/M00/00/00/CipvqF6lP9WAXcZ3AABdrZgsqUU645.jpg 分佈式
能夠看到圖片性能