Hbase安装

1:下载
下载地址
2:解压

tar -zxvf hbase-0.94.26.tar.gz

3:配置目录
HBASE_HOME/conf/hbase-site.xml
默认只有配置,没有property配置,需要自己加上
也可以不用配置,直接第四步启动(hbase默认目录:/tmp/hbase-${user.name},由于很多操作系统会在重启的时候清空/tmp目录,所以这里设置一下比较好)

<configuration>
    <property>
      <name>hbase.rootdir</name>
      <value>file:/usr/hbase/hbase-${user.name}</value>
    </property>
</configuration>

4:启动

[root@liuchao bin]# ./start-hbase.sh 
starting master, logging to /usr/local/hbase-0.94.26/bin/../logs/hbase-root-master-liuchao.out

5:貌似成功了(试试)

[root@liuchao bin]# ./hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.94.26, ra9114543cd48c7e230dabd31f45a086f7b7a5d6a, Wed Dec 17 20:37:01 UTC 2014

hbase(main):001:0> status
1 servers, 0 dead, 2.0000 average load

hbase(main):002:0> 

6:看到这些,说明已经成功了,可以进行下一步测试了
创建一张表

hbase(main):001:0> create 'testtable','colfam1'
0 row(s) in 3.7160 seconds

1:>查看创建的表

hbase(main):002:0> list 'tae'
TABLE                                                                                             
0 row(s) in 0.2010 seconds

hbase(main):003:0> list 'testtable'
TABLE                                                                                             
testtable                                                                                         
1 row(s) in 0.1050 seconds

2:>插入几条数据

hbase(main):004:0> put 'testtable','myrow-1','colfam1:q1','value-1'
0 row(s) in 0.4080 seconds

hbase(main):005:0> put 'testtable','myrow-2','colfam1:q2','value-2'
0 row(s) in 0.1320 seconds

hbase(main):006:0> put 'testtable','myrow-3','colfam1:q3','value-3'
0 row(s) in 0.1090 seconds

3:>查看表中的数据

hbase(main):007:0> scan 'testtable'
ROW                       COLUMN+CELL                                                             
 myrow-1                  column=colfam1:q1, timestamp=1424834391342, value=value-1               
 myrow-2                  column=colfam1:q2, timestamp=1424834424591, value=value-2               
 myrow-3                  column=colfam1:q3, timestamp=1424834464914, value=value-3               
3 row(s) in 0.2360 seconds

4:>获取某一行的数据

hbase(main):002:0> get 'testtable','myrow-2'
COLUMN                    CELL                                                                    
 colfam1:q2               timestamp=1424834424591, value=value-2                                  
1 row(s) in 0.2090 seconds

5:>删除一行数据

hbase(main):003:0> delete 'testtable','myrow-2','colfam1:q2'
0 row(s) in 0.1110 seconds

hbase(main):004:0> scan 'testtable'
ROW                       COLUMN+CELL                                                             
 myrow-1                  column=colfam1:q1, timestamp=1424834391342, value=value-1               
 myrow-3                  column=colfam1:q3, timestamp=1424834464914, value=value-3               
2 row(s) in 0.1780 seconds

6:>禁用并删除表

hbase(main):004:0> disable 'testtable'
0 row(s) in 1.4690 seconds

这时再查看,表已经不能用了

hbase(main):005:0> scan 'testtable'
ROW                       COLUMN+CELL                                                             

ERROR: org.apache.hadoop.hbase.DoNotRetryIOException: testtable is disabled.

7:>表启用

hbase(main):002:0> enable 'testtable'
0 row(s) in 1.5810 seconds

现在又可以用了

hbase(main):002:0> scan 'testtable'
ROW                       COLUMN+CELL                                                             
 myrow-1                  column=colfam1:q1, timestamp=1424834391342, value=value-1               
 myrow-3                  column=colfam1:q3, timestamp=1424834464914, value=value-3               
2 row(s) in 0.3160 seconds

8:>删除表

hbase(main):003:0> drop 'testtable'

ERROR: Table testtable is enabled. Disable it first.'

Here is some help for this command:
Drop the named table. Table must first be disabled: e.g. "hbase> drop 't1'"

必须先禁用表,才能删除表

hbase(main):004:0> disable 'testtable'
0 row(s) in 1.4460 seconds

hbase(main):005:0> drop 'testtable'
0 row(s) in 1.3030 seconds

hbase(main):006:0> scan 'testtable'
ROW                       COLUMN+CELL                                                             

ERROR: Unknown table testtable!

9:>退出

hbase(main):001:0> exit

10:>关闭Hbase

[root@liuchao bin]# ./stop-hbase.sh 
stopping hbase.....................
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值