FastDFS安装使用实战一(安装篇)

        最近在研究负载均衡和集群,其中涉及到一个主要的问题是,如何让集群中的real server共享一套文件系统。在网上查到FastDFS,国人(happy fish,感谢他的开源精神)开发的一套轻量级分布式文件系统。实际搭建了一下,感觉还不错,小巧易用,支持http下载。

      虽然FastDFS官方网站上已经有比较详细的安装使用手册,但在实际搭建过程中,还是遇到了很多问题,希望我的记录可以让后来的同学们少走一些弯路:)

下面进入正题。

FastDFS安装使用实战(安装篇)

Keywords:FastDFS、分布式文件系统、Ubuntu

Author:soartju

转载请注明出处:http://soartju.iteye.com/blog/803477


目前FastDFS支持Unix系统,在Linux和FreeBSD下测试过,本文使用的是Ubuntu10.4,建议安装之前先简单了解一下FastDFS的原理,这对后继的配置部分会有很好的理解。

一、准备工作-安装libevent

FastDFS内部绑定了libevent作为http服务器,在V2.X版本必须安装libevent,本文安装的是V2.2版本,因此必须安装libevent。(官方也推荐使用http方式下载文件)


如果已经安装了libevent,请确认安装路径是/usr,因为FastDFS在编译源程序时,需要到此目录下查找一些依赖文件,否则编译FastDFS会出错。如果不是,建议首先卸载libevent。Ubuntu10.4默认是安装了libevent,可以到软件中心卸载掉然后按照下面介绍的方式安装。

安装步骤:

1、fastDFS需要安装libevent比较新的版本,首先将本机的比较低的版本卸载了:

rpm -qa libevent

libevent-1.4.13-1.el6.x86_64
rpm -e --nodeps libevent

安装一个最新稳定版:wget https://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz

tar zxvf libevent-2.0.18-stable.tar.gz

cd libevent-2.0.18-stable

./configure
make && make install
为libevent创建软链接到/lib库下,64位系统对应/lib64

ln -s /usr/local/lib/libevent* /lib/
ln -s /usr/local/lib/libevent* /lib64/

2、安装FastDFS:
wget http://fastdfs.googlecode.com/files/FastDFS_v3.06.tar.gz
tar zxvf FastDFS_v3.06.tar.gz
cd FastDFS
./make.sh
./make.sh install

3、可是注意一点儿,就是如果有需要HTTP连接的需要在make.sh中将#WITH_HTTPD=1改成WITH_HTTPD=1,然后在安装。

4、当我在安装FastDFS时报错了:

  1. /home/FastDFS/FastDFS/tracker/../common/sched_thread.c:493: undefined reference to `pthread_create' ../common/pthread_func.o:   
  2. In function `init_pthread_lock': /home/FastDFS/FastDFS/tracker/../common/pthread_func.c:32: undefined reference to `pthread_mutexattr_init'   
  3. /home/FastDFS/FastDFS/tracker/../common/pthread_func.c:40: undefined reference to `pthread_mutexattr_settype'   
  4. /home/FastDFS/FastDFS/tracker/../common/pthread_func.c:57: undefined reference to `pthread_mutexattr_destroy' ../common/pthread_func.o:  
  5.  In function `init_pthread_attr': /home/FastDFS/FastDFS/tracker/../common/pthread_func.c:84: undefined reference to `pthread_attr_getstacksize'   
  6. /home/FastDFS/FastDFS/tracker/../common/pthread_func.c:115: undefined reference to `pthread_attr_setstacksize' ../common/pthread_func.o:   
  7. In function `create_work_threads': /home/FastDFS/FastDFS/tracker/../common/pthread_func.c:156: undefined reference to `pthread_create'   
  8. ../common/pthread_func.o:   
  9. In function `kill_work_threads': /home/FastDFS/FastDFS/tracker/../common/pthread_func.c:182: undefined reference to `pthread_kill'   
  10. collect2: ld 返回 1 make: *** [fdfs_monitor] 错误 1   

     经过在网上的查找得知:其实是不同的系统中pthread位置不一样,做法就是找到你的系统中所需要的libpthread.so文件位置,直接find就可以找到了;

  1. root@ www.linuxidc.com:~# find / -name 'libpthread.a'  
  2. /usr/lib/i386-linux-gnu/xen/libpthread.a  
  3. /usr/lib/i386-linux-gnu/libpthread.a  
  4. root@ www.linuxidc.com:~# find / -name 'libpthread.so'  
  5. /usr/lib/i386-linux-gnu/libpthread.so  

    接着直接在make.sh中找到这句话然后替换掉就可以了:

  1. if [ -f /usr/lib/libpthread.so ] || [ -f /usr/local/lib/libpthread.so ] || [ -f /usr/lib64/libpthread.so ] || [ -f /usr/lib/libpthread.a ] || [ -f /usr/local/lib/libpthread.a ] || [ -f /usr/lib64/libpthread.a ]; then   LIBS="$LIBS -lpthread"   

    然后在进行编译就OK了。

  1. ./make.sh  
  2. ./make.sh install  
  3. Cd /home/FastDFS/FastDFS/conf/  



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值