《Hadoop The Definitive Guide》ch12 HBase

来源:互联网 发布:jsp后台管理系统源码 编辑:程序博客网 时间:2024/05/21 20:09

1. 关于HBase的介绍,http://www.searchtb.com/2011/01/understanding-hbase.html 很不错。

HBase – Hadoop Database,是一个高可靠性、高性能、面向列、可伸缩的分布式存储系统,利用HBase技术可在廉价PC Server上搭建起大规模结构化存储集群。

HBase是Google Bigtable的开源实现,类似Google Bigtable利用GFS作为其文件存储系统,HBase利用Hadoop HDFS作为其文件存储系统;Google运行MapReduce来处理Bigtable中的海量数据,HBase同样利用Hadoop MapReduce来处理HBase中的海量数据;Google Bigtable利用 Chubby作为协同服务,HBase利用Zookeeper作为对应。

(HBase感觉更像是一个上学时学的分布式数据库)

2. HBase安装的版本要和Hadoop的版本对应起来,刚开始下了最新的hbase-0.94.0,但是Hadoop的版本是hadoop-0.20.203.0,在启动HBase的时候,总是有问题。重新下载了hbase-0.90.6之后,一次就启动成功了。

[ate: /local/nomad2 ]>> /local/nomad2/hbase/hbase-0.94.0/bin/start-hbase.sh starting master, logging to /local/nomad2/hbase/hbase-0.94.0/bin/../logs/hbase-nomad2-master-ate.outSLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [jar:file:/local/nomad2/hbase/hbase-0.94.0/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: Found binding in [jar:file:/local/nomad2/hadoop/hadoop-0.20.203.0/lib/slf4j-log4j12-1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

解决办法,去掉hbase下面的lib。

>> hbase classpath | tr ":" "\n" | grep -i slf4j

3. 设置环境变量

export HBASE_INSTALL=/local/nomad2/hbase/hbase-0.90.6export PATH=$PATH:$HBASE_INSTALL/bin

4. 启动HBase

[ate: /local/nomad2/hbase/hbase-0.90.6/bin ]>> start-hbase.sh starting master, logging to /local/nomad2/hbase/hbase-0.90.6/bin/../logs/hbase-nomad2-master-ate.out[ate: /local/nomad2/hbase/hbase-0.90.6/bin ]>> hbase shellHBase Shell; enter 'help<RETURN>' for list of supported commands.Type "exit<RETURN>" to leave the HBase ShellVersion 0.90.6, r1295128, Wed Feb 29 14:29:21 UTC 2012hbase(main):001:0> create 'test', 'data'0 row(s) in 1.4430 secondshbase(main):002:0> listTABLE                                                                                                             test                                                                                                              1 row(s) in 0.0420 secondshbase(main):003:0> put 'test', 'row1', 'data:1', 'value1'0 row(s) in 0.1500 secondshbase(main):005:0> put 'test', 'row2', 'data:2', 'value2'0 row(s) in 0.0230 secondshbase(main):006:0> put 'test', 'row3', 'data:3', 'value3'0 row(s) in 0.0220 secondshbase(main):007:0> scan 'test'ROW                          COLUMN+CELL                                                                        row1                        column=data:1, timestamp=1341662081734, value=value1                               row2                        column=data:2, timestamp=1341662107606, value=value2                               row3                        column=data:3, timestamp=1341662122336, value=value3                              3 row(s) in 0.0640 secondshbase(main):008:0> disable 'test'0 row(s) in 2.0590 secondshbase(main):011:0> drop 'test'0 row(s) in 1.1650 secondshbase(main):012:0> listTABLE                                                                                                          0 row(s) in 0.0190 seconds

5. 导入数据(书上的例子)

hbase(main):013:0> create 'stations', {NAME => 'info', VERSIONS => 1}0 row(s) in 1.1100 secondshbase(main):014:0> create 'observations', {NAME => 'data', VERSIONS => 1}0 row(s) in 1.1060 secondshbase(main):015:0> listTABLE                                                                                                          observations                                                                                                   stations                                                                                                       2 row(s) in 0.0210 seconds

>> export HBASE_CLASSPATH=$HBASE_CLASSPATH:ch13.jar>> hbase HBaseTemperatureImporter input/ncdc/all  

导入完成后,从http://ate:60010查看数据表。


原创粉丝点击