日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法

系統(tǒng) 1991 0

一、安裝FastDFS

1-1:執(zhí)行docker命令安裝

            
# 安裝tracker
docker run -dti --network=host --name tracker -v /var/fdfs/tracker:/var/fdfs youkou1/fastdfs tracker
# 安裝storage
docker run -dti --network=host --name storage -e TRACKER_SERVER=IP地址:22122 -v /var/fdfs/storage:/var/fdfs youkou1/fastdfs storage
          

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第1張圖片

1-2 測試是否安裝成功:執(zhí)行命令 docker ps -a

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第2張圖片

TRACKER_SERVER:IP地址說明不要使用lo 和docker下的IP地址因為在安裝鏡像中配的是enp3s0下面的IP地址。

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第3張圖片

1-3、在項目中創(chuàng)建客戶端配置文件? fastdfs/client.conf

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第4張圖片

client.conf配置文件內(nèi)容:注意tracker_serverIP地址。

            
# 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=utils/fastdfs/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.31.170: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
# if use connection pool
# default value is false
use_connection_pool = false
# connections whose the idle time exceeds this time will be closed
# unit: second
# default value is 3600
connection_pool_max_idle_time = 3600
# if load FastDFS parameters from tracker server
# 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
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
storage_ids_filename = storage_ids.conf
#HTTP settings
http.tracker_server_port=80
          

1-4:在xhell中進(jìn)入項目的虛擬環(huán)境安裝python相關(guān)包 (在虛擬環(huán)境中)

            
# 安裝相關(guān)包 
pip install fdfs_client.zip
pip install mutagen
pip install requests
          

1-5:如果pip install fdfs_client.zip 安裝報錯

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第5張圖片

請執(zhí)行如下命令

            
sudo apt-get install python3 python-dev python3-dev build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev python-pip
          

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第6張圖片

然后在執(zhí)行安裝命令:

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第7張圖片

查看所安裝的包:

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第8張圖片

測試代碼:

            
from fdfs_client.client import Fdfs_client
FDFS_Client = Fdfs_client('/common/fastdfs/client.conf')
ret = FDFS_Client.upload_by_filename('/media/2018.png')
print(ret)
          

  如果執(zhí)行不報錯,返回結(jié)果如下說明就成功了:

1-6 如果進(jìn)行測試 以下報的是語法錯誤,這個明顯是python2的語法,我現(xiàn)在用的是python3,進(jìn)過查詢相關(guān)資料,決定換一個不用 pip install fdfs_client.zip

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第9張圖片

刪除?? fdfs_client.zip? 執(zhí)行命令

pip uninstall fdfs_client-py

使用 pip install py3Fdfs

? python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第10張圖片

再次測試:

python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法_第11張圖片

?在瀏覽器中查看:

http://192.168.31.170:8888/group1/M00/00/00/wKgfqlz5yYyAHe5nAAfh_rrm7jw601.png

注意:這里的端口8888也是在上面安裝環(huán)境中配好的。

總結(jié)

以上所述是小編給大家介紹的python django框架中使用FastDFS分布式文件系統(tǒng)的安裝方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 平和县| 勐海县| 香河县| 马尔康县| 宁陕县| 银川市| 库车县| 微博| 正蓝旗| 浑源县| 成安县| 金堂县| 康平县| 凤翔县| 富顺县| 天气| 平舆县| 图片| 静乐县| 罗山县| 班玛县| 隆尧县| 乌兰浩特市| 云龙县| 柳河县| 苏尼特左旗| 拉萨市| 浦北县| 冷水江市| 洛川县| 沙坪坝区| 岑巩县| 丰顺县| 巫溪县| 海宁市| 赤城县| 宁乡县| 陈巴尔虎旗| 关岭| 章丘市| 右玉县|