Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker 不支持 Redis集群节点的IP #65

Open
orangeagain opened this issue Jan 28, 2021 · 8 comments
Open

Docker 不支持 Redis集群节点的IP #65

orangeagain opened this issue Jan 28, 2021 · 8 comments
Labels
docker Deployed in docker

Comments

@orangeagain
Copy link

orangeagain commented Jan 28, 2021

根据文档部署Docker节点: http://tendis.cn/#/Tendisplus/%E8%BF%90%E7%BB%B4/new_cluster_compose
docker run -itd -p 51002:51002 --env CLUSTER=yes --env REDIS_PASSWORD=tendisplustest tencentdbforkv/tendisplus
产生问题:
1.多物理节点Docker之间无法互相通信.
2.客户端访问节点得到的重定向地址也是Docker内部地址,导致重定向失败.

原因:
这种端口映射的方式会只会获得Docker容器本机内网IP.

可能的解决办法:
Docker部署使用 --net=host 模式共享物理机IP, 解决Docker节点间的互相通信问题, 同时解决了和客户端通信的问题.

参考:
https://www.geek-book.com/src/docs/redis/redis/redis.io/topics/cluster-tutorial.html
当前,Redis Cluster不支持NATted环境以及在重新映射IP地址或TCP端口的常规环境中。 Docker使用一种称为端口映射的技术:与该程序认为正在使用的端口相比,在Docker容器内运行的程序可能会使用不同的端口公开。为了在同一服务器上同时使用同一端口运行多个容器,这很有用。 为了使Docker与Redis Cluster兼容,您需要使用Docker 的主机联网模式。请检查Docker文档中的--net=host选项以获取更多信息。

@orangeagain
Copy link
Author

请把Docker文档更新成host网络模式,感谢

@jainal09
Copy link

hey @orangeagain i tried the following commands

docker run -it --net=host -p 51002:51002 --env CLUSTER=yes --env REDIS_PASSWORD=tendisplustest tencentdbforkv/tendisplus

or

docker run -it --net=host  --env CLUSTER=yes --env REDIS_PASSWORD=tendisplustest tencentdbforkv/tendisplus

and for connection

redis-cli -c -p 51002 -a tendisplustest
redis-cli -c -p 51002 -h localhost-a tendisplustest

But none worked how did you manage to solve?

PS. I want to access the cluster from outside the virtual machine but the docker compose provided here
cluster docker compose

has HARDCODED IP ADDRESS which is useful if accessing from inside the network but not from outside.

So, can you please help!

@orangeagain
Copy link
Author

hey @orangeagain i tried the following commands

docker run -it --net=host -p 51002:51002 --env CLUSTER=yes --env REDIS_PASSWORD=tendisplustest tencentdbforkv/tendisplus

or

docker run -it --net=host  --env CLUSTER=yes --env REDIS_PASSWORD=tendisplustest tencentdbforkv/tendisplus

and for connection

redis-cli -c -p 51002 -a tendisplustest
redis-cli -c -p 51002 -h localhost-a tendisplustest

But none worked how did you manage to solve?

PS. I want to access the cluster from outside the virtual machine but the docker compose provided here
cluster docker compose

has HARDCODED IP ADDRESS which is useful if accessing from inside the network but not from outside.

So, can you please help!

I am stuck at this problem too.
so I am wait offical to fix it.
我也卡在这了,请官方尽快修复

@OMG-By
Copy link

OMG-By commented Feb 2, 2021

我理解你的需求是:想在多个物理机器上部署docker镜像,然后通过meet构成集群?
当前同一物理机器上部署多节点是可用的。请问使用多物理机器构建集群的诉求是什么?
多物理机器支持可能需要依赖于bind参数的改造,目前已改造完成。正等待发布和镜像更新。

据docker官方文档描述:--net=host 会存在安全方面问题,所以不会在官方文档中推荐使用。
你可以自行选择使用docker run --net=host 启动。

@orangeagain
Copy link
Author

我理解你的需求是:想在多个物理机器上部署docker镜像,然后通过meet构成集群?
当前同一物理机器上部署多节点是可用的。请问使用多物理机器构建集群的诉求是什么?
多物理机器支持可能需要依赖于bind参数的改造,目前已改造完成。正等待发布和镜像更新。

据docker官方文档描述:--net=host 会存在安全方面问题,所以不会在官方文档中推荐使用。
你可以自行选择使用docker run --net=host 启动。

在同一物理机上部署多个节点意义不大,bind参数使用了,没用.期待新版本的教程.
--net=host也试了,没起起来,不知道是不是我方法不对.--net=host的性能比较高,内部服务器安全问题不大

@zhaochunxue
Copy link

我理解你的需求是:想在多个物理机器上部署docker镜像,然后通过meet构成集群?
当前同一物理机器上部署多节点是可用的。请问使用多物理机器构建集群的诉求是什么?
多物理机器支持可能需要依赖于bind参数的改造,目前已改造完成。正等待发布和镜像更新。
据docker官方文档描述:--net=host 会存在安全方面问题,所以不会在官方文档中推荐使用。
你可以自行选择使用docker run --net=host 启动。

在同一物理机上部署多个节点意义不大,bind参数使用了,没用.期待新版本的教程.
--net=host也试了,没起起来,不知道是不是我方法不对.--net=host的性能比较高,内部服务器安全问题不大

你们这个部署不会是一台台部署吧,总要有一个管理的外层工具,可以一键部署的吧,我们用的swarm集群,管理主机,使用compose文件内部使用的也是host模式是没什么问题的

@OMG-By
Copy link

OMG-By commented Mar 4, 2021

我理解你的需求是:想在多个物理机器上部署docker镜像,然后通过meet构成集群?
当前同一物理机器上部署多节点是可用的。请问使用多物理机器构建集群的诉求是什么?
多物理机器支持可能需要依赖于bind参数的改造,目前已改造完成。正等待发布和镜像更新。
据docker官方文档描述:--net=host 会存在安全方面问题,所以不会在官方文档中推荐使用。
你可以自行选择使用docker run --net=host 启动。

在同一物理机上部署多个节点意义不大,bind参数使用了,没用.期待新版本的教程.
--net=host也试了,没起起来,不知道是不是我方法不对.--net=host的性能比较高,内部服务器安全问题不大

是想在多个物理机上部署话,这边建议是使用二进制包方式。
如果是想体验集群版,可以使用docker-compose方式一键化部署体验。
容器版只为快速体验,部署在多个物理机上性能仍然不会得到多大提升。

@huawux huawux added the docker Deployed in docker label Mar 5, 2021
@0Jvang
Copy link

0Jvang commented May 19, 2022

+1,节点握手时返回的是容器内地址,导致主从复制失败(unknown node)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker Deployed in docker
Projects
None yet
Development

No branches or pull requests

6 participants