1、下载对应版本的Hbase,在我们搭建的集群环境中选用的是hbase-1.4.6
将下载完成的hbase压缩包放到对应的目录下,此处我们的目录为/opt/workspace/
2、对已经有的压缩包进行解压缩
[root@master1 workspace]#tar -zxvf hbase-1.4.6-bin.tar.gz
3、为了方便可以将文件重命名,此处我们不需要重命名
4、修改配置文件、/etc/profile,添加下面代码
# HBase Config
export HBASE_HOME=/opt/workspace/hbase-1.4.6
export PATH=.:${JAVA_HOME}/bin:${SCALA_HOME}/bin:$HADOOP_HOME/sbin:$HADOOP_HOME/bin:${HIVE_HOME}/bin:${SPARK_HOME}/bin:${HBASE_HOME}/bin:${ZK_HOME}/bin:$PATH
[root@master1 workspace]# source /etc/profile
5、修改配置文件hbase-env.sh,在文件中添加如下,其中HBASE_MANAGES_ZK=false 是不启用HBase自带的Zookeeper集群。
export JAVA_HOME=/opt/workspace/jdk1.8
export HADOOP_HOME=/opt/workspace/hadoop-2.9.1
export HBASE_HOME=/opt/workspace/hbase-1.4.6
export HBASE_CLASSPATH=$HADOOP_HOME/etc/hadoop
export HBASE_PID_DIR=/root/hbase/pids
export HBASE_MANAGES_ZK=false
export HBASE_LOG_DIR=${HBASE_HOME}/logs
6、修改配置文件hbase-site.xml,配置如下:
<?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>
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop-test/hbase</value>
<description>The directory shared byregion servers.</description>
</property>
<!--port of hbase-->
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
<!--timeout time-->
<property>
<name>zookeeper.session.timeout</name>
<value>120000</value>
</property>
<!--pretend errors caused by time don't synchronize in servers-->
<property>
<name>hbase.master.maxclockskew</name>
<value>150000</value>
</property>
<!--cluser host-->
<property>
<name>hbase.zookeeper.quorum</name>
<value>master1,master2,slave1,slave2,slave3</value>
</property>
<!--path of tmp-->
<property>
<name>hbase.tmp.dir</name>
<value>/opt/hbase_tmp/tmp</value>
</property>
<!-- true means of distributed-->
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<!--master-->
<property>
<name>hbase.master</name>
<value>60000</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/opt/workspace/zookeeper/data</value>
</property>
<property>
<name>hbase.regionserver.restart.on.zk.expire</name>
<value>true</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>60010</value>
</property>
<property>
<name>dfs.support.append</name>
<value>true</value>
</property>
</configuration>
其中hbase.rootdir配置的是hdfs地,用来持久化Hbase,ip:port要和hadoop/core-site.xml中的fs.defaultFS保持一致。hbase.cluster.distributed :Hbase的运行模式。false是单机模式,true是分布式模式
7、修改regionservers,指定hbase的主从
slave1
slave2
slave3
8、将该环境配置发送到其余4台服务器
9、启动hbase集群
[root@master1 hbase-1.4.6]# cd bin
[root@master1 bin]# start-hbase.sh
报错如下:
解决:
在hbase-env.sh文件中添加
export HBASE_SSH_OPTS="-p 61333"
重新启动,成功。
[root@master1 hbase-1.4.6]# cd bin
[root@master1 bin]# start-hbase.sh
master1节点进程如下:
slave1、slave2、slave3节点进程如下:
10、启动备用节点的HMaster
[root@master2 hbase-1.4.6]# cd bin
[root@master2 bin]# hbase-daemon.sh start master
启动成功,进程如下: