错误结果
运行一下代码,出错
from fdfs_client.client import Fdfs_client
client = Fdfs_client('utils/fastdfs/client.conf')
ret = client.upload_by_filename('/Users/tony/Downloads/images/img_01.jpg')
出错提示如下
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
[-] Error: 61 connect to 192.168.3.77:22122. Connection refused.
运行环境
python3.8
,安装的delron/fastdfs
。
运行tracker容器
sudo docker run -dit --name tracker --network=host -v /Users/tony/fdfs/tracker:/var/fdfs delron/fastdfs tracker
运行storage容器
TRACKER_SERVER因为我两个docker都安装在了本地机器上,所以直接使用了本地宿主机的ip:192.168.3.77
sudo docker run -dti --name storage --network=host -e TRACKER_SERVER=192.168.3.77:22122 -v /Users/tony/fdfs/storage:/var/fdfs delron/fastdfs storage
宿主机可用网卡:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
EHC29: flags=0<> mtu 0
XHC20: flags=0<> mtu 0
EHC26: flags=0<> mtu 0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 10:dd:b1:cb:7a:d3
inet6 fe80::1879:b94b:4ef7:45f7%en0 prefixlen 64 secured scopeid 0x7
nd6 options=201<PERFORMNUD,DAD>
media: autoselect (1000baseT <full-duplex,flow-control>)
status: active
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether f4:f9:51:e5:4d:4a
inet6 fe80::14d2:2fb0:f68f:b834%en1 prefixlen 64 secured scopeid 0x8
inet 192.168.3.77 netmask 0xffffff00 broadcast 192.168.3.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether 06:f9:51:e5:4d:4a
media: autoselect
status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
ether 52:d6:cc:53:e8:d5
inet6 fe80::50d6:ccff:fe53:e8d5%awdl0 prefixlen 64 scopeid 0xa
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:13:0b:c2:40
media: autoselect <full-duplex>
status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:13:0b:c2:41
media: autoselect <full-duplex>
status: inactive
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether 32:00:13:0b:c2:40
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en2 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 11 priority 0 path cost 0
member: en3 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 12 priority 0 path cost 0
nd6 options=201<PERFORMNUD,DAD>
media: <unknown type>
status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
inet6 fe80::93c4:a2f6:8662:f843%utun0 prefixlen 64 scopeid 0xe
nd6 options=201<PERFORMNUD,DAD>
貌似也只有这个192.168.3.77
可用。
配置文件
客户端配置文件utils/fastdfs/client.conf
内容如下:
# 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=/Users/tony/fdfs/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.3.77: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
# 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
使用以上配置,上传文件就提示被拒绝,不知道什么原因,本人尝试过去tracker容器中获取tracker容器的ip,然后使用tracker容器ip来进行以上操作,依然不行,到底是什么原因呢?各位大神帮忙看看。