FastDFS-5.08 安装部署

image

1.FastDFS介绍

FastDFS是一款开源的轻量级分布式文件系统,
-纯C实现,支持Linux,FreeBSD等UNIX系统,
-类goolge FS,不是通用的文件系统,只能通过专有API访问,目前提供了C,java和PHP API
-为互联网应用量身定做,追求高性能和高扩展
-FastDFS可以看做是基于文件的key value pair存储系统,称作为分布式文件存储服务更合适

2.FastDFS github地址

 https://github.com/happyfish100/

3.FastDFS上传原理
 - storage定时向tracker上传状态信息
 - client上传连接请求到tracker
 - tracker查询可用的storage,并返回storage的ip和端口
 - 上传文件fIlecontent和meta data
 - 生成file_id,将上传的内容写入磁盘,并返回file_id路径和文件名

4.安装FastDFS依赖lib包

cd /usr/local/src/
git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon/
./make.sh
./make.sh install

 5.安装FastDFS--v5.08

cd /usr/local/src
wget http://nchc.dl.sourceforge.net/project/fastdfs/FastDFS%20Server%20Source%20Code/FastDFS%20Server%20with%20PHP%20Extension%20Source%20Code%20V5.08/FastDFS_v5.08.tar.gz
tar -zxvf FastDFS_v5.08.tar.gz
cd FastDFS
./make.sh
./make.sh install

6.tracker配置

sed -i 's#/usr/local/bin/#/usr/bin/#g' /etc/init.d/fdfs_trackerd
mkdir -p /data/fastdfs/tracker

cd /etc/fdfs/
cp tracker.conf.sample tracker.conf
vim tracker.conf
disabled=false                  #启用配置文件 
port=22122                      #设置 tracker 的端口号 
base_path=/data/fastdfs/tracker #设置 tracker 的数据文件和日志目录(需预先创建) 
http.server_port=8888           #设置 http 端口号 
http.server_port=8888           #指的是在tracker服务器上启动http服务进程,如:apache或者nginx 启动时所监听的端口

/etc/init.d/fdfs_trackerd start

 7.storage配置

sed -i 's#/usr/local/bin/#/usr/bin/#g' /etc/init.d/fdfs_storaged
mkdir -p /data/fastdfs/base
mkdir -p /data/fastdfs/data

cd /etc/fdfs/
cp storage.conf.sample storage.conf
vim storage.conf
disabled=false                        #启用配置文件
group_name=group1                     #组名,根据实际情况修改
port=23000                            #设置 storage 的端口号
base_path=/data/fastdfs/base          #设置 storage 的日志目录(需预先创建)
store_path_count=1                    #存储路径个数,需要和 store_path 个数匹配
store_path0=/data/fastdfs/date        #存储路径
tracker_server=10.10.10.81:22122      #tracker 服务器的 IP 地址和端口号
http.server_port=8888                 #设置storage上启动的http服务的端口号,如安装的nginx的端口号

/etc/init.d/fdfs_storage start

 12.客户端文件配置

[root@localhost fdfs]# cp client.conf.sample cilent.conf
[root@img01 fdfs]# grep -Ev '^$|^#' /etc/fdfs/client.conf
connect_timeout=30
network_timeout=60
base_path=/data/fastdfs/fdfs_client      # 日志路径
tracker_server=172.16.1.40:22122         # 追踪服务器的IP,有多个服务器可以另一行
log_level=info
use_connection_pool = false
connection_pool_max_idle_time = 3600
load_fdfs_parameters_from_tracker=false
use_storage_id = false
storage_ids_filename = storage_ids.conf
http.tracker_server_port=80

 # 上传文件

[root@img01 fdfs]# fdfs_upload_file /etc/fdfs/client.conf /etc/passwd
G1/M00/00/00/rBABKVe79c-ATItLAAAETQvMt7M7741798

 # 下载文件

[root@img01 fdfs]# fdfs_download_file /etc/fdfs/client.conf G1/M00/00/00/rBABKVe79c-ATItLAAAETQvMt7M7741798

 # 查看文件信息

[root@img01 fdfs]# fdfs_file_info /etc/fdfs/client.conf G1/M00/00/00/rBABKVe79c-ATItLAAAETQvMt7M7741798
source storage id: 0
source ip address: 172.16.1.41
file create timestamp: 2016-08-23 15:05:51
file size: 1101
file crc32: 197965747 (0x0BCCB7B3)

# 查看客户端信息
[root@localhost ~]# fdfs_monitor /etc/fdfs/client.conf

[root@img01 fdfs]# fdfs_monitor /etc/fdfs/client.conf
[2016-08-23 15:09:29] DEBUG - base_path=/data/fdfs/fdfs_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: 0

server_count=1, server_index=0

tracker server is 172.16.1.40:22122

group count: 1

Group 1:
group name = G1
disk total space = 17944 MB
disk free space = 14902 MB
trunk free space = 0 MB
storage server count = 1
active server count = 1
storage server port = 23000
storage HTTP port = 8888
store path count = 1
subdir count per path = 256
current write server index = 0
current trunk file id = 0

        Storage 1:
                id = 172.16.1.41
                ip_addr = 172.16.1.41  ACTIVE
                http domain = 
                version = 5.05
                join time = 2016-08-19 21:28:08
                up time = 2016-08-19 21:37:31
                total storage = 17944 MB
                free storage = 14902 MB
                upload priority = 10
                store_path_count = 1
                subdir_count_per_path = 256
                storage_port = 23000
                storage_http_port = 8888
                current_write_path = 0
                source storage id = 
                if_trunk_server = 0
                connection.alloc_count = 256
                connection.current_count = 1
                connection.max_count = 2
                total_upload_count = 27
                success_upload_count = 27
                total_append_count = 0
                success_append_count = 0
                total_modify_count = 0
                success_modify_count = 0
                total_truncate_count = 0
                success_truncate_count = 0
                total_set_meta_count = 8
                success_set_meta_count = 8
                total_delete_count = 16
                success_delete_count = 16
                total_download_count = 9
                success_download_count = 9
                total_get_meta_count = 4
                success_get_meta_count = 4
                total_create_link_count = 0
                success_create_link_count = 0
                total_delete_link_count = 0
                success_delete_link_count = 0
                total_upload_bytes = 471624
                success_upload_bytes = 471624
                total_append_bytes = 0
                success_append_bytes = 0
                total_modify_bytes = 0
                success_modify_bytes = 0
                stotal_download_bytes = 1191
                success_download_bytes = 1191
                total_sync_in_bytes = 0
                success_sync_in_bytes = 0
                total_sync_out_bytes = 0
                success_sync_out_bytes = 0
                total_file_open_count = 40
                success_file_open_count = 40
                total_file_read_count = 13
                success_file_read_count = 13
                total_file_write_count = 27
                success_file_write_count = 27
                last_heart_beat_time = 2016-08-23 15:09:28
                last_source_update = 2016-08-23 15:05:50
                last_sync_update = 1970-01-01 08:00:00
                last_synced_timestamp = 1970-01-01 08:00:00 
[root@img01 fdfs]# 

参考文档:

http://www.cnblogs.com/Yin-BloodMage/p/5433629.html

http://blog.csdn.net/xifeijian/article/details/38567839
http://www.open-open.com/lib/view/open1435468300700.html

 

 
posted @ 2016-08-23 12:16  sunmmi  阅读(3477)  评论(0编辑  收藏  举报