ZooKeeper 本身就是为分布式应用服务的,为了确保高可用所以很少使用 Standalone 模式,而更多是使用集群模式运行
一般而言使用3个或大于3个的奇数个server
For replicated mode, a minimum of three servers are required, and it is strongly recommended that you have an odd number of servers . If you only have two servers, then you are in a situation where if one of them fails, there are not enough machines to form a majority quorum. Two servers is inherently less stable than a single server, because there are two single points of failure.
下面分享一下它的集群操作,详细可以参考 官方文档
Tip: 当前版本为 Release 3.4.6(stable)
所谓 伪集群 其实就是在同一台机器上运行多个server,从而构成集群,这类集群可以展示集群的逻辑特性
但是由于其固有的架构缺乏实际的物理冗余,所以并不抗风险,不是真正意义上的高可用集群
停掉应用后将 zookeeper-3.4.6 目录拷贝两份
[root@h101 zk]# ll -d zookeeper-3.4.6*
drwxr-xr-x 10 1000 1000 4096 Dec 2 21:58 zookeeper-3.4.6
drwxr-xr-x 10 root root 4096 Dec 3 19:24 zookeeper-3.4.6.1
drwxr-xr-x 10 root root 4096 Dec 3 19:24 zookeeper-3.4.6.2
-rw-r--r-- 1 root root 17699306 Oct 31 2014 zookeeper-3.4.6.tar.gz
[root@h101 zk]#
[root@h101 zk]# cat zookeeper-3.4.6/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper0
dataLogDir=/tmp/zookeeper0
clientPort=2180
server.0=127.0.0.1:8000:8100
server.1=127.0.0.1:8001:8101
server.2=127.0.0.1:8002:8102
[root@h101 zk]# ll zookeeper-3.4.6*/conf/zoo.cfg
-rw-r--r-- 1 root root 193 Dec 3 19:24 zookeeper-3.4.6.1/conf/zoo.cfg
-rw-r--r-- 1 root root 193 Dec 3 19:25 zookeeper-3.4.6.2/conf/zoo.cfg
-rw-r--r-- 1 root root 193 Dec 3 19:23 zookeeper-3.4.6/conf/zoo.cfg
[root@h101 zk]# cat zookeeper-3.4.6*/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper1
dataLogDir=/tmp/zookeeper1
clientPort=2181
server.0=127.0.0.1:8000:8100
server.1=127.0.0.1:8001:8101
server.2=127.0.0.1:8002:8102
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper2
dataLogDir=/tmp/zookeeper2
clientPort=2182
server.0=127.0.0.1:8000:8100
server.1=127.0.0.1:8001:8101
server.2=127.0.0.1:8002:8102
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper0
dataLogDir=/tmp/zookeeper0
clientPort=2180
server.0=127.0.0.1:8000:8100
server.1=127.0.0.1:8001:8101
server.2=127.0.0.1:8002:8102
[root@h101 zk]#
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。