签到成功

知道了

CNDBA社区CNDBA社区

Hbase 2.1.3 集群搭建手册

2019-03-05 17:17 4633 0 原创 HBase
作者: dave

在上篇我们了解了HBase 架构相关的内容,如下:
HBase 系统架构详解
https://www.cndba.cn/dave/article/3315

本篇了解一下HBase集群环境的搭建。

1 Hadoop 集群和ZooKeeper集群搭建

因为HBase依赖与HDFS和Zookeeper环境,所有在搭建HBase集群之前需要先安装这2个环境,这里不在说明,具体操作参考之前的博客。

Linux 7.6 平台 Hadoop 3.1.1 集群搭建手册
https://www.cndba.cn/download/dave/6

Zookeeper 集群安装配置
https://www.cndba.cn/dave/article/3295

测试环境中是3节点的Hadoop集群和ZooKeeper集群。

[dave@www.cndba.cn data]$ cat /etc/hosts
127.0.0.1   localhost
192.168.56.100 Master
192.168.56.101 Slave1
192.168.56.102 Slave2
[dave@www.cndba.cn data]$

[dave@www.cndba.cn data]$ yarn node --list
WARNING: YARN_CONF_DIR has been replaced by HADOOP_CONF_DIR. Using value of YARN_CONF_DIR.
2019-03-03 22:18:34,585 INFO client.RMProxy: Connecting to ResourceManager at Master/192.168.56.100:8032
Total Nodes:2
         Node-Id         Node-State    Node-Http-Address    Number-of-Running-Containers
    Slave1:37588            RUNNING          Slave1:8042                               0
    Slave2:38693            RUNNING          Slave2:8042                               0
[dave@www.cndba.cn data]$ jps
28672 SecondaryNameNode
19793 Jps
4745 QuorumPeerMain
28442 NameNode
28895 ResourceManager
[dave@www.cndba.cn data]$

2 搭建HBase集群

注意事项:HBase 集群对于时间的同步要求的比 HDFS 严格,所以,集群启动之前千万记住要进行时间同步,时间时间同步的配置这里不在描述。

http://www.cndba.cn/cndba/dave/article/3322

2.1 下载软件包

直接从apache上下载:

http://www.cndba.cn/cndba/dave/article/3322

http://hbase.apache.org/downloads.html
http://mirror.bit.edu.cn/apache/hbase/2.1.3/hbase-2.1.3-bin.tar.gz

2.2 解压缩文件

[dave@www.cndba.cn ~]$ pwd
/home/hadoop
[dave@www.cndba.cn ~]$ ls hbase-2.1.3-bin.tar.gz 
hbase-2.1.3-bin.tar.gz
[dave@www.cndba.cn ~]$ tar xzvf hbase-2.1.3-bin.tar.gz
[dave@www.cndba.cn ~]$ ls
current_dept_emp.java      dept_manager.java    hbase-2.1.3                           zookeeper
departments.java           employees.java       hbase-2.1.3-bin.tar.gz                zookeeper-3.4.13.tar.gz
dept_emp.java              hadoop               sqoop                                 zookeeper.out
dept_emp_latest_date.java  hadoop-3.2.0.tar.gz  sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz
[dave@www.cndba.cn ~]$ mv hbase-2.1.3 hbase
[dave@www.cndba.cn ~]$ ls
current_dept_emp.java      dept_manager.java    hbase                                 zookeeper
departments.java           employees.java       hbase-2.1.3-bin.tar.gz                zookeeper-3.4.13.tar.gz
dept_emp.java              hadoop               sqoop                                 zookeeper.out
dept_emp_latest_date.java  hadoop-3.2.0.tar.gz  sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz
[dave@www.cndba.cn ~]$

2.3 添加环境变量

修改/etc/profile 文件,添加如下内容:

#HBase
export HBASE_HOME=/home/hadoop/hbase
export PATH=$PATH:$HBASE_HOME/bin

source /etc/profie  #刷新配置文件

2.4 修改HBase 配置文件

2.4.1 修改hbase-env.sh 文件

修改hbase的环境配置文件hbase-env.sh, 添加如下内容:http://www.cndba.cn/cndba/dave/article/3322

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64  
#关闭HBase自带的Zookeeper,使用Zookeeper集群
export HBASE_MANAGES_ZK=false  

[dave@www.cndba.cn conf]$ pwd
/home/hadoop/hbase/conf
[dave@www.cndba.cn conf]$ ls
hadoop-metrics2-hbase.properties  hbase-env.sh      hbase-site.xml    regionservers
hbase-env.cmd                     hbase-policy.xml  log4j.properties
[dave@www.cndba.cn conf]$

2.4.2 修改hbase-site.xml 文件

添加如下内容:http://www.cndba.cn/cndba/dave/article/3322

<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://Master:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>Master,Slave1,Slave2</value>
</property>
<property>
<name>zookeeper.znode.parent</name>
<value>/hbase</value>
</property>
<property>
<name>hbase.unsafe.stream.capability.enforce</name>
<value>false</value>
</property>
</configuration>

说明如下:http://www.cndba.cn/cndba/dave/article/3322

hbase.rootdir:在HDFS上指定一个目录存放元数据,不需要手工创建,HDFS会自动创建。
hbase.cluster.distributed:是否开启分布式。
hbase.zookeeper.quorum:对应的zookeeper集群,不用加端口。
zookeeper.znode.parent:这里是我们前面修改的主目录名称。

这里要注意配置值前面不能有空格:

HBase zookeeper.RecoverableZooKeeper: Unable to create ZooKeeper Connection 解决方法
https://www.cndba.cn/dave/article/3316

hbase.unsafe.stream.capability.enforce:使用本地文件系统设置为false,使用hdfs设置为true。 在HBase 2.0.0 之后建议设置为false,否则会报如下错误:

HBase Master 启动 check the config value of ‘hbase.procedure.store.wal.use.hsync’ 解决方法
https://www.cndba.cn/dave/article/3321

2.4.3 修改regionservers文件

在regionservers文件中添加对应的节点信息。http://www.cndba.cn/cndba/dave/article/3322

[dave@www.cndba.cn conf]$ ls
hadoop-metrics2-hbase.properties  hbase-env.sh      hbase-site.xml    regionservers
hbase-env.cmd                     hbase-policy.xml  log4j.properties
[dave@www.cndba.cn conf]$ vim regionservers 
[dave@www.cndba.cn conf]$ cat regionservers 
Master
Slave1
Slave2
[dave@www.cndba.cn conf]$

2.4.4 修改backup-masters文件

该文件默认不存在,需要手工添加。http://www.cndba.cn/cndba/dave/article/3322

[dave@www.cndba.cn conf]$ pwd
/home/hadoop/hbase/conf
[dave@www.cndba.cn conf]$ touch backup-masters
[dave@www.cndba.cn conf]$ vi backup-masters 
[dave@www.cndba.cn conf]$ cat backup-masters 
Slave1
[dave@www.cndba.cn conf]$

2.5 整合HDFS和HBase

HBase在HDFS上存储数据,所以将hdfs-site.xml和core-site.xml文件复制到hbase的conf目录下。

[dave@www.cndba.cn conf]$ ls
backup-masters                    hbase-env.cmd  hbase-policy.xml  log4j.properties
hadoop-metrics2-hbase.properties  hbase-env.sh   hbase-site.xml    regionservers
[dave@www.cndba.cn conf]$ pwd
/home/hadoop/hbase/conf
[dave@www.cndba.cn conf]$ cp ~/hadoop/etc/hadoop/hdfs-site.xml .
[dave@www.cndba.cn conf]$ cp ~/hadoop/etc/hadoop/core-site.xml .
[dave@www.cndba.cn conf]$ ls
backup-masters  hadoop-metrics2-hbase.properties  hbase-env.sh      hbase-site.xml  log4j.properties
core-site.xml   hbase-env.cmd                     hbase-policy.xml  hdfs-site.xml   regionservers
[dave@www.cndba.cn conf]$

2.6 复制htrace包

执行如下操作:

cp $HBASE_HOME/lib/client-facing-thirdparty/htrace-core-3.1.0-incubating.jar $HBASE_HOME/lib/

如果不复制该包,在启动HMaster主进程时会异常退出,相关日志如下:

http://www.cndba.cn/cndba/dave/article/3322

HBase HMaster 进程 java.lang.NoClassDefFoundError: org/apache/htrace/SamplerBuilder 解决方法
https://www.cndba.cn/dave/article/3320

2.7 分发Hbase

[dave@www.cndba.cn ~]$ scp -r hbase Slave2:`pwd`
[dave@www.cndba.cn ~]$ scp -r hbase Slave1:`pwd`

2.8 启动HBASE

我们配置的HBase有3个节点,启动hbase时,在哪个节点启动哪个节点就是hmaster。
启动和关闭命令如下:

start-hbase.sh / stop-hbase.sh

在一个节点执行启动命令,会启动集群中所有节点的Hbase,对于hmaster,也可以手工启动:http://www.cndba.cn/cndba/dave/article/3322

hbase-daemon.sh start master
hbase-daemon.sh start regionserver

2.9 Web 访问

http://192.168.56.100:16010/master-status

http://www.cndba.cn/cndba/dave/article/3322

2.10 shell 访问

[cndba@hadoopslave1 ~]$ hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/cndba/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/cndba/hbase/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.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.Log4jLoggerFactory]
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.1.3, rda5ec9e4c06c537213883cca8f3cc9a7c19daf67, Mon Feb 11 15:45:33 CST 2019
Took 0.0038 seconds                                                                                                               
hbase(main):001:0> help
HBase Shell, version 2.1.3, rda5ec9e4c06c537213883cca8f3cc9a7c19daf67, Mon Feb 11 15:45:33 CST 2019
Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command.
Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group.

COMMAND GROUPS:
  Group name: general
  Commands: processlist, status, table_help, version, whoami

  Group name: ddl
  Commands: alter, alter_async, alter_status, clone_table_schema, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, list_regions, locate_region, show_filters

  Group name: namespace
  Commands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables

  Group name: dml
  Commands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2296
    原创
  • 3
    翻译
  • 582
    转载
  • 198
    评论
  • 访问:8506692次
  • 积分:4477
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ