环境:

Ubuntu18.04
四台机器:Ubuntu1,Ubuntu2,Ubuntu3,Ubuntu4
Hadoop3.2.0
ZooKeeper3.4.13
Hbase1.2.6

前言

之前装过hbase,装的是最新的版本2.1.3
但是…出问题了。
说是文件系统不支持hsyc
一查才知道,hbase和hadoop还有兼容性的问题
http://hbase.apache.org/book.html#basic.prerequisites
大家可以在说明文档里面看到兼容性说明
现在情况是这样
HBase安装与配置
这我一看我就懵了。
我Hadoop用的是3.2.0啊,怎么办
然后就上网找解决方案,看见可以用1.2.6。
好吧,那就搞一个。后面的就简单了。

说明

hbase要安装成集群。
一个或多个节点安装为HMaster
剩下节点安装HRegionServer
我打算将Ubuntu3和Ubuntu4作为HRegionServer节点
Ubuntu1和Ubuntu2作为HMaster

准备

下载
hbase1.2.6
hbase其他版本
先装好Hadoop和ZooKeeper
并启动。
配置好ssh
Hadoop Ha(高可用) 方案 配置和安装

解压

tar -zxvf hbase-1.2.6-bin.tar.gz -C ~/hbase

安装配置

hbase的配置文件放在hbase目录的conf目录下。
配置hbase-env .sh
在文件中加入

export JAVA_HOME=/usr/lib/jdk/jdk1.8.0_201
export HBASE_MANAGES_ZK=false  

需要注意的是:
HBASE_MANAGES_ZK配置项表示,是否使用hbase自带的zookeeper。
选择false,使用我们自己配置的zookeeper。

配置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>
<!-- 指定hbase在HDFS上存储的路径 -->
	<property>
		<name>hbase.rootdir</name>
		<value>hdfs://ns1/hbase</value>
	</property>
<!-- 指定hbase是分布式的 -->
	<property>
		<name>hbase.cluster.distributed</name>
		<value>true</value>
	</property>
<!-- 指定zk的地址,多个用“,”分割 -->
	<property>
		<name>hbase.zookeeper.quorum</name>
		<value>Ubuntu3,Ubuntu4</value>
	</property>
</configuration>

获得hdfs配置信息
hbase需要获得hdfs的配置信息
复制hadoop/etc/hadoop目录下的core-site.xml和hdfs-site.xml到hbase的conf目录下

配置regionservers
里面写的是HRegionServer节点的主机号

Ubuntu3
Ubuntu4

配置完成

分发hbase

将配置好的hbase发到其他主机上

scp hbase Ubuntu2:~/
scp hbase Ubuntu3:~/
scp hbase Ubuntu4:~/

在所有主机配置环境变量

sudo vim /etc/profile
export JAVA_HOME=/usr/lib/jdk/jdk1.8.0_201
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export HADOOP_HOME=/home/czq/hadoop/hadoop-3.2.0
export HIVE_HOME=/home/czq/hive/apache-hive-3.1.1-bin
export HBASE_HOME=/home/czq/hbase/hbase-1.2.6
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin:$HBASE_HOME/bin
source /etc/profile

启动hbase

在Ubuntu1上启动

start-hbase.sh

这时候,Ubuntu1成为HMaster,Ubuntu2和Ubuntu3成为HRegionServer。
再在Ubuntu2输入此命令,Ubuntu2成为热备份的HMaster。

关闭Hbase

在Ubuntu1或2输入

stop-hbase.sh

如果想关闭HRegionServer

hbase-daemon.sh stop regionserver RegionServer

访问Web页面

在hbase启动时输入
主机名:16010

相关文章:

  • 2022-12-23
  • 2021-04-01
  • 2021-12-27
  • 2021-05-10
  • 2021-11-22
  • 2021-07-18
  • 2022-02-09
猜你喜欢
  • 2022-01-10
  • 2021-07-17
  • 2021-09-27
  • 2022-01-01
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案