Sign inSign up

xuux/fastdfs

By xuux

•Updated over 6 years ago

单机版FastDFS[同官方],Solve: can't create connection ...23000

Image
1

84

xuux/fastdfs repository overview

⁠1. 单机版使用说明

官方Docker部署⁠

FASTDFS_IPADDR 指定主机IP,192.168.1.234 为宿主机地址

docker run -d --restart=always \
-e FASTDFS_IPADDR=192.168.1.234 \
-v /fastdfs/data:/home/dfs \
-p 22122:22122 \
-p 23000:23000 \
-p 8888:8888  \
-p 8011:80 \
--name fastdfs xuux/fastdfs:alpine

⁠2. 连接storage失败

问题:can't create connection to/172.17.0.1:23000

172.12.0.2 容器地址

192.168.1.234 宿主机地址

172.12.0.1 网关

解决方案1:

需要修改宿主机路由表,修改iptables的NAT表规则,所有转发到172.12.0.2:22122的数据,源地址修改为宿主主机的地址:192.168.1.234,这样storage注册到tracker server时,tracker server获取到storage的ip地址为 192.168.1.234 而不是网关地址172.17.0.1

iptables -t nat -A POSTROUTING -p tcp -m tcp --dport 22122 -d 172.17.0.2 -j SNAT --to 192.168.1.234

Docker安装fastdfs相关文章⁠

解决方案2:

使用Host模式,不使用桥接


⁠1. Stand-alone version instructions

FASTDFS_IPADDR specifies the host IP

docker run -d --restart=always \
-e FASTDFS_IPADDR=192.168.1.234 \
-v /fastdfs/data:/home/dfs \
-p 22122:22122 \
-p 23000:23000 \
-p 8888:8888  \
-p 8011:80 \
--name fastdfs xuux/fastdfs:alpine

⁠2. Problem:can't create connection to/172.17.0.1:23000

172.12.0.2 container address

192.168.1.234 host machine address

172.12.0.1 Gateway

⁠Solution 1:

You need to modify the host routing table and modify the NAT table rules of iptables. All data forwarded to 172.12.0.2:22122, the source address is modified to the address of the host host: 192.168.1.234, so that when the storage is registered to the tracker server, the tracker server gets it The storage IP address is 192.168.1.234 instead of the gateway address 172.17.0.1

iptables -t nat -A POSTROUTING -p tcp -m tcp --dport 22122 -d 172.17.0.2 -j SNAT --to 192.168.1.234

⁠Solution 2:

Use Host mode, do not use bridge

Tag summary

Content type

Image

Digest

Size

13.1 MB

Last updated

over 6 years ago

docker pull xuux/fastdfs:alpine