fast DFS 单机使用实例

2024-06-21 16:32
文章标签 使用 实例 dfs 单机 fast

本文主要是介绍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 单机使用实例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/1081740

相关文章

Java Thread中join方法使用举例详解

《JavaThread中join方法使用举例详解》JavaThread中join()方法主要是让调用改方法的thread完成run方法里面的东西后,在执行join()方法后面的代码,这篇文章主要介绍... 目录前言1.join()方法的定义和作用2.join()方法的三个重载版本3.join()方法的工作原

Spring AI使用tool Calling和MCP的示例详解

《SpringAI使用toolCalling和MCP的示例详解》SpringAI1.0.0.M6引入ToolCalling与MCP协议,提升AI与工具交互的扩展性与标准化,支持信息检索、行动执行等... 目录深入探索 Spring AI聊天接口示例Function CallingMCPSTDIOSSE结束语

Linux系统之lvcreate命令使用解读

《Linux系统之lvcreate命令使用解读》lvcreate是LVM中创建逻辑卷的核心命令,支持线性、条带化、RAID、镜像、快照、瘦池和缓存池等多种类型,实现灵活存储资源管理,需注意空间分配、R... 目录lvcreate命令详解一、命令概述二、语法格式三、核心功能四、选项详解五、使用示例1. 创建逻

在Java中使用OpenCV实践

《在Java中使用OpenCV实践》用户分享了在Java项目中集成OpenCV4.10.0的实践经验,涵盖库简介、Windows安装、依赖配置及灰度图测试,强调其在图像处理领域的多功能性,并计划后续探... 目录前言一 、OpenCV1.简介2.下载与安装3.目录说明二、在Java项目中使用三 、测试1.测

MySQL多实例管理如何在一台主机上运行多个mysql

《MySQL多实例管理如何在一台主机上运行多个mysql》文章详解了在Linux主机上通过二进制方式安装MySQL多实例的步骤,涵盖端口配置、数据目录准备、初始化与启动流程,以及排错方法,适用于构建读... 目录一、什么是mysql多实例二、二进制方式安装MySQL1.获取二进制代码包2.安装基础依赖3.清

C++中detach的作用、使用场景及注意事项

《C++中detach的作用、使用场景及注意事项》关于C++中的detach,它主要涉及多线程编程中的线程管理,理解detach的作用、使用场景以及注意事项,对于写出高效、安全的多线程程序至关重要,下... 目录一、什么是join()?它的作用是什么?类比一下:二、join()的作用总结三、join()怎么

SpringBoot 异常处理/自定义格式校验的问题实例详解

《SpringBoot异常处理/自定义格式校验的问题实例详解》文章探讨SpringBoot中自定义注解校验问题,区分参数级与类级约束触发的异常类型,建议通过@RestControllerAdvice... 目录1. 问题简要描述2. 异常触发1) 参数级别约束2) 类级别约束3. 异常处理1) 字段级别约束

mybatis中resultMap的association及collectio的使用详解

《mybatis中resultMap的association及collectio的使用详解》MyBatis的resultMap定义数据库结果到Java对象的映射规则,包含id、type等属性,子元素需... 目录1.reusltmap的说明2.association的使用3.collection的使用4.总

Apache Ignite缓存基本操作实例详解

《ApacheIgnite缓存基本操作实例详解》文章介绍了ApacheIgnite中IgniteCache的基本操作,涵盖缓存获取、动态创建、销毁、原子及条件更新、异步执行,强调线程池注意事项,避免... 目录一、获取缓存实例(Getting an Instance of a Cache)示例代码:二、动态

Spring Boot配置和使用两个数据源的实现步骤

《SpringBoot配置和使用两个数据源的实现步骤》本文详解SpringBoot配置双数据源方法,包含配置文件设置、Bean创建、事务管理器配置及@Qualifier注解使用,强调主数据源标记、代... 目录Spring Boot配置和使用两个数据源技术背景实现步骤1. 配置数据源信息2. 创建数据源Be