HBase 常用命令
1. 启动Hbase
- hbase shell
2. 查看表若干行
- scan \'表名\',{LIMIT => 10}
3. 查看表的某列的若干行
- scan \'表名\',{COLUMN=>\'列族:列名\', LIMIT => 10}
4. 指定范围查询表并结合shell处理并导出数据
- echo "scan \'hb_test\',{STARTROW => \'79839078\', STOPROW=>\'798390788\', COLUMNS => \'index:updated_at\'}" | ./hbase shell | grep value > myText.txt //指定范围scan并导出数据到文件
- cat myText.txt | awk -F_ \'{print $3}\' | awk -F\ \'{print $1}\' | sort -u > retText.txt //选择列,排序并去重
- cat retText.txt | tr -s "\n" "," > text.txt //多行合成一行
5. 创建表
- # 例如:创建表t1,有两个family name:f1,f2,且版本数均为1
- hbase(main)> create \'t1\',{NAME => \'f1\', VERSIONS => 1},{NAME => \'f2\', VERSIONS => 1}