当前位置: 首页 > cloud, dfs > 正文

fastdfs体验

download source code

wget http://fastdfs.googlecode.com/files/FastDFS_v4.04.tar.gz

yum install libevent libevent-devel

Setup#step 1. download FastDFS source package and unpack ittar xzf FastDFS_v4.04.tar.gz#for example:tar xzf FastDFS_v4.04.tar.gz

#step 2. enter the FastDFS dir
cd FastDFS

#step 3. enter the FastDFS dir
cd FastDFS

#step 4. if build-in HTTP supported, modify make.sh, uncomment the line:
WITH_HTTPD=1, then execute:
./make.sh

#step 5. make install
./make.sh install

#step 6. edit/modify the config file of tracker and storage

#step 7. run server programs
#start the tracker server:
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
#in Linux, you can start fdfs_trackerd as a service:
/sbin/service fdfs_trackerd start

#start the storage server:
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
#in Linux, you can start fdfs_storaged as a service:
/sbin/service fdfs_storaged start

#step 8. run test program
#for example, upload a file:
/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /var/tmp/test.txt

Test

[root@2hei.net tmp]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /var/tmp/test.txt
This is FastDFS client test program v4.04

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.

[2013-01-21 13:32:42] DEBUG – base_path=/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0

tracker_query_storage_store_list_without_group:
server 1. group_name=group1, ip_addr=192.168.1.143, port=23000
server 2. group_name=group1, ip_addr=192.168.1.145, port=23000

group_name=group1, ip_addr=192.168.1.143, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgBj1D81MWAQGkSAAAAENuTjTk391.txt
source ip address: 192.168.1.143
file timestamp=2013-01-21 13:40:21
file size=16
file crc32=3683880249
file url: http://192.168.1.145:8080/group1/M00/00/00/wKgBj1D81MWAQGkSAAAAENuTjTk391.txt
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgBj1D81MWAQGkSAAAAENuTjTk391_big.txt
source ip address: 192.168.1.143
file timestamp=2013-01-21 13:40:21
file size=16
file crc32=3683880249
file url: http://192.168.1.145:8080/group1/M00/00/00/wKgBj1D81MWAQGkSAAAAENuTjTk391_big.txt
http://192.168.1.145:8080/group1/M00/00/00/wKgBj1D81MWAQGkSAAAAENuTjTk391_big.txt
http://192.168.1.145:8080/group1/M00/00/00/wKgBkVD81TiAeNCzAAA6besPniU192_big.jpg
http://192.168.1.145:8080/group1/M00/00/00/wKgBj1D82M6Ad1q2ABTqYBjVNKM419_big.apk
http://192.168.1.143:8888/status.html

启动

/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

重启:

/usr/local/bin/restart.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/local/bin/restart.sh /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

查看状态

/usr/local/bin/fdfs_monitor /etc/fdfs/client.conf

查看日志

 cd /home/fastdfs/logs /usr/local/bin/fdfs_download_file /etc/fdfs/client.conf <file_id> [local_filename] /usr/local/bin/fdfs_delete_file /etc/fdfs/client.conf <file_id>

其他命令

/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /var/tmp/down.txt
/usr/local/bin/fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKgBj1D81MWAQGkSAAAAENuTjTk391_big.txt down.txt
/usr/local/bin/fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKgBkVD82bKANF3-AAAAENuTjTk783_big.txt

至此简单的体验了一下fastdfs,各语言api的调用后续添加。

本文固定链接: https://www.2hei.net/2013/01/21/fastdfs_use_1/ | 2hei.net

该日志由 u2 于2013年01月21日发表在 cloud, dfs 分类下,
原创文章转载请注明: fastdfs体验 | 2hei.net
关键字:

报歉!评论已关闭.