您现在的位置是:首页 > 文章详情

学习Hbase之quick start

日期:2012-12-12点击:708
1.2. Quick Start

     Loopback IP

     /etc/hosts should look something like this:
      
  1. vi /etc/hosts

  2. 127.0.0.1 localhost
  3. 127.0.0.1 ubuntu.ubuntu-domain ubuntu

1.2.1. Download and unpack the latest stable release.(下载和解压稳定版本)


  1. $ tar xfvz hbase-0.94.3-security.tar.gz
  2. $ cd hbase-0.94.3-security
        安装之前,编辑 conf/hbase-site.xml.其中hbase.rootdir,是Hbase写数据的目录
                                           其中hbase.zookeeper.property.dataDir,是ZooKeeper写数据的目录


  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. hbase.rootdir
  4. /data/hbase
  5. hbase.zookeeper.property.dataDir
  6. /data/zookeeper

1.2.2. Start HBase


  1. [root@ZSDDB8 hbase-0.94.3-security]# ./bin/start-hbase.sh
  2. starting master, logging to /root/hbase-0.94.3-security/bin/../logs/hbase-root-master-ZSDDB8.out
这样就算开启了单实例的HBase

         Is java Installed?可以查看http://blog.chinaunix.net/space.php?uid=26446098&do=blog&id=3438622   java7安装方式


1.2.3. Shell Exercises


通过shell连接HBASE

  1. [root@ZSDDB8 hbase-0.94.3-security]# ./bin/hbase shell
  2. HBase Shell; enter 'help' for list of supported commands.
  3. Type "exit" to leave the HBase Shell
  4. Version 0.94.3, r1408904, Wed Nov 14 16:41:36 UTC 2012

  5. hbase(main):001:0>

创建一个表为test且一个列集合为cf。通过list 'test'验证它的创建然后插入一些数据


  1. hbase(main):003:0> create 'test', 'cf'
  2. 0 row(s) in 1.2200 seconds
  3. hbase(main):002:0> list 'test'
  4. TABLE
  5. test
  6. 1 row(s) in 0.0170 seconds
  7. 1 row(s) in 0.0550 seconds
  8. hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1'
  9. 0 row(s) in 0.0560 seconds
  10. hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2'
  11. 0 row(s) in 0.0370 seconds
  12. hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3'
  13. 0 row(s) in 0.0450 seconds
通过执行scan 命令验证刚插入的数据


  1. hbase(main):006:0> scan 'test'
  2. ROW COLUMN+CELL
  3. row1 column=cf:a, timestamp=1355386368983, value=value1
  4. row2 column=cf:b, timestamp=1355386374028, value=value2
  5. row3 column=cf:c, timestamp=1355386377745, value=value3
  6. 3 row(s) in 0.0600 seconds
得到一行的数据

  1. hbase(main):007:0> get 'test', 'row1'
  2. COLUMN CELL
  3. cf:a timestamp=1355386368983, value=value1
  4. 1 row(s) in 0.0330 seconds
现在disable然后drop掉你的表,就可以清除上面你做的所有操作


  1. hbase(main):008:0> disable 'test'
  2. 0 row(s) in 2.0730 seconds

  3. hbase(main):009:0> drop 'test'
  4. 0 row(s) in 0.1100 seconds
退出

  1. hbase(main):013:0> exit
1.2.4. Stopping HBase

执行stop-hbase.sh关闭HBase

  1. $ ./bin/stop-hbase.sh
  2. [root@ZSDDB8 hbase-0.94.3-security]# ./bin/stop-hbase.sh
  3. stopping hbase...........

1.2.5. Where to go next
The above described standalone setup is good for testing and experiments only. In the next chapter, Chapter 2, Apache HBase (TM) Configuration, we'll go into depth on the different HBase run modes, system requirements running HBase, and critical configurations setting up a distributed HBase deploy.








原文链接:https://yq.aliyun.com/articles/393859
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章