一个分布式HBase系统安装依赖于一个运行着的ZooKeeper集群,所有参与的节点和客户端必须能够正常访问运行着的ZooKeeper集群。HBase默认为你提供一个节点的ZooKeeper集群,它会伴随着HBase start/stop进程的启动/停止而启动/停止,当然你也可以运行自己的一个ZooKeeper集群,为了切换是否启用默认ZooKeeper集群,需在conf/hbase-env.sh中将HBASE_MANAGES_ZK的值改为false,默认是ture。
当HBase管理ZooKeeper集群时,你可以在conf/hbase-site.xml上配置ZooKeeper属性,它们的前缀是hbase.zookeeper.property,如hbase.zookeeper.property.clientPort配置clientPort属性。完整的ZooKeeper集群列表参考ZooKeeper的 zoo.cfg文件,当ZooKeeper挂点时,你应该查看该文件。
配置HBase完全分布式系统时,在配置文件hbase-site.xml上你必须用hbase.zookeeper.quorum列出你的机器列表。
下面是关于HBase管理ZooKeeper的实例,注意,你应该配置hbase.zookeeper.property.dataDir属性而不是使用默认值,由于默认值保存数据到/tmp目录,系统重启时就会被清空。

  <configuration>
    ...
    <property>
      <name>hbase.zookeeper.property.clientPort</name>
      <value>2222</value>
      <description>Property from ZooKeeper's config zoo.cfg.
      The port at which the clients will connect.
      </description>
    </property>
    <property>
      <name>hbase.zookeeper.quorum</name>
      <value>rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com</value>
      <description>Comma separated list of servers in the ZooKeeper Quorum.
      For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".
      By default this is set to localhost for local and pseudo-distributed modes
      of operation. For a fully-distributed setup, this should be set to a full
      list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh
      this is the list of servers which we will start/stop ZooKeeper on.
      </description>
    </property>
    <property>
      <name>hbase.zookeeper.property.dataDir</name>
      <value>/usr/local/zookeeper</value>
      <description>Property from ZooKeeper's config zoo.cfg.
      The directory where the snapshot is stored.
      </description>
    </property>
    ...
  </configuration>

1 运用现存ZooKeeper系统

为了使HBase指向一个已经存在ZooKeeper集群,在conf/hbase-env.sh中设置HBASE_MANAGES_ZK位置false。

  ...
  # Tell HBase whether it should manage its own instance of Zookeeper or not.
  export HBASE_MANAGES_ZK=false

管理ZooKeeper可以使用HBase的start/stop脚本,如下:

${HBASE_HOME}/bin/hbase-daemons.sh {start,stop} zookeeper

更多启动分布式ZooKeeper集群信息,参考Getting Started Guide

2 ZooKeeper SASL认证

新版本的HBase(>0.92)连接ZooKeeper时支持SASL认证,Zookeeper版本需要3.4.0或以上。参照ZooKeeper SASL

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐