zoukankan      html  css  js  c++  java
  • Linux下搭建Zookeeper环境

    Zookeeper 是 Google 的 Chubby一个开源的实现,是 Hadoop 的分布式协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名服务等。

    其工作原理示意图如下:

    1.为什么使用Zookeeper

    »      大部分分布式应用需要一个主控、协调器或控制器来管理物理分布的子进程(如资源、任务分配等)

    »      目前,大部分应用需要开发私有的协调程序,缺乏一个通用的机制

    »      协调程序的反复编写浪费,且难以形成通用、伸缩性好的协调器

    »      ZooKeeper:提供通用的分布式锁服务,用以协调分布式应用

    2.Zookeeper能做什么

    »      Hadoop2.0,使用Zookeeper的事件处理确保整个集群只有一个活跃的NameNode,存储配置信息等

    »      HBase,使用Zookeeper的事件处理确保整个集群只有一个HMaster,察觉HRegionServer联机和宕机,存储访问控制列表等

    3.Zookeeper的特性

    »      Zookeeper是简单的

    »      Zookeeper是富有表现力的

    »      Zookeeper具有高可用性

    »      Zookeeper采用松耦合交互方式

    »      Zookeeper是一个资源库

     

    4.在Linux下的配置

    我们启动三个主机,每个执行相同的操作。

    首先下载压缩包

    http://labs.renren.com/apache-mirror/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz

    进行解压tar -zxvf zookeeper-3.4.5.tar.gz -C /home/hadoop/app

    在zookeeper/conf/zoo.cfg中进行如下配置:(刚开始是zoo_sample.cfg,重命名一下,最下面三个是三台主机的IP)

    # 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=/home/hadoop/app/zookeeper-3.4.5/data
    # 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=192.168.230.135:2888:3888
    server.2=192.168.230.136:2888:3888
    server.3=192.168.230.137:2888:3888

    回到data目录下(data目录是自己建的zookeeper/data),分别在不同主机下执行echo 1 > myid,echo 2 > myid,echo 3 > myid

    在zookeeper/bin目录下,进行启动:./zkServer.sh start(关闭是 ./zkServer.sh stop)

    进行监控:./zkServer.sh status

    可以看到一台主节点,两台从节点。

    批量启动zookeeper服务器脚本(可以自己修改):

    #!/bin/sh
    echo 'start zkServer...'
    for i in 1 2 3
    do
    ssh weekend0$i 'source /etc/profile;/home/hadoop/app/zookeeper-3.4.5/bin/zkServer.sh start'
    done
  • 相关阅读:
    Python--day34--socket模块的方法
    Python--day32--ftp文件传输报错的原因
    Python--day32--struct模块
    Python--day32--复习:https和http的区别;黏包;黏包问题的解决方式;
    快捷键(随时补充)
    turtle 20秒画完小猪佩奇“社会人”
    Kibana使用教程
    Elasticsearch: 权威指南
    數據可視化大屏
    newtonsoft文檔說明
  • 原文地址:https://www.cnblogs.com/DarrenChan/p/6479061.html
Copyright © 2011-2022 走看看