`

Centos7 安装FastDFS+nginx module

 
阅读更多

时间:2015-04-29 14:40来源:blog.csdn.net 作者:freewebsys的专栏

 

1,关于FastDFS

 

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

 

FastDFS服务端有两个角色:跟踪器(tracker)和存储节点(storage)。跟踪器主要做调度工作,在访问上起负载均衡的作用。

 

存储节点存储文件,完成文件管理的所有功能:存储、同步和提供存取接口,FastDFS同时对文件的meta data进行管理。所谓文件的meta data就是文件的相关属性,以键值对(key value pair)方式表示,如:width=1024,其中的key为width,value为1024。文件meta data是文件属性列表,可以包含多个键值对。

 

GitHub:https://github.com/happyfish100/fastdfs 
一个写的不错的博客:http://tech.uc.cn/?p=221

 

2,安装FastDFS

 

参考文档: 
https://github.com/happyfish100/fastdfs/blob/master/INSTALL

 

2.1,安装编译工具

 

yum -y groupinstall 'Development Tools' 
yum -y install wget 

 

  • 1
  • 2

 

2.2,安装libfastcommon类库

 

必须先按照这个,否则报错:

 

cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -DOS_LINUX -DIOEVENT_USE_EPOLL -c -o ../common/fdfs_global.o ../common/fdfs_global.c  -I../common -I/usr/include/fastcommon
../common/fdfs_global.c:20:20: fatal error: logger.h: No such file or directory
 #include "logger.h"
                    ^
compilation terminated.
........

 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

 

直接下载安装即可:

 

wget https://github.com/happyfish100/libfastcommon/archive/master.zip
unzip master.zip
cd libfastcommon-master
./make.sh
./make.sh install

 

  • 1
  • 2
  • 3
  • 4
  • 5

 

2.3,安装FastDFS

 

wget  https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
tar -zxvf V5.05.tar.gz 
cd fastdfs-5.05/
./make.sh
./make.sh install

 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

 

2.4,启动FastDFS

 

安装之后配置文件在目录/etc/fdfs。

 

mv storage.conf.sample  storage.conf
mv tracker.conf.sample tracker.conf

 

  • 1
  • 2

 

首先修改配置文件:  /etc/fdfs/tracker.conf,修改路径到/data/fdfs目录。

 

# the base path to store data and log files
base_path=/data/fdfs

 

  • 1
  • 2

 

启动:  /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start

 

修改配置文件:  /etc/fdfs/storage.conf,修改路径到/data/fdfs目录,同时配置tracker_server地址。

 

# the base path to store data and log files
base_path=/data/fdfs
# 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.1.36:22122
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/data/fdfs
#store_path1=/home/yuqing/fastdfs2

 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

 

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

 

启动的时候,看日志没有错误就说明启动成功。  查看fdfs进程:

 

#ps -ef | grep fdfs
root     19880     1  0 21:42 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
root     20050     1  0 22:08 ?        00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
root     20060 19915  0 22:08 pts/1    00:00:00 grep --color=auto fdfs

 

  • 1
  • 2
  • 3
  • 4

 

2.5 安装nginx + lua + fastdfs module  下载fastdfs-nginx-module模块  https://github.com/happyfish100/fastdfs-nginx-module  下载openresty nginx +lua包

 

wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip
unzip fastdfs-nginx-module-master.zip
wget http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz
tar -zxvf ngx_openresty-1.7.10.1.tar.gz

 

  • 1
  • 2
  • 3
  • 4

 

编译安装:这里注意下,需要增加参数。  一个是stub_status统计模块,一个是realip模块。  参考地址:  http://blog.danielss.com/?p=80  http://wiki.nginx.org/HttpRealipModuleChs

 

yum -y install pcre-devel openssl openssl-devel
cd ngx_openresty-1.7.10.1
./configure --with-luajit --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --add-module=/root/fastdfs-nginx-module-master/src 
gmake
gmake install

 

  • 1
  • 2
  • 3
  • 4
  • 5

 

nginx +lua安装路径:

 

  nginx path prefix: "/usr/local/openresty/nginx"
  nginx binary file: "/usr/local/openresty/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/openresty/nginx/conf"
  nginx configuration file: "/usr/local/openresty/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/openresty/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/openresty/nginx/logs/error.log"
  nginx http access log file: "/usr/local/openresty/nginx/logs/access.log"

 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

 

启动,重启nginx

 

#启动
/usr/local/openresty/nginx/sbin/nginx
#重启
 /usr/local/openresty/nginx/sbin/nginx -s restart

 

  • 1
  • 2
  • 3
  • 4

 

3,测试FastDFS

 

配置服务:

 

cd /etc/fdfs
mv client.conf.sample client.conf

 

  • 1
  • 2

 

修改配置:

 

# the base path to store log files
base_path=/data/fdfs

# 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.1.36:22122

 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

 

配置nginx:

 

cp /root/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/
mkdir /data/ngx

 

  • 1
  • 2

 

修改mod_fastdfs.conf配置文件:修改tracker端口,否则nginx启动不了。路径也必须修改,否则找不到文件。

 

# the base path to store log files
base_path=/data/ngx
# FastDFS tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=192.168.1.36:22122
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/data/fdfs

 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

 

拷贝配置文件,否则nginx启动不了,报错:

 

[2015-04-28 11:30:14] ERROR - file: ini_file_reader.c, line: 315, include file "http.conf" not exists, line: "#include http.conf"
[2015-04-28 11:30:14] ERROR - file: /root/fastdfs-nginx-module-master/src/common.c, line: 155, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
2015/04/28 11:30:14 [alert] 19969#0: worker process 2753 exited with fatal code 2 and cannot be respawned

 

  • 1
  • 2
  • 3
  • 4

 

解决办法:

 

cp /root/fastdfs-master/conf/http.conf /root/fastdfs-master/conf/mime.types  /etc/fdfs

 

  • 1

 

nginx配置修改vi /usr/local/openresty/nginx/conf/nginx.conf

 

    server {
        listen       80;
        server_name  localhost;

        charset utf8;

        location /M00 {
                alias /data/fdfs/data;
                ngx_fastdfs_module;
        }
   ......

 

  • 1
  • 2
  • 3
  • 4
  • 5
  •  

 

创建连接

 

ln -s /data/fdfs/data /data/fdfs/data/M00

 

  • 1

 

重启nginx。  测试命令:

 

echo "test fastdfs" > test.html
 /usr/bin/fdfs_test /etc/fdfs/client.conf upload test.html

 

  • 1
  • 2

 

上传成功,执行结果:

 


This is FastDFS client test program v5.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.

[2015-04-25 18:06:09] DEBUG - base_path=/data/fdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group:
        server 1. group_name=, ip_addr=192.168.1.36, port=23000

group_name=group1, ip_addr=192.168.1.36, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01.html
source ip address: 192.168.1.36
file timestamp=2015-04-25 18:06:09
file size=13
file crc32=3418468952
example file url: http://192.168.1.36/group1/M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01.html
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01_big.html
source ip address: 192.168.1.36
file timestamp=2015-04-25 18:06:09
file size=13
file crc32=3418468952
example file url: http://192.168.1.36/group1/M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01_big.html

 

  •  

 

测试访问:

 

curl http://192.168.1.36/M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01_big.html

 

如果返回“test fastdfs”说明配置成功。上面的每一步修改都要正确才可以。

 

查看nginx错误日志:  tail -f /usr/local/openresty/nginx/logs/error.log

 

4,总结

 

FastDFS非常好的分布式文件系统。配置简单,可以多机器部署,同时官方给了一个Nginx模块,可以直接用nginx访问,非常方便。这样减少了中 间的tomcat层,效率高。  接下来继续研究lua的图片压缩。直接在nginx层进行图片压缩。效率更高,同时图片读取FastDFS的文件。

分享到:
评论

相关推荐

    fastdfs的安装手册说明+配置文件+fastdfs安装包+nginx安装包

    下载Nginx源码,解压后配置并编译安装,确保编译时添加FastDFS模块`--with-http_fastdfs_module`。 2. 配置Nginx 在Nginx配置文件中添加FastDFS模块的配置,如`/etc/nginx/nginx.conf`,设置连接Tracker的地址和...

    CentOS6环境FastDFS+Nginx安装配置笔记.pdf

    在本篇《CentOS6环境FastDFS+Nginx安装配置笔记》中,主要涉及的是在 CentOS 6操作系统上搭建FastDFS分布式文件系统以及Nginx反向代理服务器的过程。FastDFS是一个开源的高性能、轻量级的分布式文件系统,而Nginx则...

    linux下搭建FastDFS+Nginx服务器

    - 下载Nginx源码包,解压并编译安装:从官网下载最新版本,执行`./configure --with-http_stub_status_module --with-http_ssl_module --with-http_fastdfs_module --with-pcre`,然后`make && make install`。...

    Linux上安装FastDFS+nginx+fastDHT 详细教程&含安装包.zip

    fastdfs-nginx-module_v1.19.zip是FastDFS的Nginx模块,用于将nginx和FastDFS结合。 FastDHT是一种分布式哈希表,用于提供分布式数据存储和检索服务。FastDHT_v1.17.tar.gz是其源码包,它可以帮助实现数据的分布式...

    FastDFS+Nginx文件系统搭建

    在搭建FastDFS+Nginx文件系统时,你需要在CentOS 6.8 64位操作系统上安装FastDFS的相应版本(FastDFS_v5.08、libfastcommon-master和fastdfs-nginx-module_v1.16),按照官方文档或社区教程进行配置,包括安装依赖、...

    fastdfs+nginx完整安装包(含安装说明及.net测试客户端)

    本教程将详细介绍如何在CentOS7操作系统上进行FastDFS和Nginx的安装、配置,并结合.NET测试客户端进行功能验证。 一、环境准备 在开始安装前,确保你的CentOS7系统已经更新到最新版本,并安装了基本的开发工具集...

    Java Centos7上fastdfs安装详细手册

    至此,您已经完成了FastDFS在Centos7上的安装及配置,包括libfastcommon、FastDFS本身以及fastdfs-nginx-module和Nginx等必要组件的安装与配置。通过以上步骤,您可以构建起一个稳定且高效的数据存储与分发系统。

    centos7搭建nginx+fastDFS

    ### FastDFS 在 CentOS 7 下的部署与 Nginx 集成详解 #### 一、FastDFS 简介及工作原理 **1.1 快速理解 FastDFS** FastDFS 是一个开源的高性能分布式文件系统,适用于海量数据存储场景,特别是针对中小文件(4KB ...

    FastDFS 5.05 + nginx + cache 集群安装配置手册

    本指南详细介绍了如何在 CentOS 6.5 x86_64 操作系统上安装配置 **FastDFS 5.05**、**nginx** 和 **nginx cache** 插件。该配置适用于搭建高性能的文件服务集群。 ##### (一) 下载FastDFS安装包 首先,需要从官方...

    centos离线安装fastdfs所需要软件

    进入fastdfs-nginx-module目录,配置时指定Nginx源码和FastDFS的安装路径: ``` cd ../fastdfs-nginx-module vi Makefile # 在Makefile中找到objs/ 指向nginx的src目录 ./configure --with-nginx=/usr/local/...

    Centos6安装FastDFS分布式全套软件.zip

    fastdfs-nginx-module_v1.16.tar.gz, FastDFS_v4.06.tar.gz libevent-headers-1.4.13-4.el6.noarch.rpm libevent-doc-1.4.13-4.el6.noarch.rpm libevent-devel-1.4.13-4.el6.x86_64.rpm nginx-1.7.10.tar.gz

    centos6 安装 fastdfs所需安装包(适用于centos6 和centos 7)

    在FastDFS源码目录中找到`nginx_module`,编译并安装: ```bash cd /usr/local/src/fastdfs/nginx_module ./configure --with-nginx=/usr/local/nginx --with-fdfs=/usr/local/fastdfs make make install ``` 编辑...

    FastDFS安装与Nginx整合

    **FastDFS安装与Nginx整合详解** FastDFS是一个开源的、高性能的、轻量级的分布式文件系统,主要用于解决大容量存储和负载均衡的问题。它具有高可用性、高扩展性和低延迟等特点,适用于互联网行业的图片、视频等大...

    CentOS7安装FastDFS-单机版亲测

    FastDFS是一款开源的轻量级分布式文件系统纯C实现,支持Linux、FreeBSD等UNIX系统类google FS,不是通用的文件系统,只能通过专有API访问,目前提供了C、Java和... fastdfs-nginx-module-master.zip  下载地址:  

    Linux系统:centos7下搭建Nginx和FastDFS.rar

    在Linux系统,特别是CentOS 7环境下,搭建Nginx和FastDFS是一项常见的任务,用于构建高效、稳定且可扩展的文件服务器。Nginx是一款高性能的HTTP和反向代理服务器,而FastDFS是一个轻量级的分布式文件系统,两者结合...

    Linux Centos7.5 安装FastDFS所需软件

    在Linux CentOS 7.5操作系统上安装FastDFS是一项常见的任务,尤其对于那些需要处理大量文件存储和分发的系统来说。FastDFS是一个高效且轻量级的分布式文件系统,其设计目标是为互联网服务提供高可用性和高扩展性的...

    FastDFS-v5.08.tar.gzlibfastcommonfastdfs-nginx-modulenginx

    7. 安装FastDFS Nginx模块:FastDFS提供Nginx模块来处理HTTP请求,将文件服务与Web服务器结合。需要编译并安装此模块。 8. 配置Nginx:修改Nginx配置文件,引入FastDFS模块并配置相应的路径和连接Tracker服务器的...

    fast+nginx.zip

    在这个“fast+nginx.zip”压缩包中,包含了在CentOS操作系统上安装和配置这两个组件来创建一个图片缩略图服务的步骤和文件。 首先,我们来看`FastDFS`。FastDFS提供了文件存储、文件同步、负载均衡等功能,特别适合...

    CentOS 6.3下FastDFS_v4.06的安装及其配置

    在本文中,我们将深入探讨如何在CentOS 6.3操作系统上安装和配置FastDFS_v4.06。FastDFS是一个开源的、轻量级的分布式文件系统,它专为互联网应用设计,支持高可用性、高性能和负载均衡。本文将分为几个关键步骤,...

Global site tag (gtag.js) - Google Analytics