fastDFS分布式文件系统的部署

安装libfastcommon

libfastcommon是FastDFS官方提供的,libfastcommon包含了FastDFS运行所需要的一些基础库。

将libfastcommonV1.0.7.tar.gz拷贝至/usr/local/下

cd /usr/local

tar -zxvf libfastcommonV1.0.7.tar.gz

cd libfastcommon-1.0.7

./make.sh

./make.sh install

注意:libfastcommon安装好后会自动将库文件拷贝至/usr/lib64下,由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件libfastcommon.so拷贝至/usr/lib下。

tracker编译安装

将FastDFS_v5.05.tar.gz拷贝至/usr/local/下

tar -zxvf FastDFS_v5.05.tar.gz 

cd FastDFS

./make.sh

./make.sh install

安装成功将安装目录下的conf下的文件拷贝到/etc/fdfs/下。

 配置

安装成功后进入/etc/fdfs目录

拷贝一份新的tracker配置文件:

cp tracker.conf.sample tracker.conf

修改tracker.conf

vi tracker.conf

base_path=/home/yuqing/FastDFS  

改为:

base_path=/home/FastDFS

配置http端口:

http.server_port=80

启动

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

 FastDFS--storage安装

进入/etc/fdfs目录:

拷贝一份新的storage配置文件:

cp storage.conf.sample storage.conf

修改storage.conf

vi storage.conf

group_name=group1

base_path=/home/yuqing/FastDFS改为:base_path=/home/FastDFS

store_path0=/home/yuqing/FastDFS改为:store_path0=/home/FastDFS/fdfs_storage

#如果有多个挂载磁盘则定义多个store_path,如下

#store_path1=.....

#store_path2=......
tracker_server=192.168.101.3:22122   #配置tracker服务器:IP

#如果有多个则配置多个tracker

tracker_server=192.168.101.4:22122

#配置http端口

http.server_port=80

启动

/usr/bin/fdfs_storage /etc/fdfs/storage.conf restart

上传图片测试

FastDFS安装成功可通过/usr/bin/fdfs_test测试上传、下载等操作。 

修改/etc/fdfs/client.conf

base_path=/home/fastdfs

tracker_server=192.168.101.3:22122

tracker_server=192.168.101.4:22122

使用格式:

/usr/bin/fdfs_test 客户端配置文件地址  upload  上传文件 

比如将/home下的图片上传到FastDFS中:

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/tomcat.png

打印如下日志:

This is FastDFS client test program v5.05

 

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.

 

[2015-05-18 02:07:10] DEBUG - base_path=/home/FastDFS, 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.101.5, port=23000

         server 2. group_name=, ip_addr=192.168.101.6, port=23000

 

group_name=group1, ip_addr=192.168.101.5, port=23000

storage_upload_by_filename

group_name=group1, remote_filename=M00/00/00/wKhlBVVY2M-AM_9DAAAT7-0xdqM485.png

source ip address: 192.168.101.5

file timestamp=2015-05-18 02:07:11

file size=5103

file crc32=3979441827

example file url: http://192.168.101.5/group1/M00/00/00/wKhlBVVY2M-AM_9DAAAT7-0xdqM485.png

storage_upload_slave_by_filename

group_name=group1, remote_filename=M00/00/00/wKhlBVVY2M-AM_9DAAAT7-0xdqM485_big.png

source ip address: 192.168.101.5

file timestamp=2015-05-18 02:07:11

file size=5103

file crc32=3979441827

example file url: http://192.168.101.5/group1/M00/00/00/wKhlBVVY2M-AM_9DAAAT7-0xdqM485_big.png

http://192.168.101.5/group1/M00/00/00/wKhlBVVY2M-AM_9DAAAT7-0xdqM485_big.png就是文件的下载路径。

对应storage服务器上的

/home/fastdfs/fdfs_storage/data/00/00/wKhlBVVY2M-AM_9DAAAT7-0xdqM485_big.png文件。

posted @ 2017-05-26 14:07  崔布斯  阅读(278)  评论(0编辑  收藏  举报