1.1 HBase集群部署规划
HBase是一个分布式的、面向列的开源数据库,HBase在Hadoop之上提供了类似于Bigtable的能力。HBase是Apache的Hadoop项目的子项目。HBase不同于一般的关系数据库,它是一个适合于非结构化数据存储的数据库。另一个不同的是HBase基于列的而不是基于行的模式。
注:因此,HBase的安装部署必需建立在Hadoop安装好的前提下,启动HBase集群之前先启动hadoop集群
HBase集群的部署分布如下表所示:
主机名 | 角色 | 进程 | 备注 |
Gn-M01 | 管理节点 | HMaster | HBase是在Hadoop基础的上部署的,根据节点的角色来决定进程的 |
Gn-M02 | 存储节点 | HRegionServer | |
Gn-S01 | 存储节点 | HRegionServer |
注意:
部署思路:选择从Gn-M01开始安装,然后远程复制到Gn-M02、Gn-S01各个节点上
1.2 解压安装包
进入安装目录,命令如下:
cd /opt/software
ls(查看是否有HBase的安装包)
如果有hbase的安装包,则解压hbase安装包,命令如下所示:
tar -zxvf hbase-1.0.0-bin.tar.gz
1.3 配置环境变量
注:在Gn-M01、Gn-M02、Gn-S01上都进行配置环境变量,方便hbase相关服务的启动、停止、状态的查看等操作
进入hbase的解压目录下,命令如下:
cd /opt/software/hbase-1.0.0
pwd
用vi编辑/etc/profile文件,命令如下:
vi /etc/profile
配置的hbase环境变量的内容如下所示:
在/etc/profile文件中增加以下配置
export HBASE_HOME=/opt/software/hbase-1.0.0
exportPATH=$PATH:$HBASE_HOME/bin
修改完成后保存退出(:wq)
修改完成后,让配置的环境变量生效,命令如下所示:
source /etc/profile
1.4 修改配置文件
进入hbase的配置目录:
cd /opt/software/hbase-1.0.0/conf
1.4.1 hbase-site.xml
用vi编辑/opt/software/hbase-1.0.0/conf/目录下的core-site.xml文件,命令如下所示:
vi hbase-site.xml
添加内容如下所示(红色字体是主要添加的内容):
<?xmlversion="1.0"?>
<?xml-stylesheettype="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 underthe Apache License, Version 2.0
(the * "License"); you may notuse this file except in compliance * with
the License. You may obtain a copy of theLicense at * * http://www.apache.org/licenses/LICENSE-2.0
* * Unless required by applicable law oragreed to in writing, software *
distributed under the License isdistributed on an "AS IS" BASIS, * WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied. * See the
License for the specific languagegoverning permissions and * limitations
under the License. */ -->
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://green/hbase</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>/opt/software/hbase-1.0.0/tmp</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>Gn-M01,Gn-M02,Gn-S01</value>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>30000</value>
</property>
<property>
<name>hbase.regionserver.handler.count</name>
<value>100</value>
</property>
<property>
<name>hbase.hregion.max.filesize</name>
<value>107374182400</value>
</property>
</configuration>
1.4.2 hbase-env.sh
用vi编辑/opt/software/hbase-1.0.0/conf/目录下的hbase-env.sh文件,命令如下所示:
vi hbase-site.xml
添加内容如下所示(红色字体是主要添加的内容):
exportJAVA_HOME=/opt/software/jdk1.7.0_71
修改内容如下所示(红色字体是主要修改的内容):
export HBASE_MANAGES_ZK=false
修改HBASE_MANAGES_ZK的值,默认为true。即使用内部的Zookeeper.这里我们使用外部自己配置的Zookeeper,因此为false.
外部的Zookeeper参考本文档的Zookeeper的部署。
配置完成后给/opt/software/hbase-1.0.0/conf目录下的.sh结尾的文件增加可执行权限,命令如下所示:
chmod +x *.sh
1.4.3 regionservers
用vi编辑/opt/software/hbase-1.0.0/conf/目录下的regionservers文件,命令如下所示:
vi regionservers
regionservers文件中的内容决定Hregionserver进程的所在,regionservers文件中配置的内容是数据节点的主机名。
添加内容如下所示(红色字体是主要添加的内容):
Gn-M02
Gn-S01
1.5 部署到其他节点
将Gn-M01上的/opt/software/hbase-1.0.0目录分别远程复制到Gn-M02、Gn-S01的/opt/softwate目录下,命令如下所示:
scp -r /opt/software/hbase-1.0.0 root@Gn-M02:/opt/software/
scp -r /opt/software/hbase-1.0.0 root@Gn-S02:/opt/software/
Gn-M02上查看/opt/software目录下的hbase-1.0.0,如下图所示:
说明Gn-M01远程复制到Gn-M02成功
Gn-S01上查看/opt/software目录下的hbase-1.0.0,如下图所示:
说明Gn-S01远程复制到Gn-M02成功
1.6 启动及验证
1.6.1 启动Hbase
HBase启动命令如下:
start-hbase.sh (或者/opt/software/hbase-1.0.0/bin/start-hbase.sh)
启动验证
(1)查看进程
(1) 进入Hbase客户端
hbase shell (或者/opt/software/hbase-1.0.0/bin/hbase shell)
(3)查看HDFS上的hbase目录:
hdfs dfs –ls /
(4)查看浏览器
http://ip:16030
1.6.2 停止Hbase
HBase停止命令如下所示:
stop-hbase.sh (或者/opt/software/hbase-1.0.0/bin/stop-hbase.sh)