原理图:

fastdfs适用场景:

  fastdfs特别适合海量 中小文件(建议范围:4KB< file_size <500MB)为载体的在线服务。

安装系统介绍:

  CentOS6.6

安装准备软件包:

一、安装fastdfs:

[root@xiaofan fxh]# pwd
/home/fxh
[root@xiaofan fxh]# tar xf libevent-2.0.19-stable.tar.gz
[root@xiaofan fxh]# cd libevent-2.0.19-stable
[root@xiaofan libevent-2.0.19-stable]# ./configure --prefix=/usr/local/libevent
[root@xiaofan libevent-2.0.19-stable]# make
[root@xiaofan libevent-2.0.19-stable]# make install

[root@xiaofan ~]# cd /home/fxh/
[root@xiaofan fxh]# tar xf FastDFS_4.06.tar.gz
[root@xiaofan fxh]# tar xf FastDFS_4.06.tar.gz
[root@xiaofan fxh]# cd FastDFS
[root@xiaofan FastDFS]# ./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
[root@xiaofan FastDFS]# ./make.sh install

配置文件路径:/etc/fdfs/
tracker.conf//负责均衡调度服务器配置文件
client.conf//客户端上传配置文件
http.conf//http服务器配置文件
storage.conf//文件存储服务器配置文件
mime.types//文件类型配置文件

tracker配置文件:
[root@xiaofan ~]# egrep -v "^#|^$" /etc/fdfs/tracker.conf
disabled=false
bind_addr=
port=22122
connect_timeout=30
network_timeout=60
base_path=/home/data #设置base_path
max_connections=1000
work_threads=4
store_lookup=2
store_group=group1
store_server=0
store_path=0
download_server=0
reserved_storage_space = 10%
log_level=info
run_by_group=
run_by_user=
allow_hosts=*
sync_log_buff_interval = 10
check_active_interval = 120
thread_stack_size = 64KB
storage_ip_changed_auto_adjust = true
storage_sync_file_max_delay = 86400
storage_sync_file_max_time = 300
use_trunk_file = false
slot_min_size = 256
slot_max_size = 16MB
trunk_file_size = 64MB
trunk_create_file_advance = false
trunk_create_file_time_base = 02:00
trunk_create_file_interval = 86400
trunk_create_file_space_threshold = 20G #
trunk_init_check_occupying = false
trunk_init_reload_from_binlog = false
use_storage_id = false
storage_ids_filename = storage_ids.conf
id_type_in_filename = ip
store_slave_file_use_link = false
rotate_error_log = false
error_log_rotate_time=00:00
rotate_error_log_size = 0
use_connection_pool = false
connection_pool_max_idle_time = 3600
http.server_port=8080 #http 端口
http.check_alive_interval=30
http.check_alive_type=tcp
http.check_alive_uri=/status.html

创建目录:
mkdir /home/data #启动可能会报错,哪个目录没创建,看日志就好了

添加iptables规则:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT

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

检查端口22122:
[root@xiaofan ~]# lsof -i :22122
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
fdfs_trac 1605 root 5u IPv4 13569 0t0 TCP *:22122 (LISTEN)
fdfs_trac 1605 root 25u IPv4 13666 0t0 TCP 10.10.168.104:22122->10.10.168.104:46410 (ESTABLISHED)
fdfs_trac 1605 root 26u IPv4 13699 0t0 TCP 10.10.168.104:22122->10.10.168.105:filenet-rmi (ESTABLISHED)
fdfs_trac 1605 root 27u IPv4 13705 0t0 TCP 10.10.168.104:22122->10.10.168.105:32781 (ESTABLISHED)
fdfs_stor 1631 root 26u IPv4 135680 0t0 TCP 10.10.168.104:41466->10.10.168.105:22122 (SYN_SENT)
fdfs_stor 1631 root 27u IPv4 13685 0t0 TCP 10.10.168.104:46410->10.10.168.104:22122 (ESTABLISHED)

storage配置文件:
[root@xiaofan ~]# egrep -v "^#|^$" /etc/fdfs/storage.conf
disabled=false
group_name=group1
bind_addr=
client_bind=true
port=23000
connect_timeout=30
network_timeout=60
heart_beat_interval=30
stat_report_interval=60
base_path=/home/data
max_connections=1000
buff_size = 256KB
work_threads=4
disk_rw_separated = true
disk_reader_threads = 1
disk_writer_threads = 1
sync_wait_msec=50
sync_interval=0
sync_start_time=00:00
sync_end_time=23:59
write_mark_file_freq=500
store_path_count=1
store_path0=/home/data/storage
subdir_count_per_path=256
tracker_server=10.10.168.104:22122
tracker_server=10.10.168.105:22122
log_level=info
run_by_group=
run_by_user=
allow_hosts=*
file_distribute_path_mode=0
file_distribute_rotate_count=100
fsync_after_written_bytes=0
sync_log_buff_interval=10
sync_binlog_buff_interval=10
sync_stat_file_interval=300
thread_stack_size=512KB
upload_priority=10
if_alias_prefix=
check_file_duplicate=0
file_signature_method=hash
key_namespace=FastDFS
keep_alive=0
use_access_log = false
rotate_access_log = false
access_log_rotate_time=00:00
rotate_error_log = false
error_log_rotate_time=00:00
rotate_access_log_size = 0
rotate_error_log_size = 0
file_sync_skip_invalid_record=false
use_connection_pool = false
connection_pool_max_idle_time = 3600
http.domain_name=
http.server_port=8888

iptables规则:
-A INPUT -m state --state NEW -m tcp -p tcp --dport23000 -j ACCEPT

启动stroage:
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
#启动时会看到屏幕创建一叠的目录。

检查端口:
[root@xiaofan ~]# lsof -i :23000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
fdfs_stor 1631 root 5u IPv4 13670 0t0 TCP *:inovaport1 (LISTEN)
fdfs_stor 1631 root 29u IPv4 13701 0t0 TCP 10.10.168.104:inovaport1->10.10.168.105:39237 (ESTABLISHED)

如果报错libevent库找不到:
解决方法1:
find / -name libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
解决方法2:
find / -name libevent-2.0.so.5
[root@xiaofan ~]# tail -1 /etc/profile
export LD_LIBRARY_PATH=/usr/local/lib/
[root@xiaofan ~]# source /etc/profile

二、安装配置nginx结合fastdfs:
[root@xiaofan fxh]# tar xf fastdfs-nginx-module_v1.16.tar.gz
[root@xiaofan fxh]# tar xf nginx-1.2.0.tar.gz
[root@xiaofan fxh]# yum install -y pcre-devel zlib-devel
[root@xiaofan fxh]# cd nginx-1.2.0
[root@xiaofan nginx-1.2.0]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --add-module=/home/fxh/fastdfs-nginx-module/src --with-http_ssl_module
[root@xiaofan nginx-1.2.0]# make
[root@xiaofan nginx-1.2.0]# make install

修改配置文件mod_fastdfs:
[root@xiaofan nginx-1.2.0]# cp /home/fxh/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[root@xiaofan nginx-1.2.0]# egrep -v "^#|^$" /etc/fdfs/mod_fastdfs.conf
connect_timeout=2 #
network_timeout=30
base_path=/home/data
load_fdfs_parameters_from_tracker=true
storage_sync_file_max_delay = 86400
use_storage_id = false
storage_ids_filename = storage_ids.conf
tracker_server=10.10.168.104:22122
tracker_server=10.10.168.105:22122
storage_server_port=23000
group_name=group1
url_have_group_name = true
store_path_count=1
store_path0=/home/data/storage
log_level=info
log_filename=
response_mode=proxy
if_alias_prefix=
flv_support = true
flv_extension = flv
group_count = 0
/usr/local/nginx/sbin/nginx

进行文件上传测试:

修改client配置文件:
[root@xiaofan ~]# egrep -v "^#|^$" /etc/fdfs/client.conf
connect_timeout=30
network_timeout=60
base_path=/home/data
tracker_server=10.10.168.104:22122
tracker_server=10.10.168.105:22122
log_level=info
use_connection_pool = false
connection_pool_max_idle_time = 3600
load_fdfs_parameters_from_tracker=false
use_storage_id = false
storage_ids_filename = storage_ids.conf
http.tracker_server_port=8080

修改nginx配置文件:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
  server_name localhost;
  #charset koi8-r;
  #access_log logs/host.access.log main;
  location /group1/M00 {
  #alias /home/data/storage/data;
  root /home/data/storage/data;
  ngx_fastdfs_module;
   }
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
    }
  }
}

修改iptables配置:
-A INPUT -m state --state NEW -m tcp -p tcp --dport80 -j ACCEPT

启动ngnx:
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx

进行测试:
[root@xiaofan ~]# echo "test" > test.txt
[root@xiaofan ~]# /usr/local/bin/fdfs_upload_file /etc/fdfs/client.conf ./test.txt
group1/M00/00/00/CgqoaFixY6SAb2xYAAAABelE2rQ054.txt
[root@xiaofan ~]# curl http://10.10.168.104/group1/M00/00/00/CgqoaFixY6SAb2xYAAAABelE2rQ054.txt
test

上传个图片测试:
[root@xiaofan 00]# pwd
/home/data/storage/data/00/00
[root@xiaofan 00]# ls
Cgoel1c0YxqAcDLvAAB5mpJABlg563.jpg CgqoaFixY6SAb2xYAAAABelE2rQ054.txt

fastdfs+nginx的安装部署的更多相关文章

  1. Nginx详细安装部署教程

    一.Nginx简介 Nginx是一个web服务器也可以用来做负载均衡及反向代理使用,目前使用最多的就是负载均衡,具体简介我就不介绍了百度一下有很多,下面直接进入安装步骤 二.Nginx安装 1.下载N ...

  2. Nginx 详细安装部署教程

    一.Nginx简介 Nginx是一个web服务器也可以用来做负载均衡及反向代理使用,目前使用最多的就是负载均衡,具体简介我就不介绍了百度一下有很多,下面直接进入安装步骤 二.Nginx安装 1.下载N ...

  3. Nginx详细安装部署教程(转)

    一.Nginx简介 Nginx是一个web服务器也可以用来做负载均衡及反向代理使用,目前使用最多的就是负载均衡,具体简介我就不介绍了百度一下有很多,下面直接进入安装步骤 二.Nginx安装 1.下载N ...

  4. FastDFS+Nginx分布式文件系统部署安装

    安装: ##安装tracker.storage参考:http://www.cnblogs.com/zclzhao/p/5025229.html nginx代理设置参考:http://www.cnblo ...

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

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

  6. centos 系统下安装FastDFS+nginx+fastdfs-nginx-module安装配置

    前言: 以前的项目上传的文件都是保存到本地或者是局域网内的共享文件夹下,由于数据量,服务器的负载均衡(分机的某些图片无法访问的问题处理)等因素的情况下,就想到用fastdfs来文件管理,花了几天时间硬 ...

  7. nginx的安装部署以及使用

    [介绍] nginx是现在互联上非常流行的高性能的 Web 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器. 现在很多互联网应用都使用nginx来作为负载均衡的使用,再高并发 ...

  8. 分布式文件系统之FastDFS安装部署

    前面我们了解了分布式文件系统mogilefs的框架以及安装部署和简单使用,回顾请参考https://www.cnblogs.com/qiuhom-1874/tag/MogileFS/:今天我们来了解下 ...

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

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

随机推荐

  1. Unity3D基础

    鼠标事件: OnMouseEnter():鼠标进入 OnMouseExit():鼠标移出 OnMouseDown():鼠标点击 OnMouseUp():鼠标抬起 static GameObject I ...

  2. 实现两个jQuery的API(addClass、text)

    目的 给所有的div添加一个叫“red”的class,为方便看到代码的效果,设置如下css,在设置“red”成功时,文本会变红 .red{ color:red; } 将所有的div中的textCont ...

  3. Apache-TomCat安装配置

    Apache-TomCat安装配置 本文是免安装版的Tomcat!(安装JavaJDK的步骤就不多述了!) (1)官网下载地址:https://tomcat.apache.org/download-8 ...

  4. 聊聊 TCP 中的 KeepAlive 机制

    KeepAlive并不是TCP协议规范的一部分,但在几乎所有的TCP/IP协议栈(不管是Linux还是Windows)中,都实现了KeepAlive功能 RFC1122#TCP Keep-Alives ...

  5. Object-oriented programming

    Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects&qu ...

  6. 21_HTML&CSS

    今日内容: 1. HTML标签:表单标签​2. CSS: HTML标签:表单标签 * 表单: * 概念:用于采集用户输入的数据的.用于和服务器进行交互. * form:用于定义表单的.可以定义一个范围 ...

  7. java导出html页面

    http://blog.csdn.net/zhyh1986/article/details/8727523#t6 http://blog.csdn.net/zuozuofuwaiwai/article ...

  8. Pyhton学习——Day9(阶段性练习)

    # 1.文件内容如下,标题为:姓名,性别,年纪,薪资## egon male 18 3000# alex male 38 30000# wupeiqi female 28 20000# yuanhao ...

  9. [置顶] 谷歌大牛 Jeff Dean 是如何成为互联网战神的

    谷歌大牛 Jeff Dean 是如何成为互联网战神的 原文链接: Will Oremus   翻译: 伯乐在线- Lex Lian 译文链接: http://blog.jobbole.com/4772 ...

  10. .NET开源项目一览