`

fast DFS 单机使用实例

阅读更多

fast DFS 单机使用实例

我在一台服务器上简单测试了fastdfs。client, tracker, storage server都是同一个物理服务器。

 

1. 编译fastdfs:

 

sles207:/opt/mars/FastDFS # ./make.sh

 

storage_service.o: In function `storage_service_init':
/opt/mars/FastDFS/storage/storage_service.c:1100: undefined reference to `event_base_new'
storage_service.o: In function `work_thread_entrance':
/opt/mars/FastDFS/storage/storage_service.c:1364: undefined reference to `event_base_free'
collect2: ld returned 1 exit status
make: *** [fdfs_storaged] Error 1


没有装libevent,需下载安装。(http://monkey.org/~provos/libevent/)

 

 

2. 安装fastdfs:

 

sles207:/opt/mars/FastDFS # ./make.sh install
mkdir -p /usr/local/bin
mkdir -p /etc/fdfs
cp -f fdfs_trackerd  /usr/local/bin
if [ ! -f /etc/fdfs/tracker.conf ]; then cp -f ../conf/tracker.conf ../conf/mime.types ../conf/http.conf /etc/fdfs; fi
mkdir -p /usr/local/bin
mkdir -p /etc/fdfs
cp -f fdfs_storaged  /usr/local/bin
if [ ! -f /etc/fdfs/storage.conf ]; then cp -f ../conf/storage.conf ../conf/mime.types ../conf/http.conf /etc/fdfs; fi
mkdir -p /usr/local/bin
mkdir -p /etc/fdfs
mkdir -p /usr/local/lib
cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender /usr/local/bin
cp -f libfastcommon.so.1 libfdfsclient.so.1 /usr/local/lib
if [ ! -f /etc/fdfs/client.conf ]; then cp -f ../conf/client.conf ../conf/http.conf /etc/fdfs; fi
mkdir -p /usr/local/include
mkdir -p /usr/local/include/fastcommon
mkdir -p /usr/local/include/fastdfs
cp -f ../common/common_define.h ../common/hash.h ../common/chain.h ../common/logger.h ../common/base64.h ../common/shared_func.h ../common/pthread_func.h ../common/ini_file_reader.h ../common/sockopt.h ../common/sched_thread.h ../common/http_func.h ../common/md5.h ../common/_os_bits.h ../common/local_ip_func.h /usr/local/include/fastcommon
cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/local/include/fastdfs
#ln -fs /usr/local/lib/libfastcommon.so.1 /usr/local/lib/libfastcommon.so
#ln -fs /usr/local/lib/libfdfsclient.so.1 /usr/local/lib/libfdfsclient.so
sh ./fdfs_link_library.sh

3. 修改配置文件:

 

a. client.conf:

 

sles207:/etc/fdfs # cat client.conf 
# connect timeout in seconds
# default value is 30s
connect_timeout=30

# network timeout in seconds
# default value is 30s
network_timeout=60

# the base path to store log files
base_path=/opt/mars/fastdfs 

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=10.200.107.207 :22122

#standard log level as syslog, case insensitive, value list:
### emerg for emergency
### alert
### crit for critical
### error
### warn for warning
### notice
### info
### debug
log_level=info


#HTTP settings
http.tracker_server_port=8080

#use "#include" directive to include HTTP other settiongs
##include http.conf

 

b. storage.conf

 

sles207:/etc/fdfs # cat storage.conf 
# is this config file disabled
# false for enabled
# true for disabled
disabled=false

# the name of the group this storage server belongs to
group_name=group2 

# bind an address of this host
# empty for bind all addresses of this host
bind_addr=

# if bind an address of this host when connect to other servers 
# (this storage server as a client)
# true for binding the address configed by above parameter: "bind_addr"
# false for binding any address of this host
client_bind=true

# the storage server port
port=23000

# connect timeout in seconds
# default value is 30s
connect_timeout=30

# network timeout in seconds
# default value is 30s
network_timeout=60

# heart beat interval in seconds
heart_beat_interval=30

# disk usage report interval in seconds
stat_report_interval=60

# the base path to store data and log files
base_path=/opt/mars/fastdfs 

# max concurrent connections server supported
# max_connections worker threads start when this service startup
max_connections=256

# the buff size to recv / send data
# default value is 64KB
# since V2.00
buff_size = 256KB

# work thread count, should <= max_connections
# work thread deal network io
# default value is 4
# since V2.00
work_threads=4

# if disk read / write separated
##  false for mixed read and write
##  true for separated read and write
# default value is true
# since V2.00
disk_rw_separated = true

# if read / write file directly
# if set to true, open file will add the O_DIRECT flag to avoid file caching
# by the file system. be careful to set this parameter.
# default value is false
disk_rw_direct = false

# disk reader thread count per store base path
# for mixed read / write, this parameter can be 0
# default value is 1
# since V2.00
disk_reader_threads = 1

# disk writer thread count per store base path
# for mixed read / write, this parameter can be 0
# default value is 1
# since V2.00
disk_writer_threads = 1

# when no entry to sync, try read binlog again after X milliseconds
# 0 for try again immediately (not need to wait)
sync_wait_msec=200

# after sync a file, usleep milliseconds
# 0 for sync successively (never call usleep)
sync_interval=0

# sync start time of a day, time format: Hour:Minute
# Hour from 0 to 23, Minute from 0 to 59
sync_start_time=00:00

# sync end time of a day, time format: Hour:Minute
# Hour from 0 to 23, Minute from 0 to 59
sync_end_time=23:59

# write to the mark file after sync N files
# default value is 500
write_mark_file_freq=500

# path(disk or mount point) count, default value is 1
store_path_count=1

# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/opt/mars/fastdfs 
#store_path1=/home/yuqing/fastdfs2

# subdir_count  * subdir_count directories will be auto created under each 
# store_path (disk), value can be 1 to 256, default value is 256
subdir_count_per_path=256

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=10.200.107.207 :22122

#standard log level as syslog, case insensitive, value list:
### emerg for emergency
### alert
### crit for critical
### error
### warn for warning
### notice
### info
### debug
log_level=info

#unix group name to run this program, 
#not set (empty) means run by the group of current user
run_by_group=

#unix username to run this program,
#not set (empty) means run by current user
run_by_user=

# allow_hosts can ocur more than once, host can be hostname or ip address,
# "*" means match all ip addresses, can use range like this: 10.0.1.[1-15,20] or
# host[01-08,20-25].domain.com, for example:
# allow_hosts=10.0.1.[1-15,20]
# allow_hosts=host[01-08,20-25].domain.com
allow_hosts=*

# the mode of the files distributed to the data path
# 0: round robin(default)
# 1: random, distributted by hash code
file_distribute_path_mode=0

# valid when file_distribute_to_path is set to 0 (round robin), 
# when the written file count reaches this number, then rotate to next path
# default value is 100
file_distribute_rotate_count=100

# call fsync to disk when write big file
# 0: never call fsync
# other: call fsync when written bytes >= this bytes
# default value is 0 (never call fsync)
fsync_after_written_bytes=0

# sync log buff to disk every interval seconds
# default value is 10 seconds
sync_log_buff_interval=10

# sync binlog buff / cache to disk every interval seconds
# this parameter is valid when write_to_binlog set to 1
# default value is 60 seconds
sync_binlog_buff_interval=60

# sync storage stat info to disk every interval seconds
# default value is 300 seconds
sync_stat_file_interval=300

# thread stack size, should >= 512KB
# default value is 512KB
thread_stack_size=512KB

# the priority as a source server for uploading file.
# the lower this value, the higher its uploading priority.
# default value is 10
upload_priority=10

# the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a
# multi aliases split by comma. empty value means auto set by OS type
# default values is empty
if_alias_prefix=

# if check file duplicate, when set to true, use FastDHT to store file indexes
# 1 or yes: need check
# 0 or no: do not check
# default value is 0
check_file_duplicate=0

# namespace for storing file indexes (key-value pairs)
# this item must be set when check_file_duplicate is true / on
key_namespace=FastDFS

# set keep_alive to 1 to enable persistent connection with FastDHT servers
# default value is 0 (short connection)
keep_alive=0

# you can use "#include filename" (not include double quotes) directive to 
# load FastDHT server list, when the filename is a relative path such as 
# pure filename, the base path is the base path of current/this config file.
# must set FastDHT server list when check_file_duplicate is true / on
# please see INSTALL of FastDHT for detail
##include /home/yuqing/fastdht/conf/fdht_servers.conf


#HTTP settings
http.disabled=false

# use the ip address of this storage server if domain_name is empty,
# else this domain name will ocur in the url redirected by the tracker server
http.domain_name=

# the port of the web server on this storage server
http.server_port=8888

http.trunk_size=256KB

# if need find content type from file extension name
http.need_find_content_type=true

#use "#include" directive to include HTTP other settings
##include http.conf

 

c. tracker.conf

 

# is this config file disabled
# false for enabled
# true for disabled
disabled=false

# bind an address of this host
# empty for bind all addresses of this host
bind_addr=

# the tracker server port
port=22122

# connect timeout in seconds
# default value is 30s
connect_timeout=30

# network timeout in seconds
# default value is 30s
network_timeout=60

# the base path to store data and log files
base_path=/opt/mars/fastdfs 

# max concurrent connections this server supported
max_connections=256

 

(tracker_server不可配置为127.0.0.1, 否则有以下错误 )

sles207:/opt/mars/fastdfs/logs # vi storaged.log 

      1 [2011-04-27 02:13:03] ERROR - file: storage_func.c, line: 1083, conf file "/etc/fdfs/storage.conf", tracker: "127.0.0
        .1:22122" is invalid, tracker server ip can't be 127.0.0.1
      2 [2011-04-27 02:13:17] ERROR - file: storage_func.c, line: 1083, conf file "/etc/fdfs/storage.conf", tracker: "127.0.0
        .1:22122" is invalid, tracker server ip can't be 127.0.0.1
      3 [2011-04-27 02:13:23] ERROR - file: storage_func.c, line: 1083, conf file "/etc/fdfs/storage.conf", tracker: "127.0.0
        .1:22122" is invalid, tracker server ip can't be 127.0.0.1
~     

 

4. 启动tracker server:

                                                               
sles207:/etc/fdfs # /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf


5. 启动 storage server:


sles207:/etc/fdfs # /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

....

 

sles207:/opt/mars/fastdfs/data # ls
.data_init_flag  0B  17  23  2F  3B  47  53  5F  6B  77  83  8F  9B  A7  B3  BF  CB  D7  E3  EF  FB
00               0C  18  24  30  3C  48  54  60  6C  78  84  90  9C  A8  B4  C0  CC  D8  E4  F0  FC
01               0D  19  25  31  3D  49  55  61  6D  79  85  91  9D  A9  B5  C1  CD  D9  E5  F1  FD
02               0E  1A  26  32  3E  4A  56  62  6E  7A  86  92  9E  AA  B6  C2  CE  DA  E6  F2  FE
03               0F  1B  27  33  3F  4B  57  63  6F  7B  87  93  9F  AB  B7  C3  CF  DB  E7  F3  FF
04               10  1C  28  34  40  4C  58  64  70  7C  88  94  A0  AC  B8  C4  D0  DC  E8  F4  storage_changelog.dat
05               11  1D  29  35  41  4D  59  65  71  7D  89  95  A1  AD  B9  C5  D1  DD  E9  F5  storage_groups_new.dat
06               12  1E  2A  36  42  4E  5A  66  72  7E  8A  96  A2  AE  BA  C6  D2  DE  EA  F6  storage_servers_new.dat
07               13  1F  2B  37  43  4F  5B  67  73  7F  8B  97  A3  AF  BB  C7  D3  DF  EB  F7  storage_stat.dat
08               14  20  2C  38  44  50  5C  68  74  80  8C  98  A4  B0  BC  C8  D4  E0  EC  F8  storage_sync_timestamp.dat
09               15  21  2D  39  45  51  5D  69  75  81  8D  99  A5  B1  BD  C9  D5  E1  ED  F9  sync
0A               16  22  2E  3A  46  52  5E  6A  76  82  8E  9A  A6  B2  BE  CA  D6  E2  EE  FA
sles207:/opt/mars/fastdfs/data # 

6. 测试上传文件:


sles207:/etc/fdfs # /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /usr/include/stdlib.h     
This is FastDFS client test program v2.09

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.

[2011-04-27 02:18:42] INFO - base_path=/opt/mars/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=group2, ip_addr=10.200.107.207, port=23000

group_name=group2, ip_addr=10.200.107.207, port=23000
storage_upload_by_filename
group_name=group2, remote_filename=M00/00/00/Cshrz023DILK-oIwAACH_5lVJGU05649.h
source ip address: 10.200.107.207
file timestamp=2011-04-27 02:18:42
file size=34815
file crc32=2572493925
file url: http://10.200.107.207:8080/group2/M00/00/00/Cshrz023DILK-oIwAACH_5lVJGU05649.h
storage_upload_slave_by_filename
group_name=group2, remote_filename=M00/00/00/Cshrz023DILK-oIwAACH_5lVJGU05649_big.h
source ip address: 10.200.107.207
file timestamp=2011-04-27 02:18:43
file size=34815
file crc32=2572493925
file url: http://10.200.107.207:8080/group2/M00/00/00/Cshrz023DILK-oIwAACH_5lVJGU05649_big.h
sles207:/etc/fdfs # 


sles207:/opt/mars/fastdfs/data # find . -name Cshrz023DILK-oIwAACH_5lVJGU05649_big.h
./00/00/Cshrz023DILK-oIwAACH_5lVJGU05649_big.h
sles207:/opt/mars/fastdfs/data # 
sles207:/opt/mars/fastdfs/data # find . -name Cshrz023DILK-oIwAACH_5lVJGU05649.h
./00/00/Cshrz023DILK-oIwAACH_5lVJGU05649.h
sles207:/opt/mars/fastdfs/data # 

7. 查看整个fastdfs状态:


sles207:/etc/fdfs # /usr/local/bin/fdfs_monitor /etc/fdfs/client.conf
[2011-04-27 02:21:56] INFO - base_path=/opt/mars/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0

server_count=1, server_index=0

tracker server is 10.200.107.207:22122

group count: 1

Group 1:
group name = group2
free space = 309 GB
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

        Storage 1:
                ip_addr = 10.200.107.207 (sles207.10.198.88.18)  ACTIVE
                http domain = 
                version = 2.09
                join time = 2011-04-27 02:14:56
                up time = 2011-04-27 02:14:56
                total storage = 679GB
                free storage = 309GB
                upload priority = 10
                store_path_count = 1
                subdir_count_per_path = 256
                storage_port = 23000
                storage_http_port = 8888
                current_write_path = 0
                source ip_addr = 
                total_upload_count = 1
                success_upload_count = 1
                total_append_count = 0
                success_append_count = 0
                total_set_meta_count = 2
                success_set_meta_count = 2
                total_delete_count = 0
                success_delete_count = 0
                total_download_count = 0
                success_download_count = 0
                total_get_meta_count = 0
                success_get_meta_count = 0
                total_create_link_count = 0
                success_create_link_count = 0
                total_delete_link_count = 0
                success_delete_link_count = 0
                total_upload_bytes = 34815
                success_upload_bytes = 34815
                total_append_bytes = 0
                success_append_bytes = 0
                stotal_download_bytes = 0
                success_download_bytes = 0
                total_sync_in_bytes = 0
                success_sync_in_bytes = 0
                total_sync_out_bytes = 0
                success_sync_out_bytes = 0
                total_file_open_count = 2
                success_file_open_count = 2
                total_file_read_count = 0
                success_file_read_count = 0
                total_file_write_count = 2
                success_file_write_count = 2
                last_heart_beat_time = 2011-04-27 02:21:40
                last_source_update = 2011-04-27 02:18:43
                last_sync_update = 1970-01-01 08:00:00
                last_synced_timestamp = 1970-01-01 08:00:00 
sles207:/etc/fdfs #

分享到:
评论

相关推荐

    Fast_DFS_调研报告2

    《Fast DFS深度解析:分布式文件系统的精粹》 在当今数字化时代,文件系统扮演着至关重要的角色,尤其在大数据和云计算领域,分布式文件系统成为了解决海量数据存储和处理的关键技术。Fast DFS作为一款轻量级的...

    fast_DFS分布式资源文件系统的搭建

    centos 7 安装fastdfs5.0.9,里面含有FDFS的搭建,测试,以及对fastdfs-nginx-module的支持。最后还有 SpringMVC整合fastdfs-client-java实现web文件上传下载。

    fast-dfs离线安装所有资源

    【标题】:“fast-dfs离线安装所有资源” 在Linux操作系统中,特别是在没有网络连接或者网络环境不稳定的情况下,离线安装软件系统变得尤为重要。这里提到的“fast-dfs离线安装所有资源”针对的是FastDFS分布式文件...

    图的DFS和BFS算法实现 C++

    DFS通常使用栈来辅助实现,也可以通过递归方式完成。以下是DFS的基本步骤: 1. 从起点开始,标记该节点为已访问。 2. 探索当前节点的所有邻接节点,如果未被访问,则递归地对这些节点执行DFS。 3. 完成当前节点的...

    dfs_C++_dfs_

    DFS,全称深度优先搜索(Depth First Search),是一种在图或树中遍历所有节点的算法。在C++中实现DFS,通常会涉及到递归或栈这两种数据结构。本资料包含了一个C++实现DFS的源代码示例,适用于初学者理解和学习如何...

    使用DFS实现IIS负载均衡中双机文件同步

    此外,根据实际使用情况,调整DFS复制策略,优化网络带宽和存储资源的利用效率。 ### 注意事项 - 在实施DFS复制前,需确保所有服务器的硬盘格式为NTFS,因为DFS复制功能依赖于NTFS提供的元数据支持。 - DFS复制对...

    DFS CDMA Tool

    1. **三星M250L cdma 写号 1x.doc**:这可能是一个文档,详细介绍了如何使用DFS CDMA Tool对三星M250L这款特定CDMA设备进行写号操作。写号通常是指将设备的IMEI、ESN或MEID信息写入到设备的硬件中,使设备能够接入...

    DFS 文件高可用服务器搭建

    - 在fs02上使用PowerShell命令`Install-WindowsFeature FS-DFS-Namespace, FS-DFS-Replication, RSAT-DFS-Mgmt-Con`来安装DFS功能。 3. **创建DFS命名空间**: 在FS01上创建DFS命名空间,并指定一个易于理解的名称。...

    dfs.rar_dfs_dfs java

    在这个例子中,`DFS`类包含一个栈`stack`和一个布尔数组`visited`。`search`方法从起始节点`start`开始执行DFS。首先将起始节点压入栈,并标记为已访问。然后进入一个循环,只要栈不为空,就弹出栈顶元素作为当前...

    Windows server 2019系统配置DFS文件服务器SOP

    - 推荐使用备机作为域控机。 **2.3 安装步骤** 1. **添加角色和功能** - 打开服务器管理器,选择“添加角色和功能”。 - 按照向导提示完成角色和功能的添加。 2. **将服务器提升为域控制器** - 在服务器管理器...

    Windows Server 2019 文件同步配置教程DFS文件服务器

    Windows Server 2019 文件同步配置教程DFS文件服务器主要涉及的是如何在Windows Server环境中实现文件的高效同步和高可用性。DFS(Distributed File System)是微软提供的一种分布式文件系统,它允许用户通过单一的...

    DFS.rar_DFS algorithm_dfs_dfs python

    以下是一个使用递归实现的DFS示例: ```python def dfs(graph, node, visited=None): if visited is None: visited = set() visited.add(node) print(node) # 访问当前节点 for neighbor in graph[node]: if ...

    搜索专题——DFS

    在编程实现DFS时,通常使用栈来辅助存储当前的节点路径,或者使用递归函数来实现。对于有向图,DFS可以用于检测强连通分量、拓扑排序等;对于无向图,可以用来计算连通分量、寻找最短路径等。DFS虽然容易实现,但在...

    华为2016精英挑战赛java实现核心DFS算法

    这是华为2016挑战赛个人有关DFS算法的写作。

    算法之BFS与DFS

    这些资源详细介绍了这两种算法的概念、原理、实现方式以及实例,是深入理解BFS和DFS的好材料。 总之,BFS和DFS是解决图论问题的基石,理解并掌握它们对于提升编程能力,尤其是算法设计能力至关重要。通过阅读提供的...

    dfs刷号工具

    使用DFS刷号工具和CDMAWorkShop时,需要注意以下几点: 1. 安全性:在对设备进行固件更新或刷号操作时,务必确保设备电源稳定,避免在过程中断电,否则可能导致设备损坏。 2. 兼容性:确认DFS工具和CDMA设备的兼容...

    DFS文件服务器迁移08R2-12R2

    DFS 文件服务器迁移 08R2-12R2 本文档介绍了将 Windows Server 2008 R2 DFS 环境迁移到 Windows Server 2012 R2 DFS 环境的步骤和过程。 知识点: 1. DFS 环境迁移的基本思路:在将生产环境从 Windows Server ...

    DFS配置和排错

    可选步骤包括设定优先顺序、激活客户端回滚、使用DFS-R技术。为了高效地管理DFS命名空间,可能还需要委托创建和管理命名空间的能力给特定的用户或组。 DFS名称空间的安全配置也是重要环节。应该由域管理员创建域...

    树的DFS序及其应用

    在具体的例题中,DFS序的使用可以举例如下: - 例题一:给定一棵节点数为n的树,每个节点有权值value[i],共有m个询问,每个问题要求给出x这个点的子树的权值和。这个问题可以通过DFS序转化为序列问题,然后利用前缀...

Global site tag (gtag.js) - Google Analytics