zoukankan      html  css  js  c++  java
  • zookeeper3.4.6的安装

      最近为了解决HDFS的单点故障的问题,采用了HA的方式是实现,并通过zookeeper来实现自动切换,既然需自动切换的话,那么必须要安装zookeeper,我选用的版本是3.4.6。下面详细介绍一下其安装过程。

      再讲具体的步骤之前,需要说明的是,我安装zookeeper的集群是用到了五个节点:分别是hadoop1,hadoop2,hadoop3,hadoop4,hadoop5。也就是说要在这五个节点上部署zookeeper。这里需要注意一点:zookeeper集群的节点数必须是奇数,并且至少为3个。这里涉及到zookeeper的选举算法。

    1、首先肯定是从官网下载相应的tar包,并解压

      网址:http://zookeeper.apache.org/releases.html#download 截至到我发表该文章的时候,应尽出现了3.5.0的版本了。

      解压:tar -zxvf zookeeper-3.4.6.tar.gz

    2、添加环境变量

      export ZOOKEEPER_HOME=/home/grid/zookeeper-3.4.6

      export PATH=$PATH:$ZOOKEEPER_HOME/bin

    3、修改配置文件

      cd   zookeeper-3.4.6/conf ,将zoo_sample.cfg复制为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=/home/grid/zookeeper-3.4.6/zkdata
    dataLogDir=/home/grid/zookeeper-3.4.6/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.
    #
    # 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=hadoop1:2888:3888
    server.2=hadoop2:2888:3888
    server.3=hadoop3:2888:3888
    server.4=hadoop4:2888:3888
    server.5=hadoop5:2888:3888
    

      在这里需要注意zoo.cfg的配置文件中的dataDir和dataLogDir的路径当中的文件夹必须要已存在,否则后面启动zkServer服务的时候会失败。

    4、在dataDir对应的路径文件夹下(我这里是zkdata文件夹),创建一个myid的文件,并在该文件中输入对应集群各节点的id,我这里对应的是hadoop1对应的就是1,这个是与

    server.1=hadoop1:2888:3888对应的。各个节点分别输入对应的id值即可。

    5、启动zkServer

      在各节点上执行:zkServer.sh start   并通过jps可以看到:启动了QuorumpeerMain进程。

      

    6、此时可以通过zkServer.sh  status 命令来查看节点的启动状态。

      这里需要注意点,只有当至少启动了三个节点之后,该命令才会产生结果。否则会显示:zookeeper Error contacting service. It is probably not running错误

      当你启动了至少三个节点之后,执行该命令可以看到:

      

      至此,zookeeper的安装工作结束。

    7、关闭zookeeper服务

      zkServer.sh stop  关闭

      zkServer.sh restart  重启

      

  • 相关阅读:
    5.21动态生成dll
    xtype:"combo" 动态加载
    用javascript 禁止右键,禁止复制,禁止粘贴
    页面正在载入(js代码)
    Ext.data.Store
    转 C#生成JSON数据格式的函数
    .Net 3.5环境下常用数组性能测试
    Lucene.Net 2.3.1开发介绍 —— 二、分词(六)
    Lucene.Net 2.3.1开发介绍 —— 三、索引(三)
    Lucene.Net 2.3.1开发介绍 —— 三、索引(二)
  • 原文地址:https://www.cnblogs.com/ljy2013/p/4510143.html
Copyright © 2011-2022 走看看