Install zookeeper on multiple AWS EC2instances

I am new to zookeeper and aws EC2. I am trying to install zookeeper on 3 ec2 ​​instances.

according to the zookeeper document , I installed zookeeper on all 3 instances, created zoo.conf and added the configuration below:

tickTime=2000 initLimit=10 syncLimit=5 dataDir=/opt/zookeeper/data clientPort=2181 server.1=localhost:2888:3888 server.2=<public ip of ec2 instance 2>:2889:3889 server.3=<public ip of ec2 instance 3>:2890:3890 

I also created the myid file in all three instances as /opt/zookeeper/data/myid as recommended ..

I have a few queries as shown below:

  • whenever I start the zookeeper server on each instance, it starts offline (according to the logs)

  • Can the above configuration really connect with each other? port 2889: 3889 and 2890: 38900 are all ports. Do I need to configure it on an ec2 machine or do I need to provide another port against it?

  • Do I need to create a security group to open this connection? I am not sure how to do this in an ec2 instance.

  • How to confirm that all 3 zookeeper are running and they can communicate with each other?

+5
source share
1 answer

ZooKeeper configuration is designed so that you can install the same configuration file on all servers in the cluster without changes. This simplifies ops. The component that defines the local node configuration is the myid file.

The configuration you define is not common to all servers. All servers in the server list must be tied to a private IP address available to other nodes on the network. You see that your server is starting offline because you are bound to localhost. Thus, the problem is that other servers in the cluster do not see localhost.

Your configuration should look larger:

 tickTime=2000 initLimit=10 syncLimit=5 dataDir=/opt/zookeeper/data clientPort=2181 server.1=<private ip of ec2 instance 1>:2888:3888 server.2=<private ip of ec2 instance 2>:2888:3888 server.3=<private ip of ec2 instance 3>:2888:3888 

The two ports listed in each server definition are respectively the quorum and election ports used by ZooKeeper nodes to exchange information with each other. Usually there is no need to change these ports, and you should try to maintain them equally on all servers to ensure consistency.

In addition, as I said, you should be able to share the same configuration file in all instances. The only thing to change is the myid file.

You will probably need to create a security group and open a client port to access clients, and quorum / election ports will be available to other ZooKeeper servers.

Finally, you can refer to the user interface to help manage the cluster. Netflix creates a decent interface that will give you an idea of ​​your cluster, and will also help clear old logs and save snapshots to S3 (ZooKeeper accepts snapshots but does not delete old transaction logs, so your disk will eventually be full if they are not removed properly). But once it is configured correctly, you can also see how the ZooKeeper servers connect to each other in the logs.

EDIT

@czerasz notes that starting with version 3.4.0 you can use the autopurge.snapRetainCount and autopurge.purgeInterval directives to keep your pictures clean.

@chomp notes that some users had to use 0.0.0.0 for the IP address of the local server to configure ZooKeeper on EC2. In other words, replace <private ip of ec2 instance 1> with 0.0.0.0 in the configuration file with instance 1 . This contradicts the way ZooKeeper configuration files are designed, but may be necessary for EC2.

+10
source

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


All Articles