最近在研究和使用Fastdfs,别人搭的环境,终究是别人的,绝知此事要躬行~躬行啊~
   
   下面的脚本主要参考了官方的INSTALL文件,这个是比较权威的,部分地方和实际情况不一致。
比如配置文件的名字,Fastdfs的安装位置。

一、下载
    https://github.com/happyfish100/fastdfs fastdfs-5.05.zip

https://github.com/happyfish100/libfastcommon libfastcommon-1.0.7.zip

https://github.com/happyfish100/fastdfs-nginx-module fastdfs-nginx-module.zip
二、安装
先安装libfastcommon-1.0.7.zip

解压命令 unzip libfastcommon-1.0.7.zip

cd  libfastcommon-1.0.7
./make.sh
./make.sh install

再安装fastdfs
unzip fastdfs-5.05.zip
./make.sh
./make.sh install

如果没有先安装libfastcommon,会报错
"执行 ./make.sh 报以下错误:

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."

三、配置和启动
   配置文件的位置
   /etc/fdfs/tracker.conf
   /etc/fdfs/storage.conf
   
   我的CentOS/etc/fdfs 有3个文件client.conf.sample、storage.conf.sample、tracker.conf.sample
   
   直接重命名这3个文件为,*.conf,修改配置~
   先启动tracker
   /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
   再启动storage
   /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
   
   很奇怪,为啥没有start命令,而是restart?
   
   [root@AY1304131823374920ac ~]# ps -ef|grep tracker
root     25433     1  0 16:26 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

[root@AY1304131823374920ac ~]# ps -ef|grep storage
root     25533     1  2 16:28 ?        00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
   
 四、上传
 #把配置文件上传了
 /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/client.conf
 
 [root@AY1304131823374920ac logs]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/client.conf
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-10-28 17:27:29] DEBUG - base_path=/root/fdfsdata, 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=42.96.184.84, port=23000

group_name=group1, ip_addr=42.96.184.84, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/KmC4VFYwlQGAItigAAAFsHrMXek69.conf
source ip address: 42.96.184.84
file timestamp=2015-10-28 17:27:29
file size=1456
file crc32=2060213737
example file url: http://42.96.184.84:8090/group1/M00/00/00/KmC4VFYwlQGAItigAAAFsHrMXek69.conf
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/KmC4VFYwlQGAItigAAAFsHrMXek69_big.conf
source ip address: 42.96.184.84
file timestamp=2015-10-28 17:27:29
file size=1456
file crc32=2060213737
example file url: http://42.96.184.84:8090/group1/M00/00/00/KmC4VFYwlQGAItigAAAFsHrMXek69_big.conf

五、监控
/usr/bin/fdfs_monitor /etc/fdfs/client.conf

[root@AY1304131823374920ac logs]# /usr/bin/fdfs_monitor /etc/fdfs/client.conf
[2015-10-28 17:25:13] DEBUG - base_path=/root/fdfsdata, 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

server_count=1, server_index=0

tracker server is 42.96.184.84:22122

group count: 1

Group 1:
group name = group1
disk total space = 20157 MB
disk free space = 12235 MB
trunk free space = 0 MB
storage server count = 1
active server count = 1
storage server port = 23000
storage HTTP port = 8888
store path count = 1
subdir count per path = 256
current write server index = 0

六、访问文件
   网上找了下,自带的Http可能不能使用,可能啊~
   server {
 46     listen       80;
 47     server_name  file.fansunion.cn;
 48 
 49     location /group1/M00 {
 50         root   /root/fdfsdata/data;
 51          #ngx_fastdfs_module;
 52     }
 53 }
 
 Nginx配置没有使用ngx_fastdfs_module这个模块,出现了403.
    http://file.fansunion.cn/group1/M00/00/00/KmC4VFYwlQGAItigAAAFsHrMXek69_big.conf
   403 Forbidden
   nginx/1.6.2
   
   本地host已经配置了 42.96.184.84 file.fansunion.cn
   
七、尝试安装ngx_fastdfs_module,因为之前总是403各种问题
  参考ngx_fastdfs_module中的INSTALL文档
  1.源码安装Nginx,之前的Nginx是直接安装的
    Nginx下载地址 http://nginx.org/en/download.html

写在之前的Nginx,yum remove nginx

在安装Nginx之前,可能需要安装gcc、 openssl-devel、 pcre-devel和zlib-devel软件库,具体如下:
#没用
yum install gcc-c++
#没用
yum install openssl-devel
#用了
yum install pcre-devel
#用了
yum install zlib-devel

./configure --add-module=/root/soft/fastdfs-nginx-module-master/src 
make; 
make install;

#检查语法
/usr/local/nginx/sbin/nginx -t 
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
从这里可以看出,默认使用的是/usr/local/nginx/conf/nginx.conf这个配置文件

而之前手动命令安装,配置文件在/etc/nginx目录下,这个需要注意哦~

#启动-指定配置文件
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#
/usr/local/nginx/sbin/nginx -s reload

ps -ef|grep nginx
root     20897     1  0 10:39 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
root     20918 13217  0 10:40 pts/3    00:00:00 grep nginx

再次上传 /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/client.conf
访问文件 http://file.fansunion.cn/group1/M00/00/00/KmC4VFYwlQGAItigAAAFsHrMXek69_big.conf
   
    ln -s /root/fdfsdata/data /root/fdfsdata/data/M00

八、搞了半天还没有搞好,气死我了啊~
   配置防火墙,重新启动,重新上传
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 23000 -j ACCEPT
/etc/init.d/iptables save

/usr/local/nginx/sbin/nginx

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
 /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/client.conf
 http://42.96.184.84:8080/group1/M00/00/00/KmC4VFYxlIWAOq-xAAAFsCOGhRQ76_big.conf
 
 netstat -ano |grep 8080
   
   各种调试Nginx,都报错,连最基本的配置都找不到了~
   看Nginx的日志,也没有发现,最后才晓得,Nginx源码安装的日志文件位于“/usr/local/nginx/logs”。
   
   里面报错了,提示/etc/fdfs/下没有mod_fastdfs.conf这个文件~
   
   拷贝一份http.conf到 /etc/fdfs目录下

九、麻痹,麻痹啊~终于搞定了~
  1.base_path 放在/root/fdfsdata和/root/fdfsdata2 下,都提示权限不足。
    放在了/home/fdfsdata下就行了。
  2.mime.types等配置文件,凡是提示找不到,就从fastdfs等原文件的conf目录copy一份到/etc/fdfs/
  3.400或404
    可能是Nginx配置或者group-name那个true选项

没有开启groupname的
http://42.96.184.84:8080/M00/00/00/KmC4VFYxy2OAAqGdAAAFrZvGHAA99.conf
  
  server {
 36         listen       80;
 37         server_name  42.96.184.84 alias file.test;
 38 
 39         location / {
 40            # root /root/fdfsdata/data;
 41            # ngx_fastdfs_module;
 42            root /home/www;
 43            index a.html;
 44         }
 45   }
 46 
 47   server{
 48       listen 8080;
 49       server_name 42.96.184.84;
 50 
 51       location /M00 {
 52          root /home/fdfsdata/data;
 53          ngx_fastdfs_module;
 54       }
 55 
 56   }
 
 第1个server,是测试Nginx能正常启动。
 第2个server,是监听8080端口,不带group的映射,到fdfs的数据目录。
 
 带group的url访问
 http://42.96.184.84:8080/group1/M00/00/00/KmC4VFYxy2OAAqGdAAAFrZvGHAA99.conf
 
 Nginx配置
  location /group1/M00 {
 49          root /home/fdfsdata/data;
 50          ngx_fastdfs_module;
 51       }
 
 /etc/fdfs/mod_fastdfs.conf 这个配置文件吧。
 url_have_group_name = true(默认为false,改为true)
 
 重启tracker、storage
 重启Nginx
 搞定啦~哦也~
 
 十、小结
 花费一天的时间,终于成功搭建了初步的fdfs环境。
 Nginx+Fastdfs。
 
   参考资料:http://blog.csdn.net/gaofuqi/article/details/27052155
   这个人写得有模有样,感觉比较可行啊~
   我自己的,相对比较曲折,各种问题,但是都逐个解决了~
   
   http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=3598287

Centos安装FastDFS+Nginx(一天时间搞定)的更多相关文章

  1. Centos安装FastDFS+Nginx

    一.安装环境: gcc:安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc: yum install gcc-c++ PCRE:PCRE(Perl C ...

  2. 开发者经验谈:如何一天时间搞定iOS游戏开发?

    开发者经验谈:如何一天时间搞定iOS游戏开发? 在一天时间里将完成iPhone游戏开发由梦想变为现实? 本文作者给出了从创意转变成现实的详细答案.使用苹果原生游戏引擎SpriteKit,遵循一定的原则 ...

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

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

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

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

  5. FastDFS单节点安装 & FastDFS+Nginx整合

    安装环境    FastDFS_v5.05.tar.gz(http://sourceforge.net/projects/fastdfs/files/)    fastdfs-nginx-module ...

  6. 安装FastDFS+Nginx

    安装FastDFS FastDFS开发者的GitHub地址为:https://github.com/happyfish100 打开上述链接,我们点击fastdfs–>release,发现最新版的 ...

  7. Linux安装FastDFS~Nginx~

    确保Linux联网,我这里使用的是CentOS7操作,联网教程 https://www.cnblogs.com/taopanfeng/p/10978752.html 先把指定的四个文件放入指定目录 安 ...

  8. centos 安装 rtmp nginx 视频流服务器

    ---恢复内容开始--- 1.使用yum安装git yum -y install git 2.下载nginx-rtmp-module,官方github地址 // 通过git clone 的方式下载到服 ...

  9. mysql安装了半天参考了文章搞定了

    https://blog.csdn.net/yelllowcong/article/details/79641313 mysql -uroot -pbrucelee 总结下: 1.安装时注意具体的路径 ...

随机推荐

  1. Git 内部原理 - (7)维护与数据恢复 (8) 环境变量 (9)总结

    维护与数据恢复 有的时候,你需要对仓库进行清理 - 使它的结构变得更紧凑,或是对导入的仓库进行清理,或是恢复丢失的内容. 这个小节将会介绍这些情况中的一部分. 维护 Git 会不定时地自动运行一个叫做 ...

  2. JavaScript笔记(3)

    •位操作符 所有的按位操作符的操作数都会被转成补码形式的有符号的32位整数. 运算符 用法 描述 按位与(AND) a & b 对于每一个比特位,只有两个操作数相应的比特位都是1时,结果才为1 ...

  3. [Bug]Python3.x SyntaxError: 'ascii' codec can't decode byte 0xe4 in position

    安装arch后就没再用python了 昨天管服务器的大佬在跑贝叶斯分类器的时候发现正确率有问题 我赶紧去做优化,然后就有这样的报错 Python 3.6.4 (default, Jan 5 2018, ...

  4. 同门不同类—创新Aurvana Live2/Air简评(附随身视听设备心路历程)

    (注,本文把live2/air并成一起写的,同时本人是木耳,请轻拍) 本命年各种坏东西,很是无语,终于坏到耳塞耳机了来了,之前用的拜亚DT235无缘无故就一边不响了,无奈只能扔了. 纠结了好几个月,终 ...

  5. 05-数据类型转换(bool类型)

  6. ECNUOJ 2142 放书

    放书 Time Limit:1000MS Memory Limit:65536KBTotal Submit:409 Accepted:173 Description  你要把一叠书放进一些箱子里面,为 ...

  7. mysql(for update)悲观锁总结与实践

    悲观锁,正如其名,它指的是对数据被外界(包括本系统当前的其他事务,以及来自外部系统的事务处理)修改持保守态度,因此,在整个数据处理过程中,将数据处于锁定状态.悲观锁的实现,往往依靠数据库提供的锁机制( ...

  8. linux虚拟机拓展大小

    http://blog.csdn.net/wutong_login/article/details/40147057?utm_source=tuicool http://www.linuxidc.co ...

  9. spring定时器中如何获取servletcontext

    spring定时器中如何获取servletcontext 学习了:https://zhidao.baidu.com/question/406212574.html @Scheduled(cron = ...

  10. OpenStack依然大行其道,可是否能等来属于自己的时代

    版权声明:不论什么转载需全文转载并保留来源(微信公众号techculture)和该声明,并同一时候转载文后的二维码.否则视作侵权. OpenStack在云计算领域依然火热,甚至能够说势不可挡.这可能是 ...