HBase基本操作

查看所有表空间下的所有表

list

查看指定表空间下的所有表

list_namespace_tables [namespace]

建表

create 'tableName',{NAME=>'columnCluster',VERSIONS=>2,BLOCKCACHE=>true,BLOOMFILTER=>'ROW',COMPRESSION=>'SNAPPY',TTL=> '31536000'},{SPLITS => ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60',
'61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80',
'81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','96','97','98','99']}

tableName:表名

NAME:列簇名

BLOCKCACHE:是否开启块缓存;

VERSIONS:设置版本数,表示该列簇下的数据保存多少个版本的信息

BLOOMFILTER:是布隆过滤器,用于优化Hbase的随机读写性能,默认值为none

COMPRESSION:是数据的压缩方式,snappy压缩率最低,编解码速率最高,建议使用;

TTL:表示数据的过期时间,单位为秒;

SPLITS:预分区策略

授权用户读写权限

grant [user],'RW','[namespace]:[tableName]'

查看表里全部数据

scan '[namespace]:[tableName]'

查看单条rowkey数据

get '[namespace]:[tableName]','[rowKey]'

插入数据

put '[namespace]:[tableName]','[rowKey]','[columnCluster]:[columnName]' [value]
上一篇:Hbase过滤器


下一篇:面试(串讲三)