HBase 搭建

系统环境

操作系统:  CentOS 7
主机名:    centos02
IP:       192.168.122.1
Java:     1.8
Hadoop:   2.8.5
Zookeeper:3.4.12
HBase:    2.1.6

 

新建Hive目录

[root@centos02 opt]# mkdir -m 777 /opt/bigdata/hbase

 

解压HBase到指定目录

[root@centos02 opt]# tar -xvzf hbase-2.1.6-bin.tar.gz -C /opt/bigdata/hbase

 

修改解压的hbase文件夹的权限

[root@centos02 opt]# cd /opt/bigdata/hbase
[root@centos02 hbase]# chown -R 777 /opt/bigdata/hbase/hbase-2.1.6

 

新建保存数据和日志文件的目录

[root@centos02 hbase]# cd ./hbase-2.1.6
[root@centos02 hbase-2.1.6]# mkdir -m 777 tmp
[root@centos02 hbase-2.1.6]# mkdir -m 777 pids
[root@centos02 hbase-2.1.6]# mkdir -m 777 logs

 

添加环境变量

[root@centos02 hbase-2.1.6]# vim /etc/profile
#HBase
export HBASE_HOME=/opt/bigdata/hbase/hbase-2.1.6
export PATH=$PATH:$HBASE_HOME/bin
[root@centos02 hbase-2.1.6]# source /etc/profile

 

修改 HBase运行环境配置

[root@centos02 hbase-2.1.6]# cd $HBASE_HOME/conf
[root@centos02 conf]# ll
总用量 40
-rw-r--r-- 1 777 centos02 1811 7月   6 2018 hadoop-metrics2-hbase.properties
-rw-r--r-- 1 777 centos02 4284 8月   6 15:59 hbase-env.cmd
-rw-r--r-- 1 777 centos02 7351 2月   7 2019 hbase-env.sh
-rw-r--r-- 1 777 centos02 2257 7月   6 2018 hbase-policy.xml
-rw-r--r-- 1 777 centos02  934 7月   6 2018 hbase-site.xml
-rw-r--r-- 1 777 centos02 4977 7月   6 2018 log4j.properties
-rw-r--r-- 1 777 centos02   10 7月   6 2018 regionservers
[root@centos02 conf]# 

 

修改 hbase-env.sh

[root@centos02 conf]# vim hbase-env.sh
export JAVA_HOME=/usr/local/java/jdk1.8
export HADOOP_HOME=/opt/bigdata/hadoop/hadoop-2.8.5

export HBASE_HOME=/opt/bigdata/hbase/hbase-2.1.6
export HBASE_CLASSPATH=$HADOOP_HOME/etc/hadoop

export HBASE_LOG_DIR=$HBASE_HOME/logs
export HBASE_PID_DIR=$HBASE_HOME/pids
export HBASE_MANAGES_ZK=false
#不启用HBase自带的Zookeeper集群

 

修改hbase-site.xml

[root@centos02 conf]# vim hbase-site.xml
<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>hdfs://centos02:9000/hbase</value>
    <description>存储目录</description>
  </property>

  <property>
    <name>hbase.tmp.dir</name>
    <value>/opt/bigdata/hbase/hbase-2.1.6/tmp</value>
  </property>

  <property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
    <description> false:单机模式  true :分布式模式 </description>
  </property>

  <property>
    <name>dfs.replication</name>
    <value>1</value>
    <description>冗余度</description>
  </property>

  <property>
    <name>hbase.master.port</name>
    <value>16000</value>
    <description>HMaster的rpc端口</description>
  </property>

  <property>
    <name>hbase.master.info.port</name>
    <value>16010</value>
    <description>HMaster的http端口</description>
  </property>


  <!--Zookeeper 集群配置-->
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>centos02</value>
    <description>ZK主机地址</description>
  </property>

  <property>
    <name>hbase.zookeeper.property.clientPort</name>
    <value>2181</value>
    <description>ZK端口</description>
  </property>

  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/opt/bigdata/zookeeper/zookeeper-3.4.12/zkdata</value>
    <description>ZK数据目录,跟zoo.cfg的dataDir一致</description>
  </property>

</configuration>

 

替换 jline-x.x.x.jar

[root@centos02 conf]# cd $HBASE_HOME/lib/zkcli
[root@centos02 zkcli]# ll
总用量 300
-rw-rw-r-- 1  777 centos02  87325 8月  26 19:19 jline-0.9.94.jar
[root@centos02 zkcli]#
[root@centos02 zkcli]# mv jline-0.9.94.jar jline-0.9.94.jar.bak
[root@centos02 zkcli]# cp $HIVE_HOME/lib/jline-2.12.jar $HBASE_HOME/lib/zkcli

替换zookeeper-x.x.x.jar

[root@centos02 zkcli]# cd $HBASE_HOME/lib
[root@centos02 lib]# mv zookeeper-3.4.10.jar zookeeper-3.4.10.jar.bak
[root@centos02 lib]# cp $ZOOKEEPER_HOME/zookeeper-3.4.12.jar $HBASE_HOME/lib
[root@centos02 lib]#

 

把Hive安装目录的hive-hbase-handler包复制到HBase安装目录的lib目录下

[root@centos02 lib]# cp $HIVE_HOME/lib/hive-hbase-handler-*.jar $HBASE_HOME/lib

 

先启动 Hadoop,然后启动 Zookeeper,最后启动 HBase 

[root@centos02 centos02]# cd $HADOOP_HOME/sbin
[root@centos02 sbin]# start-all.sh
[root@centos02 sbin]# cd $ZOOKEEPER_HOME/bin
[root@centos02 bin]# zkServer.sh start

HBase启动

[root@centos02 bin]# cd $HBASE_HOME/bin
[root@centos02 bin]# start-hbase.sh
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/bigdata/hadoop/hadoop-2.8.5/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/bigdata/hive/hive-2.3.4/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/bigdata/hbase/hbase-2.1.6/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]
running master, logging to /opt/bigdata/hbase/hbase-2.1.6/logs/hbase-root-master-centos02.out
: running regionserver, logging to /opt/bigdata/hbase/hbase-2.1.6/logs/hbase-root-regionserver-centos02.out
[root@centos02 bin]# 
[root@centos02 bin]# jps
3264 NameNode
3825 ResourceManager
5169 Jps
4567 HMaster
4682 HRegionServer
3643 SecondaryNameNode
3947 NodeManager
3405 DataNode
4366 QuorumPeerMain
[root@centos02 bin]# 

 

进入HBase

[root@centos02 bin]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/bigdata/hadoop/hadoop-2.8.5/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/bigdata/hive/hive-2.3.4/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/bigdata/hbase/hbase-2.1.6/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.6, rba26a3e1fd5bda8a84f99111d9471f62bb29ed1d, Mon Aug 26 20:40:38 CST 2019
Took 0.0044 seconds                                                                                                                                 
hbase(main):001:0> 
hbase(main):002:0> version
2.1.6, rba26a3e1fd5bda8a84f99111d9471f62bb29ed1d, Mon Aug 26 20:40:38 CST 2019
Took 0.0003 seconds                                                                                                                                 
hbase(main):003:0> 

 

在浏览器输入:http://centos02:16010/

 

posted @ 2019-09-08 08:10  茗::流  阅读(166)  评论(0编辑  收藏  举报
如有雷同,纯属参考。如有侵犯你的版权,请联系我。