环境:CentOS6.5 Hadoop1.2.1 HBase0.98.11
1.安装好 hadoop 集群,并启动
[grid@hadoop1 ~]$ sh $HADOOP_PREFIX/bin/start-all.sh
查看 hadoop 版本:
[grid@hadoop1 ~]$ hadoop version
Hadoop 1.2.1
Subversion https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.2 -r 1503152
Compiled by mattf on Mon Jul 22 15:23:09 PDT 2013
From source with checksum 6923c86528809c4e7e6f493b6b413a9a
This command was run using /home/grid/hadoop-1.2.1/hadoop-core-1.2.1.jar
2.查看 hbase 官方文档(http://hbase.apache.org/book.html#basic.prerequisites),找到与 hadoop 版本对应的 hbase 并下载
[grid@hadoop1 ~]$ wget http://mirrors.cnnic.cn/apache/hbase/hbase-0.98.11/hbase-0.98.11-hadoop1-bin.tar.gz
3.解压
[grid@hadoop1 ~]$ tar -zxf hbase-0.98.11-hadoop1-bin.tar.gz
4.进入 hbase 的 lib 目录,查看 hadoop-core-*.jar 的版本
[grid@hadoop1 ~]$ cd hbase-0.98.11-hadoop1/lib/
[grid@hadoop1 lib]$ find -name 'hadoop-core-*jar'
./hadoop-core-1.2.1.jar
正好与 hadoop 集群的版本号一致,不用替换 jar 包;否则需要用 hadoop 目录下的 hadoop-core-*.jar 替换 hbase/lib 目录下的 hadoop-core-*.jar 文件
5.修改配置文件
5.1.
[grid@hadoop1 hbase-0.98.11-hadoop1]$ vi conf/hbase-env.sh
export
JAVA_HOME=/usr/java/jdk1.7.0_72
export
HBASE_CLASSPATH=/home/grid/hadoop-1.2.1/conf
export
HBASE_MANAGES_ZK=true
第一个参数指定了JDK路径;第二个参数指定了 hadoop 的配置文件路径;第三个参数设置使用 hbase 默认自带的 Zookeeper
5.2.
[grid@hadoop1 hbase-0.98.11-hadoop1]$ vi conf/hbase-site.xml
<!-- hbase.rootdir:存放数据目录 -->
<property>
<name>
hbase.rootdir</name>
<value>hdfs://hadoop1:9000/hbase</value>
</property>
<!-- 打开分布模式 -->
<property>
<name>
hbase.cluster.distributed</name>
<value>true</value>
</property>
<!-- 设置临时文件目录 -->
<property>
<name>
hbase.tmp.dir</name>
<value>/home/grid/hbase-0.98.11-hadoop1/tmp</value>
</property>
<!-- 添加 Zookeeper 的节点主机名 -->
<property>
<name>
hbase.zookeeper.quorum</name>
<value>hadoop1,hadoop2,hadoop3</value>
</property>
<!-- 设置 Zookeeper 文件目录 -->
<property>
<name>
hbase.zookeeper.property.dataDir</name>
<value>/home/grid/hbase-0.98.11-hadoop1/zookeeper</value>
</property>
创建目录
[grid@hadoop1 hbase-0.98.11-hadoop1]$ mkdir tmp
[grid@hadoop1 hbase-0.98.11-hadoop1]$ mkdir zookeeper
5.3.
[grid@hadoop1 hbase-0.98.11-hadoop1]$ vi conf/regionservers
hadoop1
hadoop2
hadoop3
6.设置环境变量
[grid@hadoop1 ~]$ vi .bash_profile
export HBASE_HOME=/home/grid/hbase-0.98.11-hadoop1
export PATH=$PATH:$HBASE_HOME/bin
[grid@hadoop1 ~]$ source .bash_profile
7.分发 hbase 到其它机器,并在其上设置环境变量
[grid@hadoop1 ~]$ scp -r hbase-0.98.11-hadoop1 grid@hadoop2:~
[grid@hadoop1 ~]$ scp -r hbase-0.98.11-hadoop1 grid@hadoop3:~
8.启动 hbase
[grid@hadoop1 ~]$ sh start-hbase.sh
[grid@hadoop1 ~]$ jps
2017 NameNode
3597 Jps
3196 HMaster
2164 SecondaryNameNode
3315 HRegionServer
2246 JobTracker
3139 HQuorumPeer
[grid@hadoop2 ~]$ jps
2268 TaskTracker
2673 HQuorumPeer
2747 HRegionServer
2917 Jps
2199 DataNode
[grid@hadoop3 ~]$ jps
2475 HQuorumPeer
2732 Jps
2071 TaskTracker
2004 DataNode
2549 HRegionServer
9.shell
10.Web管理界面