HBase之简单的shell操作 发表于 2018-10-25 | 分类于 大数据 | | 阅读次数: 这些只是简单的shell操作,更多的shell操作还是去网上查看 首先启动相应的服务 进入客户端1[root@localhost conf]# hbase shell 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117显示hbase中的表list创建user表,包含info、data两个列族create 'user', 'info1', 'data1'create 'user', {NAME => 'info', VERSIONS => 3}向user表中插入信息,row key为rk0001,列族info中添加name列标示符,值为zhangsanput 'user', 'rk0001', 'info:name', 'zhangsan'向user表中插入信息,row key为rk0001,列族info中添加gender列标示符,值为femaleput 'user', 'rk0001', 'info:gender', 'female'向user表中插入信息,row key为rk0001,列族info中添加age列标示符,值为20put 'user', 'rk0001', 'info:age', 20向user表中插入信息,row key为rk0001,列族data中添加pic列标示符,值为pictureput 'user', 'rk0001', 'data:pic', 'picture'获取user表中row key为rk0001的所有信息get 'user', 'rk0001'获取user表中row key为rk0001,info列族的所有信息get 'user', 'rk0001', 'info'获取user表中row key为rk0001,info列族的name、age列标示符的信息get 'user', 'rk0001', 'info:name', 'info:age'获取user表中row key为rk0001,info、data列族的信息get 'user', 'rk0001', 'info', 'data'get 'user', 'rk0001', {COLUMN => ['info', 'data']}get 'user', 'rk0001', {COLUMN => ['info:name', 'data:pic']}获取user表中row key为rk0001,列族为info,版本号最新5个的信息get 'people', 'rk0002', {COLUMN => 'info', VERSIONS => 2}get 'user', 'rk0001', {COLUMN => 'info:name', VERSIONS => 5}get 'user', 'rk0001', {COLUMN => 'info:name', VERSIONS => 5, TIMERANGE => [1392368783980, 1392380169184]}获取user表中row key为rk0001,列标示符中含有a的信息get 'people', 'rk0001', {FILTER => "(QualifierFilter(=,'substring:a'))"}put 'user', 'rk0002', 'info:name', 'fanbingbing'put 'user', 'rk0002', 'info:gender', 'female'put 'user', 'rk0002', 'info:nationality', '中国'get 'user', 'rk0002', {FILTER => "ValueFilter(=, 'binary:中国')"}查询user表中的所有信息scan 'user'查询user表中列族为info的信息scan 'people', {COLUMNS => 'info'}scan 'user', {COLUMNS => 'info', RAW => true, VERSIONS => 5}scan 'persion', {COLUMNS => 'info', RAW => true, VERSIONS => 3}查询user表中列族为info和data的信息scan 'user', {COLUMNS => ['info', 'data']}scan 'user', {COLUMNS => ['info:name', 'data:pic']}查询user表中列族为info、列标示符为name的信息scan 'user', {COLUMNS => 'info:name'}查询user表中列族为info、列标示符为name的信息,并且版本最新的5个scan 'user', {COLUMNS => 'info:name', VERSIONS => 5}查询user表中列族为info和data且列标示符中含有a字符的信息scan 'people', {COLUMNS => ['info', 'data'], FILTER => "(QualifierFilter(=,'substring:a'))"}查询user表中列族为info,rk范围是[rk0001, rk0003)的数据scan 'people', {COLUMNS => 'info', STARTROW => 'rk0001', ENDROW => 'rk0003'} 查询user表中row key以rk字符开头的scan 'user',{FILTER=>"PrefixFilter('rk')"}查询user表中指定范围的数据scan 'user', {TIMERANGE => [1392368783980, 1392380169184]}删除数据删除user表row key为rk0001,列标示符为info:name的数据delete 'people', 'rk0001', 'info:name'删除user表row key为rk0001,列标示符为info:name,timestamp为1392383705316的数据delete 'user', 'rk0001', 'info:name', 1392383705316清空user表中的数据truncate 'people'修改表结构首先停用user表(新版本不用)disable 'user'添加两个列族f1和f2alter 'people', NAME => 'f1'alter 'user', NAME => 'f2'启用表enable 'user'###disable 'user'(新版本不用)删除一个列族:alter 'user', NAME => 'f1', METHOD => 'delete' 或 alter 'user', 'delete' => 'f1'添加列族f1同时删除列族f2alter 'user', {NAME => 'f1'}, {NAME => 'f2', METHOD => 'delete'}将user表的f1列族版本号改为5alter 'people', NAME => 'info', VERSIONS => 5启用表enable 'user'删除表disable 'user'drop 'user'