本文共 2832 字,大约阅读时间需要 9 分钟。
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 | $ tar xfz hbase-0.98.0-hadoop2-bin. tar .gz |
2 | $ cd hbase-0.98.0-hadoop2 |
3 | $ ln -s hbase-0.98.0-hadoop2 hbase |
注意:HBase的版本和Hadoop的版本的对应关系
2、配置系统环境
2 | export HBASE_HOME= "/usr/local/share/hbase" |
3 | export PATH=$HBASE_HOME/bin:$PATH |
3、配置HBase参数
修改配置文件:<HBASE_HOME>/conf/hbase-site.xml
2 | < name >hbase.rootdir</ name > |
7 | < name >hbase.cluster.distributed</ name > |
4、演示
启动HBase之前确保HDFS已经启动,和单机模式的演示过程基本一致。
4.1、启动HBase:
2 | localhost: starting zookeeper, logging to /usr/ local /share/hbase/bin/../logs/hbase-micmiu-zookeeper-micmiu-mbp. local .out |
3 | starting master, logging to /usr/ local /share/hbase/logs/hbase-micmiu-master-micmiu-mbp. local .out |
4 | 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演示 建表、插入数据、查询数据、删除表
2 | 2014-03-10 10:45:17,409 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available |
3 | HBase Shell; enter 'help<RETURN>' for list of supported commands. |
4 | Type "exit<RETURN>" to leave the HBase Shell |
5 | Version 0.98.0-hadoop2, r1565492, Thu Feb 6 16:46:57 PST 2014 |
7 | hbase(main):001:0> create 'test_pseudo' , 'cf' |
8 | 0 row(s) in 2.2370 seconds |
10 | => Hbase::Table - test_pseudo |
11 | hbase(main):002:0> list 'test_pseudo' |
14 | 1 row(s) in 0.0590 seconds |
17 | hbase(main):003:0> put 'test_pseudo' , 'row1' , 'cf:a' , 'micmiu.com' |
18 | 0 row(s) in 0.0940 seconds |
20 | hbase(main):004:0> put 'test_pseudo' , 'row2' , 'cf:b' , 'sjsky.iteye.com' |
21 | 0 row(s) in 0.0220 seconds |
23 | hbase(main):005:0> put 'test_pseudo' , 'row3' , 'cf:c' , 'baby.micmiu.com' |
24 | 0 row(s) in 0.0220 seconds |
26 | hbase(main):006:0> scan 'test_pseudo' |
28 | row1 column=cf:a, timestamp=1394420980666, value=micmiu.com |
29 | row2 column=cf:b, timestamp=1394420985666, value=sjsky.iteye.com |
30 | row3 column=cf:c, timestamp=1394420990144, value=baby.micmiu.com |
31 | 3 row(s) in 0.0450 seconds |
33 | hbase(main):007:0> get 'test_pseudo' , 'row1' |
35 | cf:a timestamp=1394420980666, value=micmiu.com |
36 | 1 row(s) in 0.0240 seconds |
38 | hbase(main):008:0> disable 'test_pseudo' |
39 | 0 row(s) in 15.6070 seconds |
41 | hbase(main):009:0> drop 'test_pseudo' |
42 | 0 row(s) in 5.2770 seconds |
4.3、停止HBase:stop-hbase.sh
2 | stopping hbase.............. |
3 | localhost: stopping zookeeper. |
到此伪分布式模式的安装配置的介绍结束。
转载地址:http://dnvwn.baihongyu.com/