FastDFS是一個開源的輕量級分佈式文件系統,它對文件進行管理,功能包括:文件存儲、文件同步、文件訪問(文件上傳、文件下載)等,解決了大容量存儲和負載均衡的問題。特別適合以文件爲載體的在線服務,如相冊網站、視頻網站等等(摘自百度百科). 實驗環境: 1.docker下運行單節點的跟蹤器(tracker)和存儲節點(storage) 2.windows10 上運行Python環境: 3.6.4 3.IDE:Pychram ============================================== 安裝fastdfs_client 1. 安裝fdfs_client-py-1.2.6 (下載地址:http://down.51cto.com/data/2448725) 解壓以後使用python setup.py install命令安裝,或解壓直接將fdfs_client文件夾拷貝到Python/lib目錄下便可
2. 修改Python/Lib/fdfs_client/storage_client.py文件,將12行刪除或註釋(不然,使用時會報錯ImportError: No module named sendfile) # from fdfs_client.sendfile import * 安裝完windows下環境: (上面方法安裝):fdfs_client 網絡安裝: pip install mutagen pip isntall requests Python manage.py shell環境測試:
from fdfs_client.client import Fdfs_client client = Fdfs_client('配置文件絕對路徑') 上傳OK !!!! 坑點: 1.storage.client,註釋12行 2.測試上傳文件絕對路徑須要進行 r 轉義,否則報Unicode錯誤 3.若是經過網絡安裝(pip) fdfs_client,會有以下報錯,不要盲目安裝VC++ 14.0 , 能夠先去 控制面板==>>程序==>>程序和功能 查看是否安裝過:
=================================== # fastdfs 配置文件:client.config ============client.config============== # (注意標黃配置) # 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= ../../logs # 日誌存放 # tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address tracker_server=192.168.115.129:22122 # tracker服務器 #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 # if use connection pool # default value is false # since V4.05 use_connection_pool = false # connections whose the idle time exceeds this time will be closed # unit: second # default value is 3600 # since V4.05 connection_pool_max_idle_time = 3600 # if load FastDFS parameters from tracker server # since V4.05 # default value is false load_fdfs_parameters_from_tracker=false # if use storage ID instead of IP address # same as tracker.conf # valid only when load_fdfs_parameters_from_tracker is false # default value is false # since V4.05 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 #use "#include" directive to include HTTP other settiongs ##include http.conf (發現錯誤,如有疑問,歡迎評論交流)
寫在有道雲筆記中的文檔連接:
https://note.youdao.com/share/?id=da3d2b54f99a916854d3383b4e2ecee8&type=note#/python