Hbase2.4.17安装

介绍

Hbase是一个开源的分布式列式数据库,它是构建在Apache Hadoop之上的一部分,用于处理大规模数据集。HBase的设计灵感来自于Google的Bigtable论文,它提供了对结构化数据的高可用、高性能和可伸缩的存储和访问。

HBase被设计用于在大规模的集群上存储和处理海量数据。它具有以下主要特点:

  • 列式存储:HBase将数据按列进行存储,而不是按行存储。这种存储方式使得读取特定列的数据非常高效,并且支持灵活的数据模式。
  • 可伸缩性:HBase可以在成百上千个服务器上运行,并能够处理非常大的数据集。它使用分布式架构、将数据划分为多个区域(regions),并将这些区域分布在集群中的不同节点上,以实现数据的负载均衡和并行处理。
  • 高可用性:HBase支持一致性模型,即当数据发生变化时,所有读取该数据的客户端都能够立即看到最新的变化。
  • 快速读写:HBase的设计目标之一是提供低延迟的读写操作。它使用内存和硬盘结合的方式,将热点数据存储在内存中,以加快读取和写入的速度。

HBase通常用于存储和处理需要快速随机读写的大数据集,例如日志数据、传感器数据、实时分析等。它在许多大型互联网公司和数据密集型应用中得到广泛应用。

总而言之,HBase是一个分布式、可伸缩、高可用性的列式数据库,适用于处理大规模数据集的存储和访问需求。

安装前准备

环境

  • centos 7.x
  • java 1.8.0_201
  • Hadoop 3.3.4
  • Zookeeper 3.7.1
  • HBase 2.4.17

规划

IP地址 主机名 HBase
172.16.77.202 hadoop-master-202 HMaster、ThriftServer
172.16.77.203 hadoop-node-203 HRegionServer 、HMaster(备)
172.16.77.204 hadoop-node-204 HRegionServer 、HMaster(备)
172.16.77.205 hadoop-node-205 HRegionServer 、HMaster(备)

安装HBase

下载HBase

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#下载HBase
wget https://dlcdn.apache.org/hbase/2.4.17/hbase-2.4.17-bin.tar.gz --no-check-certificate

#解压至安装目录
tar -zxvf hbase-2.4.17-bin.tar.gz -C /home/hadoop/software/


#安装包下主要目录和文件:
bin:包含了HBase的可执行脚本,如启动、停止和管理HBase集群的脚本。
conf:包含了HBase的配置文件,用于配置HBase集群的各种参数,如HBase的主要配置文件hbase-site.xml
docs:包含了HBase的文档,如用户指南、API文档等。
hbase-webapps:包含了HBase的web应用程序文件,用于提供HBase的web界面和管理工具。
lib:包含了HBase的依赖库文件,用于支持HBase的各种功能和扩展。


#将HBase安装目录分配至hadoop用户
chown -R hadoop:hadoop /home/hadoop/software/

配置环境变量

此处按自己的需求来,没有必须在/etc/profile添加 正常在~/.bashrc下添加就行,这里都加上了

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
vim /etc/profile
......
#hbase
export HBASE_HOME=/home/hadoop/software/hbase-2.4.17
export PATH=$PATH:$HBASE_HOME/bin



##加载环境环境,测试是否安装成功
source /etc/profile

echo $HBASE_HOME
#出现以下内容,说明正常
/home/hadoop/software/hbase-2.4.17
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
su - hadoop

vim ~/.bashrc
......
#hbase
export HBASE_HOME=/home/hadoop/software/hbase-2.4.17
export PATH=$PATH:$HBASE_HOME/bin

##加载环境环境
source ~/.bashrc

配置HBase

配置hbase-env.sh

1
2
3
4
5
6
7
cd $HBASE_HOME/conf

vim hbase-env.sh
......
#加入一下内容
#禁用HBase自带的zookeeper,使用外部的zookeeper
export HBASE_MANAGES_ZK=false

配置hbase-site.xml

/home/hadoop/software/hbase-2.4.17/conf/hbase-site.xml,按需求选择添加和修改配置

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?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>true</value>
    </property>
    <property>
        <!--hbase的根目录以及其对应的hdfs路径-->
        <name>hbase.rootdir</name>
        <value>hdfs://172.16.77.202:8020/hbase</value>
    </property>

    <property>
        <!--用于指定外部的zookeeper集群的地址-->
        <name>hbase.zookeeper.quorum</name>
        <value>172.16.77.202,172.16.77.203,172.16.77.204</value>
    </property>
    <property>
        <!--指定了HBase在ZooKeeper中的根节点(Root ZNode)默认是hbase-->
        <name>zookeeper.znode.parent</name>
        <value>/hbase-zk</value>
    </property>
    <property>
        <!--  HBase 用于缓存临时数据的目录  -->
        <name>hbase.tmp.dir</name>
        <value>/home/hadoop/software/hbase-2.4.17/tmp</value>
    </property>
    <!-- 是否启用 HBase 表压缩功能 -->
    <property>
        <!--Hasee存储区(HStore)的阻塞存储文件数  默认为16-->
        <name>hbase.hstore.blockingStoreFiles</name>
        <value>200</value>
    </property>
    <property>
        <!--HBase存储区(HStore)的阻塞等待时间 单位毫秒 默认90000 90秒-->
        <name>hbase.hstore.blockingWaitTime</name>
        <value>90000</value>
    </property>
    <property>
        <!--ZooKeeper会话的超时时间。单位毫秒 默认90000 90秒  这里设置了1小时-->
        <name>zookeeper.session.timeout</name>
        <value>3600000</value>
    </property>
    <property>
        <!--当ZooKeeper会话过期时是否重启HBase区域服务器。-->
        <name>hbase.regionserver.restart.on.zk.expire</name>
        <value>true</value>
    </property>
    <property >
        <!--  hbase主节点端口号 默认为16000  -->
        <name>hbase.master.port</name>
        <value>16000</value>
    </property>
    <property>
        <name>hbase.master.ipc.address</name>
        <value>0.0.0.0</value>
    </property>
    <property>
        <!--  HBase Master Web UI 的端口 默认为16010  -->
        <name>hbase.master.info.port</name>
        <value>16010</value>
    </property>
    <property>
        <!--  HBase Master Web UI 的绑定地址 默认为0.0.0.0 可以设置为ip地址-->
        <name>hbase.master.info.bindAddress</name>
        <value>0.0.0.0</value>
    </property>
    <property>
        <!--  HBase RegionServer 节点侦听的端口号,默认为 16020 -->
        <name>hbase.regionserver.port</name>
        <value>16020</value>
    </property>
    <property>
        <!--  HBase RegionServer web UI 的端口 默认为16030  -->
        <name>hbase.regionserver.info.port</name>
        <value>16030</value>
    </property>
    <property>
        <!--  指定 HBase 客户端操作的超时时间,单位为毫秒。默认是1200000 20分钟   这里设置为1小时-->
	    <name>hbase.client.operation.timeout</name>
	    <value>3600000</value>
    </property>
    <property>
        <!--  指定客户端扫描器(scanner)的超时时间,单位为毫秒。单位毫秒 默认60000 60秒  这里设置了1小时  -->
	    <name>hbase.client.scanner.timeout.period</name>
	    <value>3600000</value>
    </property>
    <property>
        <!--  用于指定当协处理程序(Coprocessor)发生错误时,是否挂起该 RegionServer 以防止进一步损坏数据。
                       默认为true 这里设置为false-->
      	<name>hbase.coprocessor.abortonerror</name>
      	<value>false</value>
	</property>
    <property>
        <!--  指定客户端在出现错误时的重试次数  默认值为15-->
        <name>hbase.client.retries.number</name>
        <value>15</value>
    </property>
    <property>
        <!--  HBase 中用于控制客户端扫描大小的配置项。当客户端需要获取大量数据时,可以使用扫描操作来逐个读取数据。
                      默认值是2147483647 注意这个值不能大于hbase.client.scanner.timeout.period的值 以免超时 -->
        <name>hbase.client.scanner.caching</name>
        <value>1000</value>
    </property>
    <property>
        <!-- 配置HBase客户端应用程序的远程调用超时时间,单位为毫秒 默认60000 60秒  这里设置了1小时 -->
	    <name>hbase.rpc.timeout</name>
	    <value>3600000</value>
    </property>
    <property>
        <!-- namespace系统表assign超时时间,单位毫秒 默认300000 5分钟  这里设置2个小时-->
        <name>hbase.master.namespace.init.timeout</name>
        <value>7200000</value>
    </property>
    <!-- master初始化超时时间,默认900000-->
    <property>
        <!-- master初始化超时时间,默认900000 单位毫秒 15分钟  这里设置2个小时-->
        <name>hbase.master.initializationmonitor.timeout</name>
        <value>7200000</value>
    </property>
    <property>
        <!--配置HBase的Write-Ahead Log(WAL)提供程序。不设置为filesystem 启动可能会报错-->
        <name>hbase.wal.provider</name>
        <value>filesystem</value> <!--也可以用multiwal、asyncfs-->
    </property>
    <property>
        <!--用于配置HBase区域服务器(RegionServer)同时打开区域(Region)的线程数。
                     默认情况下,该属性的值为3,即允许同时打开3个区域的线程。-->
        <name>hbase.regionserver.executor.openregion.threads</name>
        <value>200</value>
    </property>
</configuration>

配置regionservers

1
2
3
4
5
vim  regionservers
#写入slave节点(RegionServer服务)的主机名或者IP 推荐主机名
172.16.77.203
172.16.77.204
172.16.77.205

配置Backup Master

备用(Backup) Master可以在主master节点发生故障或不可用时接管主master的职责,确保集群的持续可用性。主要作用:高可用性、故障转移、自动恢复、负载均衡

1
2
3
4
5
6
7
8
9
##配置Backup Master
###在conf目录创建backup-masters 写入对应主机名或IP 可以写入多个
cd $HBASE_HOME/conf

vim backup-masters
#写入以下内容,这里将所有从节点都写进去了
172.16.77.203
172.16.77.204
172.16.77.205

jar包冲突问题

启动时可能会有以下类似提示:

1
2
3
4
5
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/software/hadoop-3.3.4/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/software/hbase-2.4.17/lib/client-facing-thirdparty/slf4j-reload4j-1.7.33.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Reload4jLoggerFactory]

解决方案一

去除HBase中包,使用Hadoop的

1
mv /home/hadoop/software/hbase-2.4.17/lib/client-facing-thirdparty/slf4j-reload4j-1.7.33.jar  /home/hadoop/software/hbase-2.4.17/lib/client-facing-thirdparty/slf4j-reload4j-1.7.33.jar.bak

解决方案二

去除Hadoop的库,使用HBase的库

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
vim hbase-env.sh
......
# Tell HBase whether it should include Hadoop's lib when start up,
# the default value is false,means that includes Hadoop's lib.
#去除下这行的注释
export HBASE_DISABLE_HADOOP_CLASSPATH_LOOKUP="true"

##环境变量解释:用于配置HBase在启动时是否包含Hadoop的库。默认值为false,表示包含Hadoop的库。
##默认情况下,HBase会自动查找Hadoop的类路径,并将其包含在HBase的类路径中。这样做是为了确保
##HBase能够与Hadoop集成并使用Hadoop的功能。然而,有时候您可能希望禁用这种自动查找,特别是当您想
##要使用自定义的Hadoop库或避免与已有的Hadoop库版本冲突时。
##通过设置为"true",告诉HBase不要自动查找Hadoop的类路径。这样,HBase将仅使用自身的类路径,而不包含Hadoop的库。

分发目录

将hbase安装目录拷贝到各个节点上

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#将hbase安装目录分配至hadoop用户
chown -R hadoop:hadoop /home/hadoop/software/

#切换到hadoop用户
su - hadoop

#查看路径
pwd
/home/hadoop

#传输hbase
scp -r software/hbase-2.4.17/ hadoop@172.16.77.203:/home/hadoop/software/
scp -r software/hbase-2.4.17/ hadoop@172.16.77.204:/home/hadoop/software/
scp -r software/hbase-2.4.17/ hadoop@172.16.77.205:/home/hadoop/software/

#传输bashrc
scp ~/.bashrc hadoop@172.16.77.203:~/.bashrc
scp ~/.bashrc hadoop@172.16.77.204:~/.bashrc
scp ~/.bashrc hadoop@172.16.77.205:~/.bashrc

启动HBase

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
###一次性启动HBase
###会在202上启动HMaster
###会在203-205上启动HRegionServer  HMaster(备)
start-hbase.sh

#启动ThriftServer
hbase-daemon.sh start thrift


###单个组件启动 最好按下面顺序来启动#####
#在每个服务器上去启动对应的组件
#--------202-----------------
#启动HMaster 占用端口16000、16010   web ui端口为16010
hbase-daemon.sh start master 
#启动ThriftServer  占用端口9090
hbase-daemon.sh start thrift


#--------203-205----------------
#启动备HMaster 占用端口16000、16010   web ui端口为16010
hbase-daemon.sh start master 
#启动HRegionServer  占用端口16020、16030  web ui端口为16030
hbase-daemon.sh start regionserver

#启动ThriftServer  占用端口9090
#保证可用性 如果主节点宕机了 在从节点上也可以连接
hbase-daemon.sh start thrift


#####-----------------对应关闭--------------###
stop-hbase.sh

hbase-daemon.sh stop master
hbase-daemon.sh stop thrift

hbase-daemon.sh stop master
hbase-daemon.sh stop regionserver
Buy me a coffee
支付宝
微信
0%