1.1 下载
Hbase可以在Hadoop集群的某些机器(一台也可以,例如选择namenode节点来安装)上安装,也可以全部机器上都安装。Hbase是依赖Hadoop和Zookeeper的,所以在安装Hbase之前,请先安装Hadoop和Zookeeper。
在官网 http://mirror.bit.edu.cn/apache/hbase/stable/ 下载 hbase-1.2.5-bin.tar.gz,上传到目录/usr/local/hbase 下
1.2 解压缩
解压并删除安装包
tar hbase-1.2.5-bin.tar.gz
rm -rf hbase-1.2.5-bin.tar.gz
2.1 环境变量配置
vim /etc/profile
添加:
export HBASE_HOME=/usr/local/hbase/hbase-1.2.5
export PATH=$PATH:$HBASE_HOME/bin
source /etc/profile
2.2 conf目录下的配置
cd /usr/local/hbase/hbase-1.2.5/conf/
(1)修改hbase-env.sh文件
vim hbase-env.sh
添加:
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_181
export HADOOP_HOME=/usr/local/hadoop/hadoop-2.8.4
export HBASE_HOME=/usr/local/hbase/hbase-0.98.24-hadoop2
export HBASE_CLASSPATH=/usr/local/hadoop/hadoop-2.8.4/etc/hadoop
export HBASE_PID_DIR=/usr/local/hbase/hbase-0.98.24-hadoop2/pids
export HBASE_MANAGES_ZK=false
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_181
export HADOOP_HOME=/usr/local/hadoop/hadoop-2.8.5
export HBASE_HOME=/usr/local/hbase/hbase-1.2.5
export HBASE_CLASSPATH=/usr/local/hadoop/hadoop-2.8.5/etc/hadoop
export HBASE_PID_DIR=/usr/local/hbase/hbase-1.2.5/pids
export HBASE_MANAGES_ZK=false
(2)修改配置文件hbase-site.xml
vim hbase-site.xml
<configuration>
<property>
<name>hbase.rootdirname>
<value>hdfs://master:9000/hbasevalue>
<description>The directory shared byregion servers.description>
property>
<property>
<name>hbase.zookeeper.property.clientPortname>
<value>2181value>
<description>Property from ZooKeeper'sconfig zoo.cfg. The port at which the clients will connect.
description>
property>
<property>
<name>zookeeper.session.timeoutname>
<value>120000value>
property>
<property>
<name>hbase.zookeeper.quorumname>
<value>master,slaver1,slaver2,slaver3,slaver4,slaver5value>
property>
<property>
<name>hbase.tmp.dirname>
<value>/usr/local/hbase/hbase-1.2.5/tmpvalue>
property>
<property>
<name>hbase.cluster.distributedname>
<value>truevalue>
property>
<property>
<name>hbase.master.info.portname>
<value>60010value>
property>
configuration>
(3)修改regionservers文件
vim regionservers
添加:
master
slaver1
slaver2
slaver3
slaver4
slaver5
3.1 启动
Hbase是基于hadoop提供的分布式文件系统的,所以启动Hbase之前,先确保hadoop在正常运行,另外Hbase还依赖于zookkeeper,本来我们可以用hbase自带的zookeeper,但是我们上面的配置启用的是我们自己的zookeeper集群,所以在启动hbase前,还要确保zokeeper已经正常运行。
cd /usr/local/hbase/hbase-1.2.5/bin/
./start-hbase.sh
查看master的进程:
3.2 测试
(1)用浏览器访问Hbase状态信息
访问地址 http://192.168.144.130:60010
(2)启动hbase的命令行
执行命令,进入到Hbase的bin目录内,命令是:
cd /usr/local/hbase/hbase-1.2.5/bin/
执行命令启动Hbase命令行窗口,命令是:
./hbase shell
出现:
[root@master bin]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/hbase-1.2.5/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/hadoop-2.8.5/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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; enter 'help' for list of supported commands.
Type "exit" to leave the HBase Shell
Version 1.2.5, rd7b05f79dee10e0ada614765bb354b93d615a157, Wed Mar 1 00:34:48 CST 2017
hbase(main):001:0>
status