C/C++教程

基于rancher搭建fastdfs环境

本文主要是介绍基于rancher搭建fastdfs环境,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务,如相册网站、视频网站等等。

FastDFS为互联网量身定制,充分考虑了冗余备份、负载均衡、线性扩容等机制,并注重高可用、高性能等指标,使用FastDFS很容易搭建一套高性能的文件服务器集群提供文件上传、下载等服务。

搭建环境

docker-compose.yml 文件编写

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配置

#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;
        }
 }
}复制代码

启动服务

验证

进入docker,查看tracker地址,如果错误,请修改主机中的 storage.conf后重启服务

上传成功,访问nginx

http://10.42.169.170/group1/M00/00/00/CipvqF6lP9WAXcZ3AABdrZgsqUU645.jpg

可以看到图片



这篇关于基于rancher搭建fastdfs环境的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!