Zookeeeper cluster installation and set up

Brief introduction

Download Zookeeper

Official website address: point I direct

Baidu cloud disk: point I direct

Stepped pit recorded

Be sure to download the official website to download the bin with

 

Otherwise zookeeper from it, to load the class can not be found inside the original download version 3.5.5 from the beginning, with the name of bin package is what we want can be directly used has binary packages compiled, and before ordinary tar.gz package which is just a source package can not be used directly.

Under really want to Tucao ah, Zookeeper change the package, source package can not add a logo src do the same to other installation package? See the name to know how well intended, to avoid false download.

Stand-alone Zookeeper

Create a directory and unzip

Into the extracted directory 

Enter conf 

Copy zoo_sample.cfg ( target file, you must zoo.cfg )

Compiled file copy: zoo.cfg

NOTE: After modifying the snapshot storage directory, use: the X-

Establish flexible connections

Environment variable configuration

vim /etc/profile

Validate the configuration:source /etc/profile

start up

./zkServer.sh start

note

  linux need jdk, turn off the firewall

Cluster Zookeeper

Ready to work

  The above table 1 single clone configured linux, used to set up a cluster.

Creating myid

  Snapshot storage directory zoo.cfg came just set down, I have here is / usr / data / zookeeper

Enter the installation directory

  Modify conf / zoo.cfg


Add all cluster host information

format

server.1=192.168.1.101:2888:3888
server.2=192.168.1.102:2888:3888
server.3=192.168.1.103:2888:3888


格式:
server.myid文件中的值=ip:端口号:端口号


端口号是集群数据交互的端口号,可以瞎写,但不能被占用

集群搭建个数,至少2个,最好奇数,这样zookeeper投票可以过半

重复克隆2台配置过集群主机信息的那台linux

  注:别忘记修改myid中对应的值!!!!

 

依次启动zookeeper集群

启动第一台

 

启动第二台

第二台变为了leader

 

我们查看刚才第一台,此时变为了

 

启动第三台

 

模拟情况

第二台关机(模拟实际情况服务器挂了)

 

查看第一台

 

查看第三台

 

搞定!!!!!

Guess you like

Origin www.cnblogs.com/chenyanbin/p/12202048.html