1、上传文件命令
语法
fdfs_upload_file /etc/fdfs/client.conf 【本地文件路径】
示例
#将test.txt文件上传到FastDFS服务器
[fastdfs@master fdfs]$ fdfs_upload_file /etc/fdfs/client.conf /home/fastdfs/data/bb.txt
group1/M00/00/00/wKgBaGId1DOACL6vAAAAeBKIAfk645.txt
上传成功后,返回一串带有组和路径标识的字符串,这是文件的id(下方都以文件ID表示)。
- 通过group1分组对应fastdfs数据存储路径下查询该文件存储目录
[fastdfs@master 00]$ pwd
/fastdfs/storage/files/data/00/00
[fastdfs@master 00]$ ls
wKgBaGId1DOACL6vAAAAeBKIAfk645.txt wKgBZ2IdwAGAThFJAAAAMOZ8mwo139.txt
- 通过cat命令查看文件
[fastdfs@master 00]$ cat /fastdfs/storage/files/data/00/00/wKgBaGId1DOACL6vAAAAeBKIAfk645.txt
WW
QQ
TT
YY
OO
2、下载文件命令
语法
fdfs_download_file /etc/fdfs/client.conf 【文件ID】
示例
[fastdfs@master data]$ fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKgBZ2IdwAGAThFJAAAAMOZ8mwo139.txt
文件直接下载到当前目录下,直接通过cat命令就可以直接进行查看。
3、查看文件信息命令
语法
fdfs_file_info /etc/fdfs/client.conf 【文件ID】
示例
[fastdfs@master data]$ fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/wKgBZ2IdwAGAThFJAAAAMOZ8mwo139.txt
GET FROM SERVER: false
file type: normal
source storage id: 0
source ip address: 192.168.192.12
file create timestamp: 2022-03-01 14:41:05
file size: 48
file crc32: -428041462 (0xe67c9b0a)
4、追加文件内容命令
- 覆盖之前文件
语法
fdfs_upload_appender /etc/fdfs/client.conf 【本地文件路径】【FastDFS文件ID】
示例
[fastdfs@master data]$ fdfs_upload_appender /etc/fdfs/client.conf ./aa.txt group1/M00/00/00/wKgBZ2IdwAGAThFJAAAAMOZ8mwo139.txt
group1/M00/00/00/wKgBZ2Id3WeEZeI8AAAAAOZ8mwo901.txt
会产生一个新的文件ID
- 直接在文件后追加内容
语法
fdfs_append_file /etc/fdfs/client.conf 【FastDFS文件ID】 【本地文件路径】
示例
[fastdfs@master data]$ fdfs_append_file /etc/fdfs/client.conf group1/M00/00/00/wKgBZ2Id3WeEZeI8AAAAAOZ8mwo901.txt ./bb.txt
5、删除文件命令
语法
fdfs_delete_file /etc/fdfs/client.conf 【文件ID】
示例
[fastdfs@master data]$ fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKgBZ2Id3WeEZeI8AAAAAOZ8mwo901.txt
6、监控服务器状态命令
语法
fdfs_monitor /etc/fdfs/client.conf
示例
[fastdfs@master data]$ fdfs_monitor /etc/fdfs/client.conf
[2022-03-01 17:31:41] DEBUG - base_path=/fastdfs/tracker, connect_timeout=30, network_timeout=60, tracker_server_count=2, 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=2, server_index=0
tracker server is 192.168.10.200:22122
group count: 3
Group 1:
group name = group1
disk total space = 50268 MB
disk free space = 44987 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 = 192.168.10.202
ip_addr = 192.168.10.202 ACTIVE
http domain =
........
........
7、其他
# 启动tracker服务
fdfs_trackerd /etc/fdfs/tracker.conf
# 启动storage服务
fdfs_storaged /etc/fdfs/storage.conf
#查看storage是否已经注册到了tracker下
fdfs_monitor /etc/fdfs/storage.conf
####### FastDFS重启
# 重启tracker
fdfs_trackerd /etc/fdfs/tracker.conf restart
# 重启storage
fdfs_storaged /etc/fdfs/storage.conf restart
######## FastDFS关闭
# 关闭tracker执行命令
fdfs_trackerd /etc/fdfs/tracker.conf stop
# 关闭storage执行命令
fdfs_storaged /etc/fdfs/storage.conf stop
##或者kill关闭fastdfs,但不建议在线上使用 kill -9 强制关闭,因为可能会导致文件信息不同步问题