hbase之路-1

来源:互联网 发布:贵州大数据学院 编辑:程序博客网 时间:2024/05/16 07:49

开始学习hbase,先下载安装包进行安装,参照http://hbase.apache.org/book/quickstart.html,安装步骤如下:

1. 安装centos虚拟机

2. 安装java6的jdk,设置javahome等环境变量。

3. 解压hbase安装包

$ tar xfz hbase-0.99.0-SNAPSHOT.tar.gz$ cd hbase-0.99.0-SNAPSHOT

装好后,基本的shell命令如下:

启动和停止hbase脚本操作如下:

$ ./bin/start-hbase.shstarting Master, logging to logs/hbase-user-master-example.org.out
$ ./bin/stop-hbase.shstopping hbase...............
进入hbase控制台命令如下:

$ ./bin/hbase shellHBase Shell; enter 'help<RETURN>' for list of supported commands.Type "exit<RETURN>" to leave the HBase ShellVersion: 0.90.0, r1001068, Fri Sep 24 13:55:42 PDT 2010hbase(main):001:0> 

重点再看看控制台中常用命令为:

create:创建表

list:查看表名列表

put:插入表数据

get:按照rowid查看表中行数据

scan:扫描查看表中数据

disable:禁用表

drop:删除表

exit:退出控制台

hbase(main):003:0> create 'test', 'cf'0 row(s) in 1.2200 secondshbase(main):003:0> list 'test'..1 row(s) in 0.0550 secondshbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1'0 row(s) in 0.0560 secondshbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2'0 row(s) in 0.0370 secondshbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3'0 row(s) in 0.0450 seconds
hbase(main):007:0> scan 'test'ROW        COLUMN+CELLrow1       column=cf:a, timestamp=1288380727188, value=value1row2       column=cf:b, timestamp=1288380738440, value=value2row3       column=cf:c, timestamp=1288380747365, value=value33 row(s) in 0.0590 seconds
hbase(main):008:0> get 'test', 'row1'COLUMN      CELLcf:a        timestamp=1288380727188, value=value11 row(s) in 0.0400 seconds
hbase(main):012:0> disable 'test'0 row(s) in 1.0930 secondshbase(main):013:0> drop 'test'0 row(s) in 0.0770 seconds 
hbase(main):014:0> exit

具体命令可以查看help后展示如下:

hbase(main):005:0> helpHBase Shell, version 0.94.19, r1588997, Tue Apr 22 00:21:01 UTC 2014Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command.Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group.COMMAND GROUPS:  Group name: general  Commands: status, version, whoami  Group name: ddl  Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, is_disabled, is_enabled, list, show_filters  Group name: dml  Commands: count, delete, deleteall, get, get_counter, incr, put, scan, truncate  Group name: tools  Commands: assign, balance_switch, balancer, close_region, compact, flush, hlog_roll, major_compact, move, split, unassign, zk_dump  Group name: replication  Commands: add_peer, disable_peer, enable_peer, list_peers, list_replicated_tables, remove_peer, start_replication, stop_replication  Group name: snapshot  Commands: clone_snapshot, delete_snapshot, list_snapshots, restore_snapshot, snapshot  Group name: security  Commands: grant, revoke, user_permissionSHELL USAGE:Quote all names in HBase Shell such as table and column names.  Commas delimitcommand parameters.  Type <RETURN> after entering a command to run it.Dictionaries of configuration used in the creation and alteration of tables areRuby Hashes. They look like this:  {'key1' => 'value1', 'key2' => 'value2', ...}and are opened and closed with curley-braces.  Key/values are delimited by the'=>' character combination.  Usually keys are predefined constants such asNAME, VERSIONS, COMPRESSION, etc.  Constants do not need to be quoted.  Type'Object.constants' to see a (messy) list of all constants in the environment.If you are using binary keys or values and need to enter them in the shell, usedouble-quote'd hexadecimal representation. For example:  hbase> get 't1', "key\x03\x3f\xcd"  hbase> get 't1', "key\003\023\011"  hbase> put 't1', "test\xef\xff", 'f1:', "\x01\x33\x40"The HBase shell is the (J)Ruby IRB with the above HBase-specific commands added.For more on the HBase Shell, see http://hbase.apache.org/docs/current/book.html
到此位置,hbase的单机安装和包含内容有个简单的印象。



0 0
原创粉丝点击