• Zookeeper:在三种模式下的部署


    zookeeper 安装模式有三种:单机模式:单机单 server;集群模式:多机多 server,形成集群;伪集群模式:单机多 server,形成伪集群。

    ~

    本篇内容包括:Zookeeper 官网下载、Zookeeper 单机模式部署、Zookeeper 集群安装、Zookeeper 集群安装



    一、Zookeeper 官网下载

    进入官网下载 Zookeeper,这里我们使用的版本为 Zookeeper-3.5.7

    Zookeeper 官网地址: http://zookeeper.apache.org/

    zookeeper 安装模式有三种:单机模式:单机单 server;集群模式:多机多 server,形成集群;伪集群模式:单机多 server,形成伪集群。

    二、Zookeeper 单机模式部署

    1、安装 JDK

    # 安装JDK

    可以参照:Java基础:Java程序设计环境

    2、安装 Zookeeper

    # 官网下载

    # 拷贝 apache-zookeeper-3.5.7-bin.tar.gz 到 Linux系统下

    # 解压到指定目录:

    tar -zxvf apache-zookeeper-3.5.7-bin.tar.gz -C /opt/module/
    
    • 1

    # 改名

    mv apache-zookeeper-3.5.7-bin zookeeper-3.5.7
    
    • 1
    3、修改 Zookpeeper 配置

    # 进入conf目录

    # mv zoo_sample.cfg zoo.cfg

    # mkdir /opt/module/zookeeper-3.5.7/zkData

    # vi 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=/opt/module/zookeeper-3.5.7/zkData
    # 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.
    #
    # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
    #
    # 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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    4、运行 Zookeeper

    # 启动Zookeeper:bin/zkServer.sh start

    # 查看进程jps

    # 客户端访问:bin/zkCli.sh

    三、Zookeeper 集群安装

    1、安装JDK(每一台服务器);

    # 安装JDK

    可以参照:Java基础:Java程序设计环境

    2、安装 Zookeeper

    # 拷贝 apache-zookeeper-3.5.7-bin.tar.gz 到 Linux系统下(每一台服务器)

    # 解压到指定目录(每一台服务器):

    tar -zxvf apache-zookeeper-3.5.7-bin.tar.gz -C /opt/module/
    
    • 1

    # 改名(每一台服务器)

    mv apache-zookeeper-3.5.7-bin zookeeper-3.5.7
    
    • 1
    3、修改 Zookpeeper 配置

    # 进入conf目录(每一台服务器)

    # mv zoo_sample.cfg zoo.cfg(每一台服务器)

    # mkdir /opt/module/zookeeper-3.5.7/zkData(每一台服务器)

    # vi /opt/module/zookeeper-3.5.7/zkData/myid,填写每天服务器对应的 ID

    # vi 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=/opt/module/zookeeper-3.5.7/zkData
    # 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.
    #
    # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
    #
    # 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=master:2888:3888
    server.2=slave1:2888:3888
    server.3=slave2:2888:3888
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    4、运行 Zookeeper

    # 启动服务:每台机器执行:bin/zkServer.sh start

    # 查看每个节点状态:bin/zkServer.sh status

    四、Zookeeper 集群启动停止脚本

    #!/bin/bash
    
    case $1 in
    "start"){
            for i in master slave1 slave2
            do
                    echo ----- zookeeper $i 启动-----
                    ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh start"
            done
    }
    ;;
    "stop"){
            for i in master slave1 slave2
            do
                    echo ----- zookeeper $i 停止-----
                    ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh stop"
            done
    }
    ;;
    "status"){
            for i in master slave1 slave2
            do
                    echo ----- zookeeper $i 状态-----
                    ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh status"
            done
    }
    ;;
    esac
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
  • 相关阅读:
    制作一个简单HTML传统端午节日网页(HTML+CSS)7页 带报告
    GBase 8c V3.0.0数据类型——几何类型转换函数
    Linux高级编程——线程
    下载、安装Git并拷贝GitHub项目到本地的流程
    R语言APRIORI关联规则、K-MEANS均值聚类分析中药专利复方治疗用药规律网络可视化...
    典型相关分析CCA计算过程
    haskell的列表推导中的基本概念和其他列表功能head/tail/take/drop
    C#调用C++dll的时候如何同步调试dll?
    函数MessageBox
    安科瑞Acrel-7000工业能耗在线监测系统,企业能源管控平台
  • 原文地址:https://blog.csdn.net/weixin_45187434/article/details/127939706