[] Zookeeper Zookeeper build a clustered environment

Zookeeper is an open source distributed coordination and efficient service can be used to coordinate the implementation of scheduling distributed among the examples of other clusters, such as Kafka on the use of cluster to manage Zookeeper, Zookeeper files in a tree structure, the storage of some of the nodes Kafka's yuan data information, such as broker information, consumer information, topic information. Kafka obtains information from Zookeeper, to ensure that metadata between each instance is the same.

In addition, Zookeeper can also be registered as a service and distribution services, such as a service registry of Dubbo, interface information to manage individual service instances released.

Positioning Zookeeper is a distributed coordination service, so it can not store large amounts of data like Kafka or Redis as nodes on the tree-like structure it can only store a small amount of information, but the amount of data that can be stored and fully meet its requirements and coordination of distributed service registration and discovery of the center.

Here Zookeeper build a cluster, to facilitate the subsequent use of learning.

 

Three linux virtual machine created in the VM, IP addresses are:

192.168.200.128 
192.168.200.129
192.168.200.130
 
First Quguan network download package zookeeper in:

After downloading uploaded to the three servers:

The opt archive into the directory, using the sudo -zxvf the tar-Apache ZooKeeper-3.5.5-bin.tar.gz -C / opt / :

 

Zookeeper configuration environment variable, sudo vim Profile command to open the environment variable configuration file.

添加export ZOOKEEPER_HOME=/opt/apache-zookeeper-3.5.5-bin

并在path中添加$ZOOKEEPER_HOME/bin

修改保存后,使用source /etc/profile 更新环境变量。

 

然后修改zookeeper的配置文件:

在zookeeper目录下的zoo_sample.cfg为zoo.cfg,使用sudo mv zoo_sample.cfg zoo.cfg:

 

使用sudo vim zoo.cfg,打开配置文件,配置节点信息:

记得三个节点都需要配置。

然后给zookeeper配置id,进入配置文件中的dataDir所指的目录,如果没有,就创建它:

创建一个myid文件,在其中分别写入编号0,1,2,如:

 

 配置完成,下面启动zookeeper

进入zookeeper安装目录的bin文件夹:

使用zkServer.sh start命令启动zookeeper(注意切换为root账号):

三个节点都启动起来之后,使用zkServer.sh status查看状态:

节点0:

节点1:

节点2:

 

 OK,集群环境搭建成功。

Guess you like

Origin www.cnblogs.com/wuyizuokan/p/11241670.html