Hbase下载与安装部署(二)- 使用外部Zookeeper独立部署

配置不使用内置Zookeeper

Hbase有内置的zookeeper,上一篇文章我就是使用Hbase内置的zookeeper启动Hbase的,如果想要使用外部独立的Zookeeper,需要将conf/hbase-env.sh中的HBASE_MANAGES_ZK设置为false,使内置的Zookeeper不受Hbase管理,不随Hbase启动而启动,不随Hbase停止而停止

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

当你想使用Hbase内置的Zookeeper,又不想因为停止或启动Hbase时,Zookeeper跟着停止或启动,可以执行以下命令
${HBASE_HOME}/bin/hbase-daemons.sh {start,stop} zookeeper

下载安装外部Zookeeper

官网 https://zookeeper.apache.org/

在这里插入图片描述
选择要下载的版本
在这里插入图片描述
点击下载
在这里插入图片描述
上传到服务器你指定的目录并解压
在这里插入图片描述

需要将conf文件夹中的zoo_sample.cfg文件复制并将文件名改为 zoo.cfg

打开zoo.cfg文件,并在zoo.cfg文件末尾加上这两项配置

export ZOOKEEPER_HOME=/usr/local/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin

进入zookeeper的bin目录,启动Zookeeper

./zkServer.sh start
启动Hbase连接Zookeeper

修改Hbase的hbase-site.xml文件

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-->
<configuration>
  <!--
    The following properties are set for running HBase as a single process on a
    developer workstation. With this configuration, HBase is running in
    "stand-alone" mode and without a distributed file system. In this mode, and
    without further configuration, HBase and ZooKeeper data are stored on the
    local filesystem, in a path under the value configured for `hbase.tmp.dir`.
    This value is overridden from its default value of `/tmp` because many
    systems clean `/tmp` on a regular basis. Instead, it points to a path within
    this HBase installation directory.

    Running against the `LocalFileSystem`, as opposed to a distributed
    filesystem, runs the risk of data integrity issues and data loss. Normally
    HBase will refuse to run in such an environment. Setting
    `hbase.unsafe.stream.capability.enforce` to `false` overrides this behavior,
    permitting operation. This configuration is for the developer workstation
    only and __should not be used in production!__

    See also https://hbase.apache.org/book.html#standalone_dist
  -->
  <property>
    <name>hbase.cluster.distributed</name>
    <value>false</value>
  </property>
  <property>
    <name>hbase.tmp.dir</name>
    <value>./tmp</value>
  </property>
  <property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>false</value>
  </property>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>master</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.clientPort</name>
    <value>2181</value>
  </property>

</configuration>

当我启动外部独立的Zookeeper,启动Hbase连接时,报错,显示Hbase依然使用内置的Zookeeper,并与我的外部Zookeeper端口冲突

在这里插入图片描述

查看Hbase的hbase-site.xml文件,因为把hbase.cluster.distributed设置为false, 也就是让hbase以standalone模式运行时,依然会去启动自带的zookeeper。

所以要做如下设置,值为true:

<property>
     <name>hbase.cluster.distributed</name>
     <value>true</value> 
</property>

注:hbase.zookeeper.quorum中的master为我在/etc/hosts中配置的

在这里插入图片描述

再次启动Hbase,启动成功

在这里插入图片描述

### 下载安装 HBase 最新稳定版 #### 获取最新版本 为了获取最新的稳定版本,建议访问 Apache 官方网站或者官方镜像站点来下载 HBase 的压缩包。通常情况下,官方网站会提供详细的说明文档以及不同平台下的进制分发文件。 ```bash wget https://archive.apache.org/dist/hbase/stable/hbase-2.7.4-bin.tar.gz ``` 此命令用于从Apache存档中下载指定版本的HBase软件包[^1]。 #### 解压安装包 完成下载之后,在目标位置解压缩该 tarball 文件: ```bash tar zxvf hbase-2.7.4-bin.tar.gz -C /opt/ ``` 上述指令将把 `hbase` 文件夹提取到 `/opt/` 目录下,并创建相应的子目录结构[^3]。 #### 配置 Java 环境变量 编辑位于 `/opt/hbase/hbase-2.7.4/conf/` 路径中的 `hbase-env.sh` 文件以设置正确的 JDK 地址: ```properties export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 ``` 这段配置指定了运行时所需的 JVM 版本所在的位置。 #### 设置 HBase 环境变量(可选) 如果希望在整个系统范围内使用 HBase 命令行工具,则可以考虑修改全局 shell profile 来添加必要的 PATH 变量: ```bash echo 'export HBASE_HOME=/opt/hbase/hbase-2.7.4' >> ~/.bashrc echo 'export PATH=$PATH:$HBASE_HOME/bin' >> ~/.bashrc source ~/.bashrc ``` 这些更改使得可以在任何地方调用 HBase 提供的各种 CLI 工具而无需每次都输入完整的路径名。 #### 创建软链接至 Hadoop 配置文件(视情况决定是否执行) 对于某些特定场景来说,可能还需要建立指向已有 Hadoop 实例配置文件 (`core-site.xml`, `hdfs-site.xml`) 的符号链接以便让 HBase 正确识别存储层的相关参数[^2]: ```bash ln -s /path/to/hadoop/etc/hadoop/core-site.xml ./conf/ ln -s /path/to/hadoop/etc/hadoop/hdfs-site.xml ./conf/ ``` 请注意替换实际存在的 hadoop 配置文件所在的绝对路径。 #### 启动服务前准备 最后一步是在启动之前确认所有的前置条件都已经满足,比如已经正确设置了 Zookeeper 和其他依赖组件的服务状态等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值