HBase安装模式有三种:单机模式、分布式(伪分布式和完全分布式)。本教程介绍了HBase的完全分布式模式安装配置的过程,分布式模式均需要依赖于HDFS。
- 基础环境
- 安装配置
[一]、环境说明
- JDK1.6+
- Hadoop 2.2.0
- CentOS 6.0
- HBase-0.98.0-hadoop2
Hadoop集群机器对应于HBase用途如下:
hostname | IP | Hadoop用途 | HBase用途 |
Master.Hadoop | 192.168.6.77 | NameNode/ResouceManager | Master |
Slave5.Hadoop | 192.168.8.205 | DataNode/NodeManager | RegionServer |
Slave6.Hadoop | 192.168.8.206 | DataNode/NodeManager | RegionServer |
Slave7.Hadoop | 192.168.8.207 | DataNode/NodeManager | RegionServer |
有关hadoop2的集群安装配置参考:http://www.micmiu.com/bigdata/hadoop/hadoop2x-cluster-setup/
[二]、安装配置
1、下载发布包
到HBase官方下载最新的版本 hbase-0.98.0-hadoop2-bin.tar.gz
(支持hadoop2)为例:
1 2 3 |
$ tar xfz hbase-0.98.0-hadoop2-bin.tar.gz $ cd hbase-0.98.0-hadoop2 $ ln -s hbase-0.98.0-hadoop2 hbase |
注意:由于 HBase 依赖 Hadoop,在分布式模式下,Hadoop版本必须和HBase下的版本一致。用你运行的分布式Hadoop版本jar文件替换HBase lib目录下的Hadoop jar文件,以避免版本不匹配问题,也可以根据情况自己编译发布包。
2、配置系统环境
1 2 3 |
#HBase micmiu.com export HBASE_HOME="/usr/local/share/hbase" export PATH=$HBASE_HOME/bin:$PATH |
3、配置HBase参数
修改配置文件:<HBASE_HOME>/conf/hbase-env.sh
export JAVA_HOME = /usr/lib/jvm/java-1.6.0-openjdk.x86_64
修改配置文件:<HBASE_HOME>/conf/hbase-site.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<property> <name>hbase.rootdir</name> <!-- 和hdfs中配置的fs.defaultFS一致 by micmiu.com--> <value>hdfs://Master.Hadoop:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.zookeeper.quorum</name> <!-- 设置zk集群的主机,建议奇数 by micmiu.com--> <value>Slave5.Hadoop,Slave6.Hadoop,Slave7.Hadoop</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/home/hadoop/data/zookeeper</value> </property> |
修改配置文件:<HBASE_HOME>/conf/regionservers
1 2 3 |
Slave5.Hadoop Slave6.Hadoop Slave7.Hadoop |
注意:在HBase集群的所有机器上(一台Master:Master.Hadoop ,三台RS:Slave5.Hadoop,Slave6.Hadoop,Slave7.Hadoop 共4台设备)都需要执行上面的所有安装配置过程。
4、演示
启动HBase之前确保HDFS已经启动,和单机模式的演示过程基本一致。
4.1、启动HBase:
在Master机器 Master.Hadoop( 192.168.6.77) 上执行启动脚本:
1 2 3 4 5 6 |
[hadoop@Master ~]$ start-hbase.sh Master.Hadoop: starting zookeeper, logging to /usr/local/hbase/bin/../logs/hbase-hadoop-zookeeper-Slave7.Hadoop.out Slave5.Hadoop: starting zookeeper, logging to /usr/local/hbase/bin/../logs/hbase-hadoop-zookeeper-Slave5.Hadoop.out Slave6.Hadoop: starting zookeeper, logging to /usr/local/hbase/bin/../logs/hbase-hadoop-zookeeper-Slave6.Hadoop.out starting master, logging to /usr/local/hbase/logs/hbase-hadoop-master-Master.Hadoop.out localhost: starting regionserver, logging to /usr/local/hbase/bin/../logs/hbase-hadoop-regionserver-Master.Hadoop.out |
- 打开 http://Master.Hadoop(192.168.6.77):60010 主界面,可以查看Master运行状态。
- 打开 http://SlaveX.Hadoop(192.168.8.20x):60030 主界面,可以查看RegionServer运行状态
4.2、shell演示 建表、插入数据、查询数据、删除表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
$ hbase shell 2014-03-10 16:31:46,216 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 0.98.0-hadoop2, r1565492, Thu Feb 6 16:46:57 PST 2014 hbase(main):001:0> create 'test_distributed','cf' SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/hbase-0.98.0-hadoop2/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hadoop-2.2.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 0 row(s) in 1.4320 seconds => Hbase::Table - test_distributed hbase(main):002:0> list TABLE test_distributed 1 row(s) in 0.0390 seconds => ["test_distributed"] hbase(main):003:0> put 'test_distributed','row1','cf:a','micmiu.com' 0 row(s) in 0.0670 seconds hbase(main):004:0> put 'test_distributed','row2','cf:b','sjsky.iteye.com' 0 row(s) in 0.0130 seconds hbase(main):005:0> put 'test_distributed','row3','cf:c','baby.micmiu.com' 0 row(s) in 0.0090 seconds hbase(main):006:0> scan 'test_distributed' ROW COLUMN+CELL row1 column=cf:a, timestamp=1394440732360, value=micmiu.com row2 column=cf:b, timestamp=1394440750501, value=sjsky.iteye.com row3 column=cf:c, timestamp=1394440765951, value=baby.micmiu.com 3 row(s) in 0.0230 seconds hbase(main):007:0> get 'test_distributed','row1' COLUMN CELL cf:a timestamp=1394440732360, value=micmiu.com 1 row(s) in 0.0110 seconds hbase(main):008:0> disable 'test_distributed' 0 row(s) in 1.4540 seconds hbase(main):009:0> drop 'test_distributed' 0 row(s) in 0.2470 seconds hbase(main):010:0> exit |
4.3、停止HBase:stop-hbase.sh
1 2 3 4 5 |
[hadoop@Master ~]$ stop-hbase.sh stopping hbase............... Slave7.Hadoop: stopping zookeeper. Slave5.Hadoop: stopping zookeeper. Slave6.Hadoop: stopping zookeeper. |
到此完全分布式模式的安装配置的介绍结束。
—————– EOF @Michael Sun —————–
原创文章,转载请注明: 转载自micmiu – 软件开发+生活点滴[ http://www.micmiu.com/ ]
本文链接地址: http://www.micmiu.com/bigdata/hbase/hbase-setup-full-distributed/
0 条评论。