搭建hbase
hbase的部署依赖zookeeper、hdfs
上传hbase安装包
hbase-2.1.0.tar.gz
修改HBase配置文件
hbase-env.sh
cd /export/software/hbase/conf
vim hbase-env.sh
# 第28行添加如下信息
export JAVA_HOME=/export/software/jdk/
export HBASE_MANAGES_ZK=false
hbase-site.xml
<configuration>
<!-- HBase数据在HDFS中的存放的路径 -->
<property>
<name>hbase.rootdir</name>
<value>hdfs://n1:9000/hbase</value>
</property>
<!-- Hbase的运行模式。false是单机模式,true是分布式模式。若为false,Hbase和Zookeeper会运行在同一个JVM里面 -->
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<!-- ZooKeeper的地址 -->
<property>
<name>hbase.zookeeper.quorum</name>
<value>n1,n2,n3</value>
</property>
<!-- ZooKeeper快照的存储位置 -->
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/export/software/zookeeper/data</value>
</property>
<!-- V2.1版本,在分布式情况下, 设置为false -->
<property>
<name>hbase.unsafe.stream.capability.enforce</name>
<value>false</value>
</property>
</configuration>
添加hbase环境变量
vim /etc/profile.d/hbase.sh
export HBASE_HOME=/export/software/hbase
export PATH=$PATH:$HBASE_HOME/bin
source /etc/profile
复制jar包到lib
cp $HBASE_HOME/lib/client-facing-thirdparty/htrace-core-3.1.0-incubating.jar $HBASE_HOME/lib/
修改regionservers文件
vim regionservers
添加各机器hostname:
n1
n2
n3
分发安装包与配置文件
scp -r /export/software/hbase n2:/export/software/
scp -r /export/software/hbase n3:/export/software/
scp /etc/profile.d/hbase.sh n2:/etc/profile.d/hbase.sh
scp /etc/profile.d/hbase.sh n3:/etc/profile.d/hbase.sh
在n2和n3加载环境变量:
source /etc/profile
启动HBase
启动hbase时先启动zookeeper和hdfs
start-hbase.sh
验证Hbase是否启动成功
root@n1 conf]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/export/software/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/export/software/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.
Version 2.1.0, re1673bb0bbfea21d6e5dba73e013b09b8b49b89b, Tue Jul 10 17:26:48 CST 2018
Took 0.0040 seconds
hbase(main):001:0> status
1 active master, 0 backup masters, 3 servers, 0 dead, 0.6667 average load
Took 0.4161 seconds