zoukankan      html  css  js  c++  java
  • Zookeeper安装

    Zookeeper windows环境安装

    环境要求:必须要有jdk环境

    1.安装jdk

    2.安装Zookeeper. 在官网http://zookeeper.apache.org/下载zookeeper.我下载的是zookeeper-3.4.6版本。

    解压zookeeper-3.4.6至D:machinezookeeper-3.4.6.

    在D:machine 新建data及log目录。

    3.ZooKeeper的安装模式分为三种,分别为:单机模式(stand-alone)、集群模式和集群伪分布模式。ZooKeeper 单机模式的安装相对比较简单,如果第一次接触ZooKeeper的话,建议安装ZooKeeper单机模式或者集群伪分布模式。

    安装单机模式。D:machinezookeeper-3.4.6conf中 复制 zoo_sample.cfg 并粘贴到当前目录下,命名zoo.cfg。

    Zookeeper集群环境搭建(linux)

    环境要求:必须要有jdk环境

    结构

    一共三个节点(zk服务器集群规模不小于3个节点),要求服务器之间系统时间保持一致。

    上传zk并且解压

    进行解压:

     tar -zxvf zookeeper-3.4.6.tar.gz

    重命名: 

    mv zookeeper-3.4.6 zookeeper

    修改zookeeper环境变量

    vi /etc/profile
    
    export JAVA_HOME=/opt/jdk1.8.0_71
    
    export ZOOKEEPER_HOME=/usr/local/zookeeper
    
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    
    export PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH
    source /etc/profile

    修改zoo_sample.cfg文件

    cd /usr/local/zookeeper/conf
    mv zoo_sample.cfg zoo.cfg


    修改conf: vi zoo.cfg 修改两处

    (1) dataDir=/usr/local/zookeeper/data(注意同时在zookeeper创建data目录)

    (2)最后面添加server.0=bhz:2888:3888server.1=hadoop1:2888:3888server.2=hadoop2:2888:3888

    创建服务器标识

    服务器标识配置:创建文件夹: mkdir data创建文件myid并填写内容为0: vimyid (内容为服务器标识 : 0)

    复制zookeeper

    进行复制zookeeper目录到hadoop01和hadoop02
    还有/etc/profile文件
    把hadoop01、 hadoop02中的myid文件里的值修改为1和2
    路径(vi /usr/local/zookeeper/data/myid)

    启动zookeeper

    启动zookeeper:

    路径: /usr/local/zookeeper/bin

    执行: zkServer.sh start(注意这里3台机器都要进行启动)

    状态: zkServer.sh status(在三个节点上检验zk的mode,一个leader和俩个follower)

    常用命令

    zkServer.sh status 查询状态

    Zookeeper配置文件介绍

    # 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/myuser/zooA/data 

    # the port at which the clients will connect 

    clientPort=2181 

    # ZooKeeper server and its port no. # ZooKeeper ensemble should know about every other machine in the ensemble # specify server id by creating 'myid' file in the dataDir # use hostname instead of IP address for convenient maintenance

    server.1=127.0.0.1:2888:3888 

    server.2=127.0.0.1:2988:3988  

    server.3=127.0.0.1:2088:3088 

    # 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  <br>

    #autopurge.purgeInterval=1 

    dataLogDir=/home/myuser/zooA/log

    tickTime:心跳时间,为了确保连接存在的,以毫秒为单位,最小超时时间为两个心跳时间

    initLimit:多少个心跳时间内,允许其他server连接并初始化数据,如果ZooKeeper管理的数据较大,则应相应增大这个值

    clientPort:服务的监听端口

    dataDir:用于存放内存数据库快照的文件夹,同时用于集群的myid文件也存在这个文件夹里(注意:一个配置文件只能包含一个dataDir字样,即使它被注释掉了。)

    dataLogDir:用于单独设置transaction log的目录,transaction log分离可以避免和普通log还有快照的竞争

    syncLimit:多少个tickTime内,允许follower同步,如果follower落后太多,则会被丢弃。

    server.A=B:C:D:
    A是一个数字,表示这个是第几号服务器,B是这个服务器的ip地址
    C第一个端口用来集群成员的信息交换,表示的是这个服务器与集群中的Leader服务器交换信息的端口
    D是在leader挂掉时专门用来进行选举leader所用

  • 相关阅读:
    POJ1811 Prime Test
    HDU3864 D_num
    HDU2138 How many prime numbers
    SPOJ1812 LCS2
    SPOJ1811 LCS
    SPOJ8222 NSUBSTR
    BZOJ4237 稻草人
    洛谷P3601 签到题
    ThreadLocal 线程的私有内存
    netty in action 笔记 二
  • 原文地址:https://www.cnblogs.com/aaron911/p/10758229.html
Copyright © 2011-2022 走看看