CodisLabs / jodis

A java client for codis based on Jedis and Curator
MIT License
217 stars 97 forks source link

可以支持连接多个zookeeper吗? #51

Closed andrewyoung51 closed 5 years ago

andrewyoung51 commented 6 years ago

可以支持连接多个zookeeper吗?我看源码好像没有实现 如果配置codis集群,可能需要配置多个zookeeper。

Apache9 commented 6 years ago

具体需求是啥?一个codis集群应该只会在一个zk上注册吧,如果你要连多个codis集群那直接创建多个pool,传不同的zk地址进去就行?

andrewyoung51 commented 6 years ago

比如我在3台server上,分布部署了主副codis-server,codis-proxy。我希望其中某一台机器死机了(网络中断了),codis集群还能使用。因此我给每一台机器也装上zookeeper?是不是一个codis-proxy只能对应到一个zookeeper?

Apache9 commented 6 years ago

zookeeper应该是一个外部系统,就是你得至少找三台机器,搭一个zookeeper集群,然后codis相关的组件都用这一个zookeeper

andrewyoung51 commented 6 years ago

我们想要有一个主备,例如 RoundRobinJedisPool.create().curatorClient(url, (int) sessionTimeout).zkProxyDir(productName).build(); 这个URL可以是192.168.1.2:2181,192.168.1.3:2181 而这两个zookeeper实际是同一个集群; 前一个连接失败,可以自动切换尝试连接第二个zookeeper。

Apache9 commented 6 years ago

codis会注册在两个zk上嘛?

andrewyoung51 commented 6 years ago

从proxy.toml来看,没有注册到两个zk

jodis_name = "zookeeper" jodis_addr = "192.168.1.2:2181" jodis_auth = "" jodis_timeout = "20s" jodis_compatible = false