第一部分   FastDFS介绍

1.FastDFS是什么

FastDFS是一款类Google FS的开源分布式文件系统,它用纯C语言实现,支持Linux、FreeBSD、AIX等UNIX系统。它只能通过 专有API对文件进行存取访问,不支持POSIX接口方式,不能mount使用。

准确地讲,Google FS以及FastDFS、mogileFS、 HDFS、TFS等类Google FS都不是系统级的分布式文件系统,而是应用级的分布式文件存储服务。

FastDFS的作者是余庆,现在淘宝网Java中间件团队从事Java基础平台研发工作。

以上文字引用自<<程序员>> 文章 <<分布式文件系统FastDFS架构剖析>>http://www.programmer.com.cn/tag/fastdfs-架构/

2.FastDFS的体系结构

3.FastDFS工作过程

1. Client询问Tracker server上传到的Storage server;

2. Tracker server返回一台可用的Storage server,返回的数据为该Storage server的IP地址和端口;

3. Client直接和该Storage server建立连接,进行文件上传,Storage server返回新生成的文件ID,文件上传结束。

1. Client询问Tracker server可以下载指定文件的Storage server,参数为文件ID(包含组名和文件名);

2. Tracker server返回一台可用的Storage server;

3. Client直接和该Storage server建立连接,完成文件下载。

FastDFS从V1.20开始,支持通过HTTP协议下载文件。

1.用户浏览器访问Tracker server内置的Web Server,URL中包含文件ID(包含组名和文件名);

2.Tracker server将这个HTTP请求redirect到一台可用的Storage server的Web Server上(可以是apache或nginx);

3.用户浏览器直接与Storage server的Web Serverr建立连接,完成文件下载。

第二部分   FastDFS+nginx_module配置手记

1.系统环境

最小化安装的 CentOS 5.6 x86_64

tracker server:   192.168.3.220

storage server:   192.168.3.226

2.环境准备[所有服务器上操作]

为了速度,配置使用sohu的源

cd /etc/yum.repo.d/

wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo

安装EPEL源

rpm -ihv http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

安装开发工具和编译nginx所需的开发包

yum groupinstall "Development Tools"

yum install libevent-devel.x86_64 pcre-devel.x86_64  zlib-devel.x86_64

3.在tracker上的操作[安装tracker server]

[root@tracker]# wget http://fastdfs.googlecode.com/files/FastDFS_v3.05.tar.gz

[root@tracker]# tar xvzf FastDFS_v3.05.tar.gz

[root@tracker]# cd FastDFS

[root@tracker]# vi make.sh

将如下两行前边的"#"删除

WITH_HTTPD=1

WITH_LINUX_SERVICE=1

[root@tracker]# ./make.sh

[root@tracker]# ./make.sh install

[root@tracker]# vi /etc/fdfs/tracker.conf

修改/etc/fdfs/tracker.conf,主要修改以下两处,如有其他调整,可参考文档自行调整,默认的配置也可以工作。

# the base path to store data and log files

base_path=/home/tracker     ====> 放置data和log的目录

##include http.conf   ====>   #include http.conf    这里一定要注意!是 #include,不是include!!!

[root@tracker]# mkdir -p /home/tracker

启动tracker服务

[root@tracker]#  /etc/init.d/fdfs_trackerd start

确认8080,22122端口已经监听

[root@tracker]# netstat -nl|grep -E '8080|22122'

tcp        0      0 0.0.0.0:22122               0.0.0.0:*                   LISTEN

tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN

4.在storage上的操作

[root@storage]# wget http://fastdfs.googlecode.com/files/FastDFS_v3.05.tar.gz

[root@storage]# wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.10.tar.gz

[root@storage]# wget http://nginx.org/download/nginx-1.0.11.tar.gz

[root@storage]# tar xvzf FastDFS_v3.05.tar.gz

[root@storage]# cd FastDFS

[root@storage]# ./make.sh

[root@storage]# ./make.sh install

[root@storage]# tar xvzf nginx-1.0.11.tar.gz

[root@storage]# tar xvzf fastdfs-nginx-module_v1.10.tar.gz

[root@storage]# cd nginx-1.0.11

[root@storage]# ./configure --prefix=/usr/local/nginx --add-module=/root/fastdfs-nginx-module/src

[root@storage]# make

[root@storage]# make install

[root@storage]# vi /etc/fdfs/storage.conf

修改/etc/fdfs/storage.conf,主要修改以下几处,如有其他调整,可参考文档自行调整,默认的配置也可以工作。

# the name of the group this storage server belongs to

group_name=group1 ====> 此台storage server所属的服务器组名

# the base path to store data and log files

base_path=/home/storage ====> 放置data和log的目录

# store_path#, based 0, if store_path0 not exists, it's value is base_path

# the paths must be exist

store_path0=/home/storage ====> 放置文件的目录

# tracker_server can ocur more than once, and tracker_server format is

#  "host:port", host can be hostname or ip address

tracker_server=192.168.3.220:22122 ====> tracker server的ip和端口,此处可以写多个tracker server,每行一个

#HTTP settings

http.disabled=true    ====> 关闭内置的web server

# the port of the web server on this storage server

http.server_port=80    ====> web server的端口改成80

[root@storage]# cp /root/fastdfs-nginx-module/mod_fastdfs.conf /etc/fdfs/

[root@storage]# vi /etc/fdfs/mod_fastdfs.conf

# the base path to store log files

base_path=/home/storage ====> 放置log的目录

# FastDFS tracker_server can ocur more than once, and tracker_server format is

#  "host:port", host can be hostname or ip address

tracker_server=192.168.3.220:22122 ====> tracker server的ip和端口,此处可以写多个tracker server,每行一个

# the group name of storage server

group_name=group1 ====> 此台storage server所属的服务器组名

# if uri including group name

# default value is false

url_have_group_name = true ====> 在URL中包含group名称

# store_path#, based 0, if store_path0 not exists, it's value is base_path

# the paths must be exist

store_path0=/home/storage ====> 放置文件的目录

[root@storage]# mkdir -p /home/storage

在nginx的server配置段中增加M00的location声明

[root@storage]# vi /usr/local/nginx/conf/nginx.conf

location /group1/M00 {

root /home/storage/data;

ngx_fastdfs_module;

}

创建M00目录的软连接

[root@storage]# ln -s /home/storage/data  /home/storage/data/M00

启动storage服务

[root@storage]#  /etc/init.d/fdfs_storaged start

启动nginx

[root@tracker]#  /usr/local/nginx/sbin/nginx

确认8080,22122端口已经监听

[root@storage]# netstat -nl|grep -E '80|23000'

tcp        0      0 0.0.0.0:23000               0.0.0.0:*                   LISTEN

tcp        0      0 0.0.0.0:80                0.0.0.0:*                   LISTEN

5.在tracker上的操作[作为client测试]

修改/etc/fdfs/client.conf文件,主要修改以下几处,如有其他调整,可参考文档自行调整,默认的配置也可以工作。

# the base path to store log files

base_path=/tmp

# tracker_server can ocur more than once, and tracker_server format is

#  "host:port", host can be hostname or ip address

tracker_server=192.168.3.220:22122

创建一个用于测试的文件demofile.txt

[root@tracker]# vi demofile.txt
    内容就一行字:  dddddddddd

使用自带的fdfs_test上传文件测试。

[root@tracker]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload demofile.txt

This is FastDFS client test program v3.05

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General

Public License V3, which may be found in the FastDFS source kit.

Please visit the FastDFS Home Page http://www.csource.org/

for more detail.

[2012-01-20 14:36:04] INFO - base_path=/tmp, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0

tracker_query_storage_store_list_without_group:

server 1. group_name=group1, ip_addr=192.168.3.226, port=23000

group_name=group1, ip_addr=192.168.3.226, port=23000

storage_upload_by_filename

group_name=group1, remote_filename=M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484.txt

source ip address: 192.168.3.226

file timestamp=2012-01-20 14:36:04

file size=11

file crc32=2037505305

file url: http://192.168.3.220:8080/group1/M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484.txt

storage_upload_slave_by_filename

group_name=group1, remote_filename=M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484_big.txt

source ip address: 192.168.3.226

file timestamp=2012-01-20 14:36:04

file size=11

file crc32=2037505305

file url: http://192.168.3.220:8080/group1/M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484_big.txt

6.使用浏览器打开上传的文件

我们在浏览器中输入http://192.168.3.220:8080/group1/M00/00/00/wKgD4k8ZC1SNK-NYAAAAC3lx3Rk484.txt

可以看到,访问的地址已经被redirect到了storage server的IP(192.168.3.226)了。

FastDFS、nginx配置手记的更多相关文章

  1. 在虚拟机中配置FastDFS+Nginx模块

    先上部署图 提示一下, ip 192.168.72.138 上面部署了两个group, 分别为 group1和g2. 另外, 同组之内的 port 要保持一致. 一.安装准备 1. #每台机器都添加两 ...

  2. FastDFS+Nginx安装配置

    下载相关包: libevent-2.0.22-stable.tar.gz => https://github.com/libevent/libevent/releases/download/re ...

  3. FastDFS+Nginx(单点部署)事例

    FastDFS是由淘宝的余庆先生所开发,是一个轻量级.高性能的开源分布式文件系统,用纯C语言开发,包括文件存储.文件同步.文件访问(上传.下载).存取负载均衡.在线扩容.相同内容只存储一份等功能,适合 ...

  4. FastDFS+Nginx部署详细教程

    本例使用到的所有tar和zip包地址:http://download.csdn.net/detail/corey_jk/9758664 本例中使用CentOS1.CentOS2两台机器实现. 1 GC ...

  5. fastDFS 安装 配置 使用

    fastDFS 安装 配置 使用 关于安装 本文采用的是源码的安装方式,其他安装方式请自行百度 简单介绍 1.背景 FastDFS是一款开源的.分布式文件系统(Distributed File Sys ...

  6. docker+fastdfs+nginx 实现分布式大文件存储系统以及视频缓存播放

    废话不多说,直接开撸 首先是一些准备工作: 1.关闭防火墙 service iptables stop --- fastdfs虽然在docker部署,但是使用的是主机网络,所以关闭防火墙. 2  下载 ...

  7. 简单的 FastDFS + Nginx 应用实例

    版权声明:本文为GitChat作者的原创文章,未经 GitChat 同意不得转载. https://blog.csdn.net/GitChat/article/details/79479148 wx_ ...

  8. FastDFS+Nginx+fastdfs-nginx-module集群搭建

    一.实验环境说明 操作系统: Centos 6.6 x64 FastDFS 相关版本: fastdfs-5.05 fastdfs-nginx-module-v1.16 libfastcommon-v1 ...

  9. FastDFS+nginx+keepalived集群搭建

    安装环境 nginx-1.6.2 libfastcommon-master.zip FastDFS_v5.05.tar.gz(http://sourceforge.net/projects/fastd ...

随机推荐

  1. qt 5 小练习 简易画板

    如何在窗口上画线?用一根根线来拼凑图案呢? 想必大家都知道点的集合是线,而线的集合就是很多线啦,用线的集合我们能拼凑出许许多多的图案.于是我就要记录自己跟着老师的学习之路啦: 既然有集合的话,势必要用 ...

  2. Cocoapod安装 - 管理第三方库

    在我们开发移动应用的时候,一般都会使用到第三方工具,而由于第三方类库的种类繁多,我们在项目中进行管理也会相对麻烦,所以此时我们就需要一个包管理工具,在iOS开发中,我们使用最多的就是Cocoapods ...

  3. [原博客] BZOJ 2242 [SDOI2011] 计算器

    题目链接 noip级数论模版题了吧.让求三个东西: 给定y,z,p,计算`Y^Z Mod P` 的值. 给定y,z,p,计算满足`xy≡ Z ( mod P )`的最小非负整数. 给定y,z,p,计算 ...

  4. Jar包可执行??

    第一次听说,jvm加载包,必须rwx么?

  5. 我新买的红米手机,新浪和360浏览器都能进,也能看电视,就是不能上手机QQ和微信

    1.请您在桌面下.点击手菜单键-全局搜索,输入网络助手,点击流量排行,点击批量联网控制,查看该软件下(不能上网的应用)wifi和流量2G/3G下方的选项是否都勾选的.如果没有勾选,请您勾选. 2:仍然 ...

  6. [转贴]怎样在LINQ实现 LEFT JOIN 或者RIGHT JOIN

    In this post let us see how we can handle Left Join and Right Join when using LINQ. There are no key ...

  7. DIV 清除样式浮动万能代码

            .talk {             width: 100%;             margin: 10px 0;         }         .talk:after { ...

  8. Firebug控制台详解

    转自:http://www.ruanyifeng.com/blog/2011/03/firebug_console_tutorial.html 作者: 阮一峰 日期: 2011年3月26日 Fireb ...

  9. 动态规划(计数DP):JLOI 2016 成绩比较

    Description G系共有n位同学,M门必修课.这N位同学的编号为0到N-1的整数,其中B神的编号为0号.这M门必修课编号为0到M- 1的整数.一位同学在必修课上可以获得的分数是1到Ui中的一个 ...

  10. UNion ALL 和 UNION 的区别

    UNION: 指定合并多个结果集并将其作为单个结果集返回.ALL: 将全部行并入结果中.其中包括重复行.如果未指定该参数,则删除重复行.