启动管理tracker:
启动管理storage:
(启动storage server的前提是tracker server必须事先已启动)
启动成功后 base_path 路径下生成以下文件夹
data logs
data下 fdfs_storaged.pid 记录程序运行的pid
storage_stat.dat 当前storage server统计信息 (上传下载)
sync 存放数据同步相关文件
6.查询服务器信息 fdfs_test /client.conf query_servers group1 M00/00/00/AAADeLE3ZJc.29.txt
server list (1):
10.0.7.216:23000
9.2.1 的上传信息
[2016-10-26 14:24:47] DEBUG - base_path=/home/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
tracker_query_storage_store_list_without_group:
server 1. group_name=, ip_addr=10.0.7.216, port=23000
group_name=group1, ip_addr=10.0.7.216, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/CgAH2FgQTC-ATZqrAAAhBUmzLaA086.png
source ip address: 10.0.7.216
file timestamp=2016-10-26 14:24:47
file size=8453
file crc32=1236479392
example file url: http://10.0.7.216/group1/M00/00/00/CgAH2FgQTC-ATZqrAAAhBUmzLaA086.png
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/CgAH2FgQTC-ATZqrAAAhBUmzLaA086_big.png
source ip address: 10.0.7.216
file timestamp=2016-10-26 14:24:47
file size=8453
file crc32=1236479392
example file url: http://10.0.7.216/group1/M00/00/00/CgAH2FgQTC-ATZqrAAAhBUmzLaA086_big.png
这两个是FastDFS自带的测试程序,会对一个文件上传两次,分别作为主文件和从文件。返回的文件ID也是两个。
并且会上传文件附加属性,storage server上会生成4个文件。
这两个程序仅用于测试目的,请不要用作实际用途。
V2.05提供了比较正式的三个小工具:
上传文件:/usr/local/bin/fdfs_upload_file <config_file> <local_filename>
下载文件:/usr/local/bin/fdfs_download_file <config_file> <file_id> [local_filename]
删除文件:/usr/local/bin/fdfs_delete_file <config_file> <file_id>
9.2.2 的下载信息
[root@localhost bin]# ./fdfs_test /etc/fdfs/client.conf download group1 M00/00/00/CgAH2Fgrg4eADNYWAAADeLE3ZJc.29.txt
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.
[2016-11-16 05:53:35] DEBUG - base_path=/home/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
storage=10.0.7.216:23000
download file success, file size=888, file save to CgAH2Fgrg4eADNYWAAADeLE3ZJc.29.txt
9.2.3 的获取属性 # ./fdfs_test /etc/fdfs/client.conf getmeta group1 M00/00/00/CgAH2Fgrg4eADNYWAAADeLE3ZJc.29.txtstorage=10.0.7.216:23000get meta data success, meta count=4ext_name=jpgfile_size=115120height=80width=160
1.
启动文件+配置文件+命令
/usr/bin/fdfs_trackerd <config_file> [start | stop | restart]
举例:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
2.
service+文件+命令(需要配置)
/sbin/service fdfs_trackerd start
/usr/bin/fdfs_trackerd <config_file> [start | stop | restart]
举例:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
2.
service+文件+命令(需要配置)
/sbin/service fdfs_trackerd start
启动如果报错,请先检查配置文件中的 base_path=xxx 这个文件夹是否创建
启动成功后 base_path 路径下生成以下文件夹
data logs
data下 fdfs_trackerd.pid 记录程序运行的pid
storage_changelog.dat 记录更新的stroage情况
storage_groups_new.dat 存储分组信息 (group_count=0)
data logs
data下 fdfs_trackerd.pid 记录程序运行的pid
storage_changelog.dat 记录更新的stroage情况
storage_groups_new.dat 存储分组信息 (group_count=0)
storage_servers_new.dat 存储服务器(storage)列表 (storage_count=0)
storage_sync_timestamp.dat
logs下 trackerd.log 日志文件 记录启动停止等信息
例如 记载启动信息:
logs下 trackerd.log 日志文件 记录启动停止等信息
例如 记载启动信息:
[2016-10-26 10:16:00] INFO - FastDFS v5.05, base_path=/home/fastdfs_tracker, run_by_group=, run_by_user=, connect_timeout=30s, network_timeout=60s, port=22122, bind_addr=, max_connections=256, accept_threads=1,
work_threads=4, store_lookup=2, store_group=, store_server=0, store_path=0, reserved_storage_space=10.00%, download_server=0, allow_ip_count=-1, sync_log_buff_interval=10s, check_active_interval=120s, thread_stack_size=64 KB, storage_ip_changed_auto_adjust=1,
storage_sync_file_max_delay=86400s, storage_sync_file_max_time=300s, use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file_size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_file_space_threshold=20
GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlog=0, trunk_compress_binlog_min_interval=0, use_storage_id=0, id_type_in_filename=ip, storage_id_count=0, rotate_error_log=0, error_log_rotate_time=00:00, rotate_error_log_size=0, log_file_keep_days=0,
store_slave_file_use_link=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s
启动管理storage:
(启动storage server的前提是tracker server必须事先已启动)
1.
启动文件+配置文件+命令
fdfs_storaged <config_file> [start | stop | restart]
举例: /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
2.
service+文件+命令(需要配置)
/sbin/service fdfs_storaged start
2.
service+文件+命令(需要配置)
/sbin/service fdfs_storaged start
启动成功后 base_path 路径下生成以下文件夹
data logs
data下 fdfs_storaged.pid 记录程序运行的pid
storage_stat.dat 当前storage server统计信息 (上传下载)
sync 存放数据同步相关文件
logs下 日志文件
我将数据存放设置到/home/fastdfs_date
storage启动后 在/home/fastdfs_date下创建 data文件夹
在data中创建了 256个存放数据文件的一级目录,目录名为十六进制字符,如:00, 1F
每个一级目录下又创建256个存放数据文件的二级目录目录,目录名为十六进制字符,如:0A, CF
使用FastDFS:
fastdfs命令
fdfs_trackerd 启动tracker
fdfs_storaged 启动storage
fdfs_monitor 监控
fdfs_upload_file 上传
fdfs_download_file 下载
fdfs_delete_file 删除文件
fdfs_file_info 查看上传文件的信息
fdfs_crc32 获取文件CRC
fdfs_test 功能测试(参见上一篇)
fdfs_test1 功能测试(参见上一篇)
fdfs_appender_test appender上传测试 (产生两个文件 原文件 和属性文件) fdfs_appender_test1 appender上传测试 (产生两个文件 原文件 和属性文件 )
fdfs_upload_appender 上传断点文件 可以后续继续上传(独立存储,appender file不能被合并存储到trunk file)
fdfs_append_file 对以创建的文件进行append操作 追加内容
1.上传 fdfs_upload_file <config_file> <local_filename> [storage_ip:port] [store_path_index]
# ./fdfs_upload_file /etc/fdfs/client.conf /root/51.29.txt
打印信息,是文件上传路径与文件名:
group1/M00/00/00/CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt
2.下载 fdfs_download_file <config_file> <file_id> [local_filename] [<download_offset> <download_bytes>]
直接下载(当前目录)
#./fdfs_download_file /client.conf group1/M00/00/00/CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt
重命名下载 到 (当前目录)
# ./fdfs_download_file /client.conf group1/M00/00/00/CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt A.TXT
选定目录下载
# ./fdfs_download_file /client.conf group1/M00/00/00/CTveAAADeLE3ZJc.29.txt /usr/A.TXT
3.删除 fdfs_delete_file <config_file> <file_id>
# ./fdfs_delete_file /client.conf group1/M00/00/00/CgAH2AAADeLE3ZJc.29.txt
4.查看上传文件信息 fdfs_file_info <config_file> <file_id>
# ./fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt
source storage id: 0 source ip address: 10.0.7.216 file create timestamp: 2016-11-16 11:34:01 file size: 888 file crc32: 2973197463 (0xB1376497)
5.获取文件CRC fdfs_crc32 <filename>
# ./fdfs_crc32 CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt
2973197463
6.upload_appender 上传断点文件
fdfs_upload_appender <config_file> <local_filename>
上传文件 (独立存储,appender file不能被合并存储到trunk file)
# fdfs_upload_appender /etc/fdfs/client.conf /root/1.txt
group1/M00/00/00/CgAH2Fgub0uEM6a-AAAAAAV96LM493.txt
7.断点上传 fdfs_append_file
fdfs_append_file <config_file> <appender_file_id> <local_filename>
已上传的 本地需要继续上传的
8.监控系统状态 可以监控查看运行状态
fdfs_monitor <config_file> [-h <tracker_server>] [list|delete|set_trunk_server <group_name> [storage_id]]
举例:/usr/bin/fdfs_monitor /etc/fdfs/client.conf
storage启动后 在/home/fastdfs_date下创建 data文件夹
在data中创建了 256个存放数据文件的一级目录,目录名为十六进制字符,如:00, 1F
每个一级目录下又创建256个存放数据文件的二级目录目录,目录名为十六进制字符,如:0A, CF
使用FastDFS:
fastdfs命令
fdfs_trackerd 启动tracker
fdfs_storaged 启动storage
fdfs_monitor 监控
fdfs_upload_file 上传
fdfs_download_file 下载
fdfs_delete_file 删除文件
fdfs_file_info 查看上传文件的信息
fdfs_crc32 获取文件CRC
fdfs_test 功能测试(参见上一篇)
fdfs_test1 功能测试(参见上一篇)
fdfs_appender_test appender上传测试 (产生两个文件 原文件 和属性文件) fdfs_appender_test1 appender上传测试 (产生两个文件 原文件 和属性文件 )
fdfs_upload_appender 上传断点文件 可以后续继续上传(独立存储,appender file不能被合并存储到trunk file)
fdfs_append_file 对以创建的文件进行append操作 追加内容
1.上传 fdfs_upload_file <config_file> <local_filename> [storage_ip:port] [store_path_index]
# ./fdfs_upload_file /etc/fdfs/client.conf /root/51.29.txt
打印信息,是文件上传路径与文件名:
group1/M00/00/00/CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt
2.下载 fdfs_download_file <config_file> <file_id> [local_filename] [<download_offset> <download_bytes>]
直接下载(当前目录)
#./fdfs_download_file /client.conf group1/M00/00/00/CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt
重命名下载 到 (当前目录)
# ./fdfs_download_file /client.conf group1/M00/00/00/CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt A.TXT
选定目录下载
# ./fdfs_download_file /client.conf group1/M00/00/00/CTveAAADeLE3ZJc.29.txt /usr/A.TXT
3.删除 fdfs_delete_file <config_file> <file_id>
# ./fdfs_delete_file /client.conf group1/M00/00/00/CgAH2AAADeLE3ZJc.29.txt
4.查看上传文件信息 fdfs_file_info <config_file> <file_id>
# ./fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt
source storage id: 0 source ip address: 10.0.7.216 file create timestamp: 2016-11-16 11:34:01 file size: 888 file crc32: 2973197463 (0xB1376497)
5.获取文件CRC fdfs_crc32 <filename>
# ./fdfs_crc32 CgAH2Fgr06mAYTveAAADeLE3ZJc.29.txt
2973197463
6.upload_appender 上传断点文件
fdfs_upload_appender <config_file> <local_filename>
上传文件 (独立存储,appender file不能被合并存储到trunk file)
# fdfs_upload_appender /etc/fdfs/client.conf /root/1.txt
group1/M00/00/00/CgAH2Fgub0uEM6a-AAAAAAV96LM493.txt
7.断点上传 fdfs_append_file
fdfs_append_file <config_file> <appender_file_id> <local_filename>
已上传的 本地需要继续上传的
8.监控系统状态 可以监控查看运行状态
fdfs_monitor <config_file> [-h <tracker_server>] [list|delete|set_trunk_server <group_name> [storage_id]]
举例:/usr/bin/fdfs_monitor /etc/fdfs/client.conf
9.测试程序
安装好后,可以先测试一下fastdfs的功能
注意:以下使用的 fdfs_test程序 为测试使用,不要用在正式环境!
注意:以下使用的 fdfs_test程序 为测试使用,不要用在正式环境!
9.1 appender测试
fdfs_appender_test <config_file> <local_filename> [FILE | BUFF | CALLBACK]
fdfs_appender_test1 <config_file> <local_filename> [FILE | BUFF | CALLBACK]
会上传产生两个文件 原文件 和属性文件
CgAH2FguakWEQQCFAAAAAAV96LM005.txt 原文件
CgAH2FguakWEQQCFAAAAAAV96LM005.txt-m 文件的属性
属性文件中一般存储 ext_name jpg file_size 115120 height 80 width160
fdfs_appender_test <config_file> <local_filename> [FILE | BUFF | CALLBACK]
fdfs_appender_test1 <config_file> <local_filename> [FILE | BUFF | CALLBACK]
会上传产生两个文件 原文件 和属性文件
CgAH2FguakWEQQCFAAAAAAV96LM005.txt 原文件
CgAH2FguakWEQQCFAAAAAAV96LM005.txt-m 文件的属性
属性文件中一般存储 ext_name jpg file_size 115120 height 80 width160
9.2普通测试
#run the client test program:
/usr/bin/fdfs_test <client_conf_filename> <operation>
/usr/bin/fdfs_test1 <client_conf_filename> <operation>
operation: upload, download, getmeta, setmeta, delete and query_servers
上传 下载 获取文件属性 设置属性 删除 查询服务器信息
1.上传 /usr/bin/fdfs_test conf/client.conf upload /usr/include/123.png
2.下载 fdfs_test /client.conf download group1 M00/00/00/AAADeLE3ZJc.29.txt
(下载文件到当前目录)
3.获取属性 fdfs_test /client.conf getmeta group1 M00/00/00/AAADeLE3ZJc.29.txt
4.设置属性 ./fdfs_test <config_file> setmeta <group_name> <remote_filename> <op_flag> <metadata_list>
op_flag: O for overwrite, M for merge
metadata_list: name1=value1,name2=value2,...
5.删除 fdfs_test /client.conf delete group1 M00/00/00/AAADeLE3ZJc.29.txt
storage=10.0.7.216:23000 delete file success
#run the client test program:
/usr/bin/fdfs_test <client_conf_filename> <operation>
/usr/bin/fdfs_test1 <client_conf_filename> <operation>
operation: upload, download, getmeta, setmeta, delete and query_servers
上传 下载 获取文件属性 设置属性 删除 查询服务器信息
1.上传 /usr/bin/fdfs_test conf/client.conf upload /usr/include/123.png
2.下载 fdfs_test /client.conf download group1 M00/00/00/AAADeLE3ZJc.29.txt
(下载文件到当前目录)
3.获取属性 fdfs_test /client.conf getmeta group1 M00/00/00/AAADeLE3ZJc.29.txt
4.设置属性 ./fdfs_test <config_file> setmeta <group_name> <remote_filename> <op_flag> <metadata_list>
op_flag: O for overwrite, M for merge
metadata_list: name1=value1,name2=value2,...
5.删除 fdfs_test /client.conf delete group1 M00/00/00/AAADeLE3ZJc.29.txt
storage=10.0.7.216:23000 delete file success
6.查询服务器信息 fdfs_test /client.conf query_servers group1 M00/00/00/AAADeLE3ZJc.29.txt
server list (1):
10.0.7.216:23000
9.2.1 的上传信息
[2016-10-26 14:24:47] DEBUG - base_path=/home/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
tracker_query_storage_store_list_without_group:
server 1. group_name=, ip_addr=10.0.7.216, port=23000
group_name=group1, ip_addr=10.0.7.216, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/CgAH2FgQTC-ATZqrAAAhBUmzLaA086.png
source ip address: 10.0.7.216
file timestamp=2016-10-26 14:24:47
file size=8453
file crc32=1236479392
example file url: http://10.0.7.216/group1/M00/00/00/CgAH2FgQTC-ATZqrAAAhBUmzLaA086.png
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/CgAH2FgQTC-ATZqrAAAhBUmzLaA086_big.png
source ip address: 10.0.7.216
file timestamp=2016-10-26 14:24:47
file size=8453
file crc32=1236479392
example file url: http://10.0.7.216/group1/M00/00/00/CgAH2FgQTC-ATZqrAAAhBUmzLaA086_big.png
这两个是FastDFS自带的测试程序,会对一个文件上传两次,分别作为主文件和从文件。返回的文件ID也是两个。
并且会上传文件附加属性,storage server上会生成4个文件。
这两个程序仅用于测试目的,请不要用作实际用途。
V2.05提供了比较正式的三个小工具:
上传文件:/usr/local/bin/fdfs_upload_file <config_file> <local_filename>
下载文件:/usr/local/bin/fdfs_download_file <config_file> <file_id> [local_filename]
删除文件:/usr/local/bin/fdfs_delete_file <config_file> <file_id>
9.2.2 的下载信息
[root@localhost bin]# ./fdfs_test /etc/fdfs/client.conf download group1 M00/00/00/CgAH2Fgrg4eADNYWAAADeLE3ZJc.29.txt
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.
[2016-11-16 05:53:35] DEBUG - base_path=/home/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
storage=10.0.7.216:23000
download file success, file size=888, file save to CgAH2Fgrg4eADNYWAAADeLE3ZJc.29.txt
9.2.3 的获取属性 # ./fdfs_test /etc/fdfs/client.conf getmeta group1 M00/00/00/CgAH2Fgrg4eADNYWAAADeLE3ZJc.29.txtstorage=10.0.7.216:23000get meta data success, meta count=4ext_name=jpgfile_size=115120height=80width=160
其它……略