Hadoop学习笔记(十五)---Hbase shell命令的使用
2015-06-07 21:49
597 查看
1.启动hbase, 进入hbase文件夹下面的bin文件夹,然后执行命令:
2。创建表:
表users,三个列簇:user_id, address, info
3.查看所有表:
4.查看表结构:
5.删除表:
表不能直接删除,需要先进行disable操作:
如果直接删除会报下面的错误:
应该先disable:
6.查看表是否存在:
7.查看是否禁止:
7.插入数据:
8.查看表中的数据:
9.获得小明的信息:
只查看年龄:
10.更新记录:
现在查看年龄就是最新的年龄:
怎么查看历史记录呢?:
查看上一个数据:
显示时间戳数据:
删除数据:
hbase shell
[root@hadoop0 bin]# hbase shell HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 0.98.12.1-hadoop1, rb00ec5da604d64a0bdc7d92452b1e0559f0f5d73, Sun May 17 12:22:29 PDT 2015 hbase(main):001:0>
2。创建表:
create 'users','user_id', 'address', 'info'
表users,三个列簇:user_id, address, info
3.查看所有表:
list
hbase(main):003:0> list TABLE users 1 row(s) in 0.0400 seconds
4.查看表结构:
describe 'users'
hbase(main):004:0> describe 'users' Table users is ENABLED users COLUMN FAMILIES DESCRIPTION {NAME => 'address', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FORE VER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} {NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER ', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} {NAME => 'user_id', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FORE VER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} 3 row(s) in 0.1000 seconds
5.删除表:
表不能直接删除,需要先进行disable操作:
如果直接删除会报下面的错误:
hbase(main):007:0> drop 'user_tmp' ERROR: Table user_tmp is enabled. Disable it first. Here is some help for this command: Drop the named table. Table must first be disabled: hbase> drop 't1' hbase> drop 'ns1:t1'
应该先disable:
hbase(main):008:0> disable 'user_tmp' 0 row(s) in 1.4120 seconds
hbase(main):010:0> drop 'user_tmp' 0 row(s) in 0.2320 seconds
6.查看表是否存在:
hbase(main):013:0> exists 'users' Table users does exist 0 row(s) in 0.0330 seconds
7.查看是否禁止:
hbase(main):016:0> is_enabled 'users' true 0 row(s) in 0.0410 seconds
hbase(main):002:0> is_disabled 'users' false 0 row(s) in 0.0270 seconds
7.插入数据:
hbase(main):001:0> put 'users', 'xiaoming','info:company','baidu'
8.查看表中的数据:
scan 'users'
9.获得小明的信息:
hbase(main):003:0> get 'users','xiaoming' COLUMN CELL info:age timestamp=1433712506712, value=22 info:company timestamp=1433712630400, value=baidu 2 row(s) in 0.0560 seconds
只查看年龄:
hbase(main):004:0> get 'users','xiaoming','info:age' COLUMN CELL info:age timestamp=1433712506712, value=22 1 row(s) in 0.0280 seconds
10.更新记录:
hbase(main):007:0> put 'users','xiaoming','info:age','24' 0 row(s) in 0.0140 seconds
现在查看年龄就是最新的年龄:
hbase(main):009:0> get 'users','xiaoming','info:age' COLUMN CELL info:age timestamp=1433713054227, value=24 1 row(s) in 0.0140 seconds
怎么查看历史记录呢?:
查看上一个数据:
hbase(main):011:0> get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>2}
显示时间戳数据:
hbase(main):016:1> get 'users','xiaoming',{COLUMN=>'info:age',TIMESTAMP=>1433713054227}
删除数据:
delete 'users','xiaoming','info:age'
相关文章推荐
- shell学习第三天
- spark基础(二)-----------scala在spark shell里的应用
- shell学习第二天
- XShell连接虚拟机Linux
- shell学习第一天
- shell 脚本执行 sql
- Shell if 命令参数
- 用Bash Script编写Hadoop MapReduce Streaming
- 希尔(Shell)排序——改良的插入排序算法
- [管理篇6]使用Linux Shell管理OpenStack的虚拟机——批量创建、开启、关闭虚拟机
- shell数值计算
- shell中如何判断一个变量是否为空
- Linux 中 shell 变量 $#,$@,$0,$1,$2 的含义解释:
- Shellcode的编写
- lvs相关4道shell编程题
- 揭开Shellcode的神秘面纱
- wince6.0 中出现缺少aygshell.h
- load和磁盘占用shell
- /bin/bash^M: bad interpreter: No such file or directory
- shell脚本(三)