Zookeeper集群的安装搭建

前提条件

三个zookeeper实例。Zookeeper也是java开发的所以需要安装jdk。
1、Linux系统
2、Jdk环境。

3、Zookeeper。


Zookeeper的安装步骤

第一步:把zookeeper的安装包上传到服务器

第二步:解压缩。

[root@solr ~]# tar -zxvf zookeeper-3.4.6.tar.gz


第三步:在/home/目录下创建一个solrcloud目录。把zookeeper解压后的文件夹复制到此目录下三份。分别命名为zookeeper1、2、3

[root@solr ~]# mkdir /home/solrcloud

[root@solr ~]# mv zookeeper-3.4.6 /home/solrcloud/zookeeper1

[root@solr ~]# cd /home/solrcloud/

[root@solr solrcloud]# cp -r zookeeper1/ zookeeper2

[root@solr solrcloud]# cp -r zookeeper1/ zookeeper3


第四步:配置zookeeper。

1、在每个zookeeper文件夹下创建一个data目录。

2、data文件夹下创建一个文件名称为myid,文件的内容就是此zookeeper的编号123

[root@solr solrcloud]# echo 1 >> zookeeper1/data/myid

[root@solr solrcloud]# echo 2 >> zookeeper2/data/myid

[root@solr solrcloud]# echo 3 >> zookeeper3/data/myid

3、分别把zookeeper123conf目录下的zoo_sample.cfg文件复制一份改名为zoo.cfg

[root@solr conf]# cp zoo_sample.cfg zoo.cfg

4、分别修改zookeeper123配置文件zoo.cfgzookeeper2clientPort=2182zookeeper3clientPort=2183

dataDir=/home/solrcloud/zookeeper1/data/

clientPort=2181

server.1=192.168.168.128:2881:3881

server.2=192.168.168.128:2882:3882

server.3=192.168.168.128:2883:3883

Zookeeper集群的安装搭建_第1张图片


第五步:启动zookeeper。进入zookeeper1/bin目录下。

启动zookeeper./zkServer.sh start

关闭:./zkServer.sh stop

查看状态:./zkServer.sh status

[root@solr solrcloud]# zookeeper1/bin/zkServer.sh start

JMX enabled by default

Using config: /home/solrcloud/zookeeper1/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

[root@solr solrcloud]# zookeeper2/bin/zkServer.sh start

JMX enabled by default

Using config: /home/solrcloud/zookeeper2/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

[root@solr solrcloud]# zookeeper3/bin/zkServer.sh start

JMX enabled by default

Using config: /home/solrcloud/zookeeper3/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

 

查看状态:

[root@solr solrcloud]# zookeeper1/bin/zkServer.sh status

JMX enabled by default

Using config: /home/solrcloud/zookeeper1/bin/../conf/zoo.cfg

Mode: follower

[root@solr solrcloud]# zookeeper2/bin/zkServer.sh status

JMX enabled by default

Using config: /home/solrcloud/zookeeper2/bin/../conf/zoo.cfg

Mode: leader

[root@solr solrcloud]# zookeeper3/bin/zkServer.sh status

JMX enabled by default

Using config: /home/solrcloud/zookeeper3/bin/../conf/zoo.cfg

Mode: follower


你可能感兴趣的:(zookeeper)