Zookeeper集群安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zookeeper集群安装相关的知识,希望对你有一定的参考价值。

  • 在根目录创建zookeeper文件夹(service1、service2、service3都创建)
  • [[email protected] /]# mkdir zookeeper

    通过Xshell上传文件到service1服务器:上传zookeeper-3.4.6.tar.gz到/software文件夹

    2.远程copy将service1下的/software/zookeeper-3.4.6.tar.gz到service2、service3

    [[email protected] software]# scp -r /software/zookeeper-3.4.6.tar.gz [email protected]:/software/

    [[email protected] software]# scp -r /software/zookeeper-3.4.6.tar.gz [email protected]:/software/

    copy /software/zookeeper-3.4.6.tar.gz到/zookeeper/目录(service1、service2、service3都执行)

    [[email protected] software]# cp /software/zookeeper-3.4.6.tar.gz /zookeeper/

    安装解压zookeeper-3.4.6.tar.gz(service1、service2、service3都执行)

    [[email protected] /]# cd /zookeeper/

    [[email protected] zookeeper]# tar -zxvf zookeeper-3.4.6.tar.gz

    在/zookeeper创建两个目录:zkdata、zkdatalog(service1、service2、service3都创建)

    [[email protected] zookeeper]# mkdir zkdata

    [[email protected] zookeeper]# mkdir zkdatalog

    进入/zookeeper/zookeeper-3.4.6/conf/目录

    [[email protected] zookeeper]# cd /zookeeper/zookeeper-3.4.6/conf/

    [[email protected] conf]# ls

    configuration.xsl log4j.properties zoo.cfg zoo_sample.cfg

    修改zoo.cfg文件

    The number of milliseconds of each tick

    tickTime=2000

    The number of ticks that the initial

    synchronization phase can take

    initLimit=10

    The number of ticks that can pass between

    sending a request and getting an acknowledgement

    syncLimit=5

    the directory where the snapshot is stored.

    do not use /tmp for storage, /tmp here is just

    example sakes.

    dataDir=/zookeeper/zkdata

    dataLogDir=/zookeeper/zkdatalog

    the port at which the clients will connect

    clientPort=2181

    the maximum number of client connections.

    increase this if you need to handle more clients

    maxClientCnxns=60

    Be sure to read the maintenance section of the

    administrator guide before turning on autopurge.

    The number of snapshots to retain in dataDir

    autopurge.snapRetainCount=3

    Purge task interval in hours

    Set to "0" to disable auto purge feature

    #autopurge.purgeInterval=1

    server.1=192.168.2.211:12888:13888

    server.2=192.168.2.212:12888:13888

    server.3=192.168.2.213:12888:13888

    1. 同步修改service2、service3的zoo.cfg配置

    2. myid文件写入(进入/zookeeper/zkdata目录下)

    [[email protected] /]# cd /zookeeper/zkdata

    [[email protected] /]# echo 1 > myid

    1. myid文件写入service2、service3

    echo 2 > myid

    echo 3 > myid

    11.查看zk命令:

    [[email protected] ~]# cd /zookeeper/zookeeper-3.4.6/bin/

    [[email protected] bin]# ls

    README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh zookeeper.out

    12.执行zkServer.sh查看详细命令:

    [[email protected] bin]# ./zkServer.sh

    JMX enabled by default

    Using config: /zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg

    Usage: ./zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}

    1. 在service1、service2、service3分别启动zk服务

    [[email protected] bin]# ./zkServer.sh start

    1. jps查看zk进程

    [[email protected] bin]# jps

    31483 QuorumPeerMain

    31664 Jps

    1. 分别在service1、service2、service3查看zk状态(可以看到leader和follower节点)

    [[email protected] bin]# ./zkServer.sh status

    JMX enabled by default

    Using config: /zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg

    Mode: follower

    [[email protected] bin]# ./zkServer.sh status

    JMX enabled by default

    Using config: /zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg

    Mode: leader

    1. 看到leader和follower节点已经安装成功

    分布式的一些解决方案,有愿意了解的朋友可以找我们团队探讨 。

    以上是关于Zookeeper集群安装的主要内容,如果未能解决你的问题,请参考以下文章

    安装Zookeeper和Kafka集群

    02_zookeeper集群安装

    Zookeeper集群安装部署

    Zookeeper集群部署

    ZooKeeper集群的安装配置高可用测试

    Zookeeper集群+Kafka集群+ELK