How to set up a zookeeper cluster on docker

Wednesday : 6 clusters of roaming dockers (2 masters and 4 workers)

Requirement : we need to configure the zookeeper cluster on an existing swarm of dockers.

Blocked . To configure zookeeper in the cluster, we need to provide all zk servers in each server configuration and provide a unique identifier in the myid file.

Question . When we create a zookeeper replica in a docker swarm, how can we provide a unique identifier for each replica. Also how can we update the zoo.cfg configuration file with the identifier of each zookeeper container.

+4
source share
1 answer

This is not easy to ask at this time. Installed state-fully scalable clusters are complex when each cluster member needs a unique identification and storage volume.

In Docker Swarm today, you are probably advised to start each member of the cluster as a separate service in your build file (see 31z4 / zookeeper-docker ):

version: '2'
services:
    zoo1:
        image: 31z4/zookeeper
        restart: always
        ports:
            - 2181:2181
        environment:
            ZOO_MY_ID: 1
            ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888

    zoo2:
        image: 31z4/zookeeper
        restart: always
        ports:
            - 2182:2181
        environment:
            ZOO_MY_ID: 2
            ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
..
..

For a modern (but still evolving) solution, I recommend checking out Kubernetes:

Statefulsets . , Docker Swarm , "" , .

+6

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


All Articles