zoukankan      html  css  js  c++  java
  • Linux下ZooKeeper集群安装

    一、简介

      ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,

    提供的功能包括:配置维护、域名服务、分布式同步、组服务等。

    二、安装

      1、个人三台Linux机器地址为:

    主机名    ip地址
    node3    192.168.182.xxx
    node4    192.168.182.xxx
    node5    192.168.182.xxx

      2、登陆其中一台主机后,下载

    # 切换目录
    cd /root
    # 下载
    wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz
    # 创建apps目录
    mkdir apps
    # 创建zookeeper存储目录
    mkdir zkdata
    # 解压
    tar -zxvf zookeeper-3.4.5.tar.gz -C /root/apps

      3、修改配置

    cd  /root/apps/zookeeper-3.4.5/conf/
    cp  zoo_sample.cfg  zoo.cfg
    vi  zoo.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=/root/zkdata
    # the port at which the clients will connect
    clientPort=2181
    #
    # 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=node3:2888:3888
    server.2=node4:2888:3888
    server.3=node5:2888:3888

      其中修改dataDir为/root/zkdata,再该目录下新建myid文件,内容为server点后的数字,例如:现在安装的是node3机器,则配置集群信息为server.1=node3:2888:3888,myid内容为1

      4、重复2安装node4,node5上的zookeeper,或者使用远程拷贝,修改相应配置

    scp -r /home/apps root@node4:/home/apps/
    scp -r /home/zkdata root@node4:/home/zkdata/

      5、启动测试,依次启动

    # 启动
    /root/apps/zookeeper-3.4.5/bin/zkServer.sh start
    # 查看状态
    /root/apps/zookeeper-3.4.5/bin/zkServer.sh status
    # 停止
    /root/apps/zookeeper-3.4.5/bin/zkServer.sh stop

      6、也可以写个集群自启动脚本

    #!/bin/bash
    SERVERS="node3 node4 node5"
    echo "start zkServers ..."
    for server in $SERVERS
    do
        ssh $server "source /etc/profile;/root/apps/zookeeper-3.4.5/bin/zkServer.sh start"
    done

    yexiangyang

    moyyexy@gmail.com


     

  • 相关阅读:
    Tomcat安装和配置过程
    Java集合框架概述
    Hash表的原理
    Java 浅拷贝和深拷贝的理解和实现方式
    Nginx 配置上传文件大小
    将博客搬至CSDN
    vscode中设置vue代码片段
    底部标签栏获取token失败
    Eacharts K线报错问题
    阿里字体图标库在项目中引用
  • 原文地址:https://www.cnblogs.com/moy25/p/8698727.html
Copyright © 2011-2022 走看看