Dynamic construction of a zoo cluster

I want to programmatically configure a zookeeper cluster. My goal is to use machines with CoreOS and dynamically deploy three nodes in the form of docker containers and configure them in one cluster of zoos.

In addition to the usual manual setting (/zookeeperReconfig.html), which shows how to add other nodes to an existing cluster of three nodes, I found a conversation that says how to do this from the very beginning, when I do not have nodes running in the existing cluster. Unfortunately, this set of steps does not work for me. I'm talking about http://mail-archives.apache.org/mod_mbox/zookeeper-user/201408.mbox/%3CCAPSuxQipZFH2582bEMid2tCVBFk%3DC31hwCYjbFgSwChBF%2BZQVQ%40mail.gmail.com%3E

Here is a list of the steps I took:

  • Start node first with standaloneEnabled = false and the only entry in zoo.cfg.dynamic.

server.1 = local: 2381: 2281: member; 0.0.0.0: +2181

  1. Run the second node with the following dynamic cfg:

server.1 = local: 2381: 2281: member; 0.0.0.0: 2181 server.2 = local: 2382: 2282: observer; 0.0.0.0: +2182

Note that there is no difference in behavior result when I change the “observer” to the “member” for the second node.

  1. Now I have two working instances. I can use. /zkCli.sh to enter the first node. When I try to add a second node using the following command:

reconfig -add server.2 = localhost: 2382: 2282: member; 0.0.0.0: 2182

... crash:

KeeperErrorCode = NewConfigNoQuorum for

However, after some research, I found a solution. But it is difficult, and I do not think that this is the only right decision.

What works for me? I can again take step # 3 at the first node, but now with an “observer”. This command causes even the first node to know about the second node. When I type 'config' for the console in zkCli, it seems to work. The next step will be to enter the second node using zkCli and the exec command:

reconfig -remove 2 <- the next step does not work without this

reconfig -add server.2 = localhost: 2382: 2282: member; 0.0.0.0: 2182

Ok, now I have a working cluster for two nodes. Finally, it is interesting that now I can add a third node using the normal script mentioned in the first paragraph.

Does anyone have any idea what I'm doing wrong?

+6
source share

Source: https://habr.com/ru/post/987738/


All Articles