FastDFS之安装测试

来源:互联网 发布:mp3音量增大软件 编辑:程序博客网 时间:2024/06/07 18:03
server端分为两个部分,一个是tracker,一个是storage。前者调度管理,负载均衡,后者则是实际的存储节点。两个都能做成集群,以防止单点故障。以前的4.x版本依赖libevent, FastDFS_v5.05依赖libfastcommon,只需安装libfastcommon即可。
以下安装最新版本,下载地址:http://sourceforge.net/projects/fastdfs/files
一、安装

1.安装libfastcomm

wget https://github.com/happyfish100/libfastcommon/archive/master.zip

unzip master.zip 
mv libfastcommon-master libfastcommon
cd libfastcommon/
./make.sh 
./make.sh install
确认make没有错误后,执行安装,64位系统默认会复制到/usr/lib64下。
这时候需要设置环境变量或者创建软链接
export LD_LIBRARY_PATH=/usr/lib64/
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
2.安装FastDFS
wget https://github.com/happyfish100/fastdfs/archive/master.zip
unzip master.zip 
mv fastdfs-master fastdfs
./make.sh
./make.sh install
确认make没有错误后,执行安装,默认会安装到/usr/bin中,并在/etc/fdfs中添加三个配置文件。
二、配置
简单配置,测试使用,关于集群等后续再讲解。
1.tracker
cp tracker.conf.sample  tracker.conf
修改:
base_path=/home/fastdfs/tracker #用于存放日志
2.storage
cp storage.conf.sample storage.conf
修改:
base_path=/home/fastdfs/storage #用于存放日志
store_path0=/home/fastdfs/storage0 #存放数据,若不设置默认为前面那个。
tracker_server=192.168.18.178:22122 #指定tracker服务器地址。
三、启动服务
1.启动tracker

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
2.启动storage
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
检查启动进程:
ps -ef | grep fdfsroot     60894     1  0 01:04 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.confroot     60971     1  0 01:07 ?        00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.confroot     60985 43839  0 01:08 pts/0    00:00:00 grep fdfs
检查启动端口:
netstat -aopn | grep fdfstcp        0      0 0.0.0.0:23000               0.0.0.0:*                   LISTEN      60971/fdfs_storaged off (0.00/0/0)tcp        0      0 0.0.0.0:22122               0.0.0.0:*                   LISTEN      60894/fdfs_trackerd off (0.00/0/0)tcp        0      0 192.168.18.178:22122        192.168.18.178:42090        ESTABLISHED 60894/fdfs_trackerd keepalive (61.00/0/0)tcp        0      0 192.168.18.178:42090        192.168.18.178:22122        ESTABLISHED 60971/fdfs_storaged keepalive (61.00/0/0)
四、上传/删除测试
修改/etc/fdfs/client.conf
base_path=/home/fastdfs/client
tracker_server=192.168.18.178:22122
使用自带的fdfs_test来测试,使用格式如下:
fdfs_test /etc/fdfs/client.conf upload  /home/fastdfs/7.jpg This is FastDFS client test program v5.06Copyright (C) 2008, Happy Fish / YuQingFastDFS may be copied only under the terms of the GNU GeneralPublic 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-05-26 01:18:27] DEBUG - base_path=/home/fastdfs/client, 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: 0tracker_query_storage_store_list_without_group:         server 1. group_name=, ip_addr=192.168.18.178, port=23000group_name=group1, ip_addr=192.168.18.178, port=23000storage_upload_by_filenamegroup_name=group1, remote_filename=M00/00/00/wKgSslVkLFOAWOw_AADfP3RIu5Y687.jpgsource ip address: 192.168.18.178file timestamp=2015-05-26 01:18:27file size=57151file crc32=1950923670example file url: http://192.168.18.178/group1/M00/00/00/wKgSslVkLFOAWOw_AADfP3RIu5Y687.jpgstorage_upload_slave_by_filenamegroup_name=group1, remote_filename=M00/00/00/wKgSslVkLFOAWOw_AADfP3RIu5Y687_big.jpgsource ip address: 192.168.18.178file timestamp=2015-05-26 01:18:27file size=57151file crc32=1950923670example file url: http://192.168.18.178/group1/M00/00/00/wKgSslVkLFOAWOw_AADfP3RIu5Y687_big.jpg
example file url是不能在浏览器中直接打开的,除非配合nginx使用。
使用fdfs_delete_file来删除文件,使用格式如下:
fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKgSslVkLFOAWOw_AADfP3RIu5Y687_big.jpg

删除文件需要完整的group_name和remote_filename。

配置参考文章:

1.FastDFS配置详解之Tracker配置
2.FastDFS配置详解之Storage配置
3.FastDFS 使用经验分享

0 0
原创粉丝点击