环境:
CentOS 6.5, Hadoop 1.1.2, zookeeper 3.4.4, Hbase 0.94.7-security, JDK 1.7
一、进入shell
执行命令 <HBASE_HOME>/bin/hbase shell
二、shell操作命令
#键入help, 查看所有操作命令
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, 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_permission
三、库表操作
1. status #查询数据库状态
2. version #查询数据库版本
3. create 'table_name_1','row_key_1','columnFamily_1','columnFamily_2','columnFamily_3' #创建表,表名、行键和列族必须指定
4. list #列出所有表
5. describe 'table_name_1' #查看表信息
6. disable 'table_name_1' #停用表
7. enable 'table_name_1' #启用表
8. alter 'table_name_1',{NAME=>'row_key_1',METHOD='delete'} #删除列族
9. drop 'table_name_1' #删除表
10. exists 'table_name_1' #判断表是否存在
11. is_enabled 'table_name_1' #判断表是否启用
12. is_disabled 'table_name_1' #判断表是否停用
13. put 'table_name_1','row_key_1','columnFamily_1:col_1','val_1' #插入或更新一条记录
14. get 'table_name_1','row_key_1' #获取一个行键的所有数据
15. get 'table_name_1','row_key_1','columnFamily_1' #获取一个行键,一个列族的所有数据
16. get 'table_name_1','row_key_1','columnFamily_1:col_1' #获取一个行键,一个列族中一个列的所有数据
17. get 'table_name_1','row_key_1',{COLUMN=>'columnFamily_1:col_1',TIMESTAMP=>1321586571843} #通过timestamp来获取数据
18. scan 'table_name_1' #全表扫描
19. delete 'table_name_1','row_key_1','columnFamily_1:col_1' #删除指定行键的字段
20. deleteall 'table_name_1','row_key_1' #删除行
21. count 'table_name_1' #查看表中行数
CentOS 6.5, Hadoop 1.1.2, zookeeper 3.4.4, Hbase 0.94.7-security, JDK 1.7
一、进入shell
执行命令 <HBASE_HOME>/bin/hbase shell
二、shell操作命令
#键入help, 查看所有操作命令
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, 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_permission
三、库表操作
1. status #查询数据库状态
2. version #查询数据库版本
3. create 'table_name_1','row_key_1','columnFamily_1','columnFamily_2','columnFamily_3' #创建表,表名、行键和列族必须指定
4. list #列出所有表
5. describe 'table_name_1' #查看表信息
6. disable 'table_name_1' #停用表
7. enable 'table_name_1' #启用表
8. alter 'table_name_1',{NAME=>'row_key_1',METHOD='delete'} #删除列族
9. drop 'table_name_1' #删除表
10. exists 'table_name_1' #判断表是否存在
11. is_enabled 'table_name_1' #判断表是否启用
12. is_disabled 'table_name_1' #判断表是否停用
13. put 'table_name_1','row_key_1','columnFamily_1:col_1','val_1' #插入或更新一条记录
14. get 'table_name_1','row_key_1' #获取一个行键的所有数据
15. get 'table_name_1','row_key_1','columnFamily_1' #获取一个行键,一个列族的所有数据
16. get 'table_name_1','row_key_1','columnFamily_1:col_1' #获取一个行键,一个列族中一个列的所有数据
17. get 'table_name_1','row_key_1',{COLUMN=>'columnFamily_1:col_1',TIMESTAMP=>1321586571843} #通过timestamp来获取数据
18. scan 'table_name_1' #全表扫描
19. delete 'table_name_1','row_key_1','columnFamily_1:col_1' #删除指定行键的字段
20. deleteall 'table_name_1','row_key_1' #删除行
21. count 'table_name_1' #查看表中行数
22. truncate 'table_name_1' #清空表