FastDFS安装与配置

一、编译安装

[root@db1 ~]# wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.14  
-stable.tar.gz  
[root@db1 ~]# tar -zxvpf libevent-2.0.14-stable.tar.gz   
[root@db1 ~]# cd libevent-2.0.14-stable  
[root@db1 libevent-2.0.14-stable]# ./configure --prefix=/usr/local/libevent-2.0.14 &&   
make && make install  
[root@db1 ~]# wget http://fastdfs.googlecode.com/files/FastDFS_v3.02.tar.gz  
[root@db1 ~]# tar -zxvf FastDFS_v3.02.tar.gz   
[root@db1 ~]# cd FastDFS  
[root@db1 FastDFS]# grep -A 4 '/usr/local/FastDFS' make.sh   
TARGET_PREFIX=/usr/local/app/fastdfs  
TARGET_CONF_PATH=/etc/fdfs  
WITH_HTTPD=1 
WITH_LINUX_SERVICE=1 
[root@db1 FastDFS]# ./make.sh C_INCLUDE_PATH=/usr/local/libevent-2.0.14/include    
LIBRARY_PATH=/usr/local/libevent-2.0.14/lib  
[root@db1 FastDFS]# ./make.sh install  
[root@db1 FastDFS]# ls /etc/fdfs/  
client.conf  http.conf  mime.types  storage.conf  tracker.conf 



二、配置

1、tracker

[root@tracker FastDFS]# vim /etc/fdfs/tracker.conf

一般只需改动以下几个参数即可:
disabled=false            #启用配置文件
port=22122                #设置tracker的端口号
base_path=/fdfs/tracker   #设置tracker的数据文件和日志目录(需预先创建)
http.server_port=8080     #设置http端口号

如需要进行性能调优,可以参照附录的配置文件的详细说明


2、storage

[root@storage1FastDFS]# vim /etc/fdfs/storage.con
一般只需改动以下几个参数即可:
disabled=false            #启用配置文件
group_name=group1#组名,根据实际情况修改
port=23000#设置storage的端口号
base_path=/fdfs/storage#设置storage的日志目录(需预先创建)
store_path_count=1#存储路径个数,需要和store_path个数匹配
store_path0=/fdfs/storage#存储路径
tracker_server=172.16.1.202:22122#tracker服务器的IP地址和端口号
http.server_port=8080     #设置http端口号

如需要进行性能调优,可以参照附录的配置文件的详细说明。

3、修改防火墙

[root@tracker FastDFS]# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22122 -j ACCEPT
[root@storage1 FastDFS]# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 23000 -j ACCEPT
[root@tracker FastDFS]# /etc/init.d/iptables save



三、运行

1、tracker

[root@tracker FastDFS]#/usr/local/app/fastdfs/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
[root@tracker FastDFS]#netstat -unltp | grep fdfs
tcp    0    0.0.0.0:22122       0.0.0.0:*           LISTEN      1766/fdfs_trackerd


2、storage

[root@storage1 FastDFS]#/usr/local/app/fastdfs/bin/fdfs_storaged /etc/fdfs/storage.conf restart
data path: /fdfs/storage/data, mkdir sub dir...
mkdir data path: 00 ...
mkdir data path: 01 ...
mkdir data path: 02 ...
mkdir data path: 03 ...
...
data path: /fdfs/storage/data, mkdir sub dir done.

[root@storage1 FastDFS]#netstat -unltp | grep fdfs
tcp    0    0.0.0.0:23000       0.0.0.0:*           LISTEN      1766/fdfs_storaged


四、测试


1、上传文件

[root@trackernginx-1.4.7]# /usr/local/app/fastdfs/bin/fdfs_upload_file /etc/fdfs/client.conf /mnt/monk.jpg
group3/M00/00/00/rBABz1MzKG6Ad_hBAACKLsUDM60560.jpg

[root@trackernginx-1.4.7]#/usr/local/app/fastdfs/bin/fdfs_test /etc/fdfs/client.conf upload /mnt/monk.jpg


2、下载文件
格式:$FDFS_HOME/bin/fdfs_download_file <config_file> <file_id> [local_filename] [<download_offset> <download_bytes>]

[root@trackernginx-1.4.7]# /usr/local/app/fastdfs/bin/fdfs_download_file /etc/fdfs/client.conf group3/M00/00/00/rBABz1MzKG6Ad_hBAACKLsUDM60560.jpg /home/app/test.tar.gz



参考:
http://ylw6006.blog.51cto.com/470441/948729/
http://www.cnblogs.com/ulex/p/5524388.html





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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值