HBase安装模式有三种:单机模式、分布式(伪分布式和完全分布式)。本教程介绍了HBase的伪分布式模式安装配置的过程,伪分布式模式是把进程运行在一台机器上,但不是同一个JVM(单机模式),分布式模式的安装配置需要依赖于HDFS。
- 基础环境
- 安装配置
[一]、环境说明
- JDK1.6+
- Hadoop 2.2.0
- Mac OS 10.9.2
[二]、安装配置
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的版本的对应关系
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-site.xml
1 2 3 4 5 6 7 8 9 |
<property> <name>hbase.rootdir</name> <!-- 对应于hdfs中配置 micmiu.com --> <value>hdfs://localhost:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> |
4、演示
启动HBase之前确保HDFS已经启动,和单机模式的演示过程基本一致。
4.1、启动HBase:
1 2 3 4 |
$ start-hbase.sh localhost: starting zookeeper, logging to /usr/local/share/hbase/bin/../logs/hbase-micmiu-zookeeper-micmiu-mbp.local.out starting master, logging to /usr/local/share/hbase/logs/hbase-micmiu-master-micmiu-mbp.local.out localhost: starting regionserver, logging to /usr/local/share/hbase/bin/../logs/hbase-micmiu-regionserver-micmiu-mbp.local.out |
启动后打开 http://localhost:60010 主界面,可以查看Master运行状态。
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 |
$ hbase shell 2014-03-10 10:45:17,409 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_pseudo', 'cf' 0 row(s) in 2.2370 seconds => Hbase::Table - test_pseudo hbase(main):002:0> list 'test_pseudo' TABLE test_pseudo 1 row(s) in 0.0590 seconds => ["test_pseudo"] hbase(main):003:0> put 'test_pseudo', 'row1', 'cf:a', 'micmiu.com' 0 row(s) in 0.0940 seconds hbase(main):004:0> put 'test_pseudo', 'row2', 'cf:b', 'sjsky.iteye.com' 0 row(s) in 0.0220 seconds hbase(main):005:0> put 'test_pseudo', 'row3', 'cf:c', 'baby.micmiu.com' 0 row(s) in 0.0220 seconds hbase(main):006:0> scan 'test_pseudo' ROW COLUMN+CELL row1 column=cf:a, timestamp=1394420980666, value=micmiu.com row2 column=cf:b, timestamp=1394420985666, value=sjsky.iteye.com row3 column=cf:c, timestamp=1394420990144, value=baby.micmiu.com 3 row(s) in 0.0450 seconds hbase(main):007:0> get 'test_pseudo','row1' COLUMN CELL cf:a timestamp=1394420980666, value=micmiu.com 1 row(s) in 0.0240 seconds hbase(main):008:0> disable 'test_pseudo' 0 row(s) in 15.6070 seconds hbase(main):009:0> drop 'test_pseudo' 0 row(s) in 5.2770 seconds |
4.3、停止HBase:stop-hbase.sh
1 2 3 |
$ stop-hbase.sh stopping hbase.............. localhost: stopping zookeeper. |
到此伪分布式模式的安装配置的介绍结束。
—————– EOF @Michael Sun —————–
原创文章,转载请注明: 转载自micmiu – 软件开发+生活点滴[ http://www.micmiu.com/ ]
本文链接地址: http://www.micmiu.com/bigdata/hbase/hbase-setup-pseudo-distributed/
0 条评论。