FastDFS架构

  •          FastDFS架构包括 Tracker server和Storage server。客户端请求Tracker server进行文件上传、下载,通过Tracker server调度最终由Storage server完成文件上传和下载。
  •          Tracker server作用是负载均衡和调度,通过Tracker server在文件上传时可以根据一些策略找到Storage server提供文件上传服务。可以将tracker称为追踪服务器或调度服务器。
  •          Storage server作用是文件存储,客户端上传的文件最终存储在Storage服务器上,Storage server没有实现自己的文件系统而是利用操作系统 的文件系统来管理文件。可以将storage称为存储服务器。

文件上传流程

文件下载流程

角色

  1. tracker server
  2. storage server
  3. client

FastDFS安装

实验环境

角色clienttracker1tracker2group1-1group1-2group2-1group2-2
IP地址192.168.1.11192.168.1.22192.168.1.33192.168.1.44192.168.1.55192.168.1.66192.168.1.77

安装依赖

[root@localhost ~]# yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl-devel autoconf automake libtool wget git vim

下载 libfastcomm

[root@localhost ~]# mkdir /home/dfs
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# git clone https://github.com/happyfish100/libfastcommon.git
[root@localhost src]# git clone https://github.com/happyfish100/fastdfs.git
[root@localhost src]# git clone https://github.com/happyfish100/fastdfs-nginx-module.git
[root@localhost src]# scp -r /usr/local/src/* 192.168.1.22:/usr/local/src/
[root@localhost src]# scp -r /usr/local/src/* 192.168.1.22:/usr/local/src/
[root@localhost src]# scp -r /usr/local/src/* 192.168.1.33:/usr/local/src/
[root@localhost src]# scp -r /usr/local/src/* 192.168.1.44:/usr/local/src/
[root@localhost src]# scp -r /usr/local/src/* 192.168.1.55:/usr/local/src/
[root@localhost src]# scp -r /usr/local/src/* 192.168.1.66:/usr/local/src/
[root@localhost src]# scp -r /usr/local/src/* 192.168.1.77:/usr/local/src/

安装libfastcommon

[root@localhost src]# cd libfastcommon/
[root@localhost libfastcommon]# ./make.sh && ./make.sh install && cd ..

安装fastdfs

[root@localhost src]# cd fastdfs
[root@localhost fastdfs]# ./make.sh && ./make.sh install && cd ..

修改配置文件

[root@localhost src]# cp /etc/fdfs/tracker.conf{.sample,}
[root@localhost src]# cp /etc/fdfs/client.conf{.sample,}
[root@localhost src]# cp /etc/fdfs/storage.conf{.sample,}

[root@localhost src]# cp fastdfs/conf/http.conf /etc/fdfs/
[root@localhost src]# cp fastdfs/conf/mime.types /etc/fdfs/
[root@localhost src]# cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

client

[root@localhost src]# vim /etc/fdfs/client.conf

安装nginx
[root@localhost src]# tar -zxvf nginx-1.11.5.tar.gz
[root@localhost src]# cd nginx-1.11.5/
[root@localhost nginx-1.11.5]# ./configure --prefix=/usr/local/nginx  && make && make install && ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
[root@localhost nginx-1.11.5]# vim /usr/local/nginx/conf/nginx.conf

tracker1

[root@localhost src]# vim /etc/fdfs/tracker.conf

tracker2

[root@localhost src]# vim /etc/fdfs/tracker.conf

group 1、2

[root@localhost src]# vim /etc/fdfs/storage.conf

[root@localhost src]# vim /etc/fdfs/mod_fastdfs.conf

安装nginx(后面四台全安装)
[root@localhost src]# tar -zxvf nginx-1.11.5.tar.gz
[root@localhost src]# cd nginx-1.11.5/
[root@localhost nginx-1.11.5]# ./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/fastdfs-nginx-module/src/ && make && make install && ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
[root@localhost nginx-1.11.5]# vim /usr/local/nginx/conf/nginx.conf

Last modification:July 23rd, 2020 at 10:45 pm
如果觉得我的文章对你有用,请随意赞赏