1 docker image pull delron/fastdfs
2 mkdir -p /root/app/fdfs/tracker 本地创建文件存储
mkdir -p /root/app/fdfs/storage
3 运行容器 更改为自己的ip
# tracker tracker容器(跟踪服务器,起到调度的作用):
docker run -dti --network=host --name tracker -v /root/app/fdfs/tracker:/var/fdfs delron/fastdfs tracker
# storage storage容器(存储服务器,提供容量和备份服务):
docker run -dti --network=host --name storage -e TRACKER_SERVER=192.168.56.100:22122 -v /root/app/fdfs/storage:/var/fdfs delron/fastdfs storage
如果之前启动过storage 无法启动
可以删除/fdfs/storage/data
目录下的fdfs_storaged.pid
文件,然后重新运行storage。
运行成功之后访问ip:8888 端口可以更改 问百度娘吧
ok 成功之后就是上传文件了
配置client
# 连接超时 connect_timeout=30 # 网络超时 network_timeout=60 # 存储日志文件的路径 base_path=/var/fdfs # trackerserver 地址设置 tracker_server=192.168.56.100:22122 # 启动storage IP和端口 # 日志级别: log_level=info # if use connection pool use_connection_pool = false # connections whose the idle time exceeds this time will be closed connection_pool_max_idle_time = 3600 # if load FastDFS parameters from tracker server load_fdfs_parameters_from_tracker=false # if use storage ID instead of IP address use_storage_id = false # specify storage ids filename, can use relative or absolute path # same as tracker.conf # valid only when load_fdfs_parameters_from_tracker is false # since V4.05 storage_ids_filename = storage_ids.conf #HTTP settings http.tracker_server_port=80
测试 python3 上传
from fdfs_client.client import Fdfs_client, get_tracker_conf tracker_path = get_tracker_conf('/root/crawd_testing/dxscaner/scaner/fastdfs/client.conf') # 配置路径 client = Fdfs_client(tracker_path) res=client.upload_by_filename('/root/crawd_testing/framework/myframework/myframework/static/pdf/漏洞 2021-06-10 14:09.pdf') # 文件 print(res)
print(res['Remote file_id'].decode())
ok 成功
访问 http://192.168.56.100:8888/group1/M00/00/00/wKg4ZGDBs9yAbnHqAAUhIE3akdE960.pdf
欢迎留言 参考连接 http://insmoin.com/?post=109