文件系统FastDFS安装

因项目需要,要使用分布式文件系统,决定使用FastDFS。网上有些例子,但可能是版本不一致,导致几次都安装失败,今天终于搞定了,写出自己的步骤,只是简单的配置,没有更深入的研究。

一、环境及版本

操作系统:Redhat 6 64位

FastDFS:4.06

libevent:1.4.13(这个包网上说必须要按,一般linux的安装盘里就有,我就是使用的安装盘里的文件)

libevent-devel:1.4.13(这个包网上没说要按,但是在编译FastDFS的时候报错:tracker_nio.h:17:19: fatal error: event.h: No such file or directory,上网查找发现需要按这个包[size=16px; line-height: 1.5;])


二、步骤

1、先安装libevent 1.4.13,直接使用rpm命令即可。

rpm -ivh libevent-1.4.13-4.el6.x86_64.rpm



2、安装libevent-devel 1.4.13,直接使用rpm命令即可。

rpm -ivh libevent-devel-1.4.13-1.x86_64.rpm --force --nodeps


3、解压FastDFS的压缩包

我的压缩包位置放在/usr/lws_file目录下的,使用命令
tar -zxvf FastDFS_v4.06.tar.gz
解压出文件夹FastDFS,网上有些文章写此时要修改FastDFS文件目录下的make.sh文件,将#WITH_HTTPD=1的注释符去掉,但是我这里面没有这句代码。

4、编译FastDFS
进入刚解压出的文件目录FastDFS,执行make.sh来编译,
./make.sh


5、安装
第4步不报错,就可以进行安装了。
./make.sh install
,不报错,说明安装成功。
/usr/lws_file/FastDFS/conf目录下会有4个配置文件,分别为
client.conf 客户端上传配置文件
storage.conf 文件存储服务器配置文件
tracker.conf 负责均衡调度服务器配置文件
http.conf http服务器配置文件

6、配置及启动 tracker
打开tracker.conf文件,进行配置

#存放日志的目录,可改为自己的目录,但必须确保目录存在,否则会报错
base_path=/usr/lws_file/FastDFS/track_log

#http端口,将来http下载文件的端口就是他了
http.server_port=8080

#tracker服务器地址,我的ip为192.168.81.128
bind_addr=192.168.81.128

#tracker服务器端口,请选择空闲端口
port=22122

配置完成后,启动tracker服务
/usr/local/bin/fdfs_trackerd /usr/lws_file/FastDFS/conf/tracker.conf


7、配置及启动 storage
打开storage.conf文件,进行配置

#storage服务器地址,我的storage和tracker在一台机器上
bind_addr=192.168.81.128

#storage存放日志的目录,可改为自己的目录,但必须确保目录存在,否则会报错
base_path=/usr/lws_file/FastDFS/storage_log

#文件存放目录,目录必须存在,如果有多个位置用store_path1,store_path2..来区分
store_path0=/usr/lws_file/fdfs_path

#配置tracker ip和端口,对应tracker.conf里的bind_addr和port
tracker_server=192.168.81.128:22122

启动storage

/usr/local/bin/fdfs_storaged /usr/lws_file/FastDFS/conf/storage.conf


8、测试上传
打开client.conf文件,进行配置

#storage 日志存放目录,对应storage.conf中的base_path
base_path=/usr/lws_file/FastDFS/storage_log

#配置tracker服务器的ip和端口
tracker_server=192.168.81.128:22122

#把下面这句代码去掉一个#, 改为 #include http.conf
##include http.conf

然后在/usr/lws_file目录下建一个a.txt文件,作为测试上传的文件。
调用上传命令上传文件

/usr/local/bin/fdfs_test /usr/lws_file/FastDFS/conf/client.conf upload /usr/lws_file/a.txt


如果出现下面代码,说明上传成功

This is FastDFS client test program v4.06

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.

[2014-11-13 23:58:28] DEBUG - base_path=/usr/lws_file/FastDFS/storage_log, 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.81.128, port=23000

group_name=group1, ip_addr=192.168.81.128, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKhRgFRltiSAOUKBAAAAAxcB2-E072.txt
source ip address: 192.168.81.128
file timestamp=2014-11-13 23:58:28
file size=3
file crc32=385997793
file url: http://192.168.81.128:8080/group1/M00/00/00/wKhRgFRltiSAOUKBAAAAAxcB2-E072.txt
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKhRgFRltiSAOUKBAAAAAxcB2-E072_big.txt
source ip address: 192.168.81.128
file timestamp=2014-11-13 23:58:28
file size=3
file crc32=385997793
file url: http://192.168.81.128:8080/group1/M00/00/00/wKhRgFRltiSAOUKBAAAAAxcB2-E072_big.txt

至此文件系统FastDFS已经安装配置完成。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值