环境:

CentOS 7

FastDFS 5.05

Nginx 1.10

fastdfs-nginx-module_v1.16

libfastcommon-1.0.7

libevent-2.0.21-stable

pcre-8.35.tar.gz

单机启动一个Tracker和三个Storage

安装支持模块:

yum install openssl openssl-devel

安装libevent-2.0.21-stable

tar zxvf libevent-2.0.21-stable.tar.gz
./configure
make && make install

安装libfastcommon-1.0.7.tar.gz

tar zxvf libfastcommon-1.0.7.tar.gz
./make.sh
./make.sh install

安装FastDFS

tar zxvf FastDFS_v5.05.tar.gz
./make.sh
./make.sh install

配置文件目录:/etc/fdfs/

配置tracker和storage

tracker:

vim /etc/fdfs/tracker.conf

base_path=/data/local/fdfs_data/tracker #确保目录存在

storage:

vim /etc/fdfs/storage.conf

group_name=group1
http.server_port=8123
base_path=/data/local/fdfs_data/storage #确保目录存在

store_path0=/data/local/fdfs_data/storage/images/data #确保目录存在,存放图片目录

tracker_server=192.168.153.10:22122  #tracker服务地址,这里就是本机地址

由于要启动三个storage,所以复制storage.conf二份,三份配置文件分别为:storage.conf、storage1.conf、storage2.conf

修改storage1.conf和storage2.conf:

storage1.conf:

group_name=group2

http.server_port=8123
base_path=/data/local/fdfs_data/storage1 #确保目录存在 store_path0=/data/local/fdfs_data/storage1/images/data #确保目录存在,存放图片目录 tracker_server=192.168.153.10:22122 #tracker服务地址,这里就是本机地址

storage2.conf:

group_name=group2
http.server_port=8123
base_path=/data/local/fdfs_data/storage2 #确保目录存在

store_path0=/data/local/fdfs_data/storage2/images/data #确保目录存在,存放图片目录  

tracker_server=192.168.153.10:22122 #tracker服务地址,这里就是本机地址

启动tracker:

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

启动三个storage:

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage1.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage2.conf

初次启动storage时会稍慢。

配置client

vim /etc/fdfs/client.conf:

base_path=/data/local/fdfs_data/client #确保目录存在

tracker_server=192.168.153.10:22122
http.server_port=8123

拷贝mime.types、http.conf

cp FastDFS/conf/mime.types /etc/fdfs/
cp FastDFS/conf/http.conf /etc/fdfs/

修改fastdfs-nginx-module/src/config,去掉local:

CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

否在在安装nginx时会报错:

 致命错误:fdfs_define.h:没有那个文件或目录
#include "fdfs_define.h"

安装nginx:

tar zxvf nginx-1.10.3.tar.gz
./configure --prefix=/data/local/nginx --with-http_gzip_static_module --with-http_ssl_module --with-http_stub_status_module --add-module=/data/package/fastdfs-nginx-module/src/ --with-pcre=/data/package/pcre-8.35
make
make install

拷贝模块文件:

cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

修改mod_fastdfs.conf:


tracker_server=tracker:22122
改为:
tracker_server=192.168.0.9:22122 #tracker的实际地址

nginx.conf

listen 8123

location /group1/M00 {
root /data/local/fdfs_data/storage/images;
ngx_fastdfs_module;
}

启动nginx...

设置伪集群:

vim mod_fastdfs.conf:

base_path=/data/local/fdfs_data/fdfs-nginx-module

tracker_server=192.168.153.9:22122

group_name=group1/group2/group3

store_path0=/data/local/fdfs_data/storage/images/data

group_count = 3

[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/data/local/fdfs_data/storage/images [group2]
group_name=group2
storage_server_port=23001
store_path_count=1
store_path0=/data/local/fdfs_data/storage1/images [group3]
group_name=group3
storage_server_port=23002
store_path_count=1
store_path0=/data/local/fdfs_data/storage3/images

重启服务:

/usr/bin/fdfs_trackered /etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage1.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage2.conf restart /data/local/nginx/sbin/nginx -s reload

上传图片测试:

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /data/package/111.jpg

通过结果:

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. [2017-04-21 17:58:52] DEBUG - base_path=/data/local/fdfs_data/client, 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.153.9, port=23000 group_name=group1, ip_addr=192.168.153.9, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKiZCVj519yAMVOkAAA_xFjVVbc000.jpg
source ip address: 192.168.153.9
file timestamp=2017-04-21 17:58:52
file size=16324
file crc32=1490376119
example file url: http://192.168.153.9:8123/group1/M00/00/00/wKiZCVj519yAMVOkAAA_xFjVVbc000.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKiZCVj519yAMVOkAAA_xFjVVbc000_big.jpg
source ip address: 192.168.153.9
file timestamp=2017-04-21 17:58:52
file size=16324
file crc32=1490376119
example file url: http://192.168.153.9:8123/group1/M00/00/00/wKiZCVj519yAMVOkAAA_xFjVVbc000_big.jpg

其中 'http://192.168.153.9:8123/group1/M00/00/00/wKiZCVj519yAMVOkAAA_xFjVVbc000_big.jpg'就是改图片通过nginx的访问地址。

PS:同一个group中的storage之间是平等的,相互备份。

查看FastDFS集群状态:

 /usr/bin/fdfs_monitor /etc/fdfs/client.conf

删除storage节点,重新加入:

/usr/bin/fdfs_monitor /etc/fdfs/client.conf delete group1 192.168.153.9

删除一个组:

/usr/bin/fdfs_monitor /etc/fdfs/client.conf delete group2

删除完之后,重启tracker和storage





FastDFS部署的更多相关文章

  1. FastDFS部署安装全过程

    你好!欢迎阅读我的博文,你可以跳转到我的个人博客网站,会有更好的排版效果和功能. 此外,本篇博文为本人Pushy原创,如需转载请注明出处:https://pushy.site/posts/153205 ...

  2. Fastdfs 部署干货

    tracker server and client:192.168.1.42 storage server:192.168.1.46 storage server:192.168.1.53 安装: 安 ...

  3. FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块(转)

    1.Nginx的FastDFS模块什么作用? 我们在使用FastDFS部署一个分布式文件系统的时候,通过FastDFS的客户端API来进行文件的上传.下载.删除等操作.同时通过 FastDFS的HTT ...

  4. FastDFS为什么要结合Nginx

    FastDFS为什么要结合Nginx? 我们在使用FastDFS部署一个分布式文件系统的时候,通过FastDFS的客户端API来进行文件的上传.下载.删除等操作.同时通过FastDFS的HTTP服务器 ...

  5. FastDFS分布式存储实战

    <FastDFS分布式存储实战> 技术选型 FastDFS相关组件及原理 FastDFS介绍 FastDFS架构 FastDFS工作流程 上传 同步机制 下载 文件合并原理 实验环境说明 ...

  6. linux上安装fastdfs+nginx+ngin-module实践并解决多个异常篇

    为什么选择Nginx Nginx 是一个很牛的高性能Web和反向代理服务器, 它具有有很多非常优越的特性: 在高连接并发的情况下,Nginx是Apache服务器不错的替代品:Nginx在美国是做虚拟主 ...

  7. CentOS7搭建FastDFS V5.11分布式文件系统-第三篇

    1.测试 前面两篇博文已对FastDFS的安装和配置,做了比较详细的讲解.FastDFS的基础模块都搭好了,现在开始测试下载. 1.1 配置客户端 同样的,需要修改客户端的配置文件: /etc/fdf ...

  8. fastdfs+nginx+image_filter安装与生成缩略图

    fastdfs简介 类似google FS的一个轻量级分布式文件系统,纯C实现,支持linux.FreeBSD等UNIX系统: 只能通过API访问,不支持POXIS: 文件不分块存储,上传的文件和OS ...

  9. fastdfs5.11+centos7.2 按照部署(三)【转载】

    1.测试 前面两篇博文已对FastDFS的安装和配置,做了比较详细的讲解.FastDFS的基础模块都搭好了,现在开始测试下载. 1.1 配置客户端 同样的,需要修改客户端的配置文件: vim /etc ...

随机推荐

  1. Scrum立会报告+燃尽图(十二月七日总第三十八次):功能测试

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2284 项目地址:https://git.coding.net/zhang ...

  2. Scrum Meeting 4 -2014.11.8

    开始了apec的放假,希望大家能处理好工作与休息的时间分配,不要玩疯了啊. 各任务都开始实现了自己的算法,需要部署的服务器我也进去看了看情况,希望最后能部署成功. 最近发现的一些关于上一届实现的问题, ...

  3. Java实验五(客户端)

    一.    实验内容 1.    运行教材上TCP代码,结对进行,一人服务器,一人客户端: 2.    利用加解密代码包,编译运行代码,客户端加密,服务器解密: 3.    客户端加密明文后将密文通过 ...

  4. “Gogoing”改进方案

    通过看见他们对我们团队的意见点评,我们还要有更多改善的地方. 首先,就是界面的优化: 其次,加上自己些特有的功能,吸引更多的用户: 然后,需要整理大量的数据库信息才能完善: 最后,需要有其他软件的集成 ...

  5. Chapter 8 面向对象设计

    设计也是一个建模的活动,在设计阶段将集中研究系统的软件实现问题包括体系结构设计.详细设计.用户界面设计和数据库设计等.通常设计活动分为系统设计和详细设计两个主要阶段.软件设计要遵循模块化.耦合度和内聚 ...

  6. [转]string和stringstream用法总结

    转自:http://blog.csdn.net/xw20084898/article/details/21939811 作者:xw20084898 一.string string 是 C++ 提供的字 ...

  7. oracle 简单的sysTimeStamp类型转date 类型

    oracle  简单的SYSTIMESTAMP 类型转date 类型 SELECT SYSTIMESTAMP , SYSTIMESTAMP+0 FROM dual; SAMPLE_TIME ----- ...

  8. Apache+Nginx+php共存(一)

    在实际开发中个人的电脑中经常需要安装 WNMRP.WAMRP.LNMRP.LAMRP等各种开发环境来应对不同的开发需求. 此篇主要是对WINDOWS系统下 Apache+Nginx + PHP +My ...

  9. [转帖] Linux buffer 和 cache相关内容

    Linux中Buffer/Cache清理 Lentil2018年9月6日 Linux中的buff/cache可以被手动释放,释放缓存的代码如下: https://lentil1016.cn/linux ...

  10. 错误“AxImp.exe”已退出,代码为 -1163019603【转载及个人看法】

    http://blog.csdn.net/duguduchong/article/details/17166123 最近使用vs2010  在重新生成解决方案的时候出现 “AxImp.exe”已退出, ...