【hadoop】【demo】HBase shell

【hadoop】【demo】HBase shell

t_student cf1cf2
rowkeyidname...ageaddress...
r11001Kitty 20/ 
r21002Jack /NanJing 

 

1.创建 用户test_super(有supergroup权限),test_guest(无supergroup权限)

2.连接用户 test_super 并创建表 't_student' 

kinit test_super

hbase shell

whoami #查看用户权限

list #查看用户下表

 

create 't_student','cf1'

describe 't_student'

user_permission 't_student' #权限:action=ADMIN

 

grant 'user_guest','CRW', 't_student' #授权 用户 user_guest 对 't_student' 有CRW 权限

quit

 

3.连接用户 test_guest 并修改表 't_student' 

kinit test_guest

hbase shell

whoami #查看用户权限

list #查看用户下表

 

describe 't_student'

disable 't_student'

alter 't_student',{NAME=>'cf1',NAME=>'cf2'} #修改表结构

enable 't_student'

 

#新增表数据:此段语句可以写入 test.sh

vi test.sh

输入以下内容:

hbase shell <<EOF

put 't_student','r1','cf1:id','1001'

put 't_student','r1','cf1:name','Kitty'

put 't_student','r1','cf2:age','20'

 

put 't_student','r2','cf1:id','1002'

put 't_student','r2','cf1:name','Jack'

put 't_student','r2','cf2:age','22'

put 't_student','r2','cf2:address','NanJing'

EOF

 

执行test.sh

sh test.sh

 

#修改/删除表数据

put 't_student','r1','cf1:name','Kitty'

put 't_student','r1','cf1:name','Amy'

 

#查询表数据

scan 't_student' #查全表

scan 't_student',{LIMIT=>1} #查1行

 

get 't_student','r1'

get 't_student','r2'

get 't_student','r1',{COLUMN=> ['cf1','cf2']}

get 't_student','r2',{COLUMN=> ['cf1','cf2']}

get 't_student','r1',{COLUMN=> ['cf1:id','cf1:name','cf2:age']}

get 't_student','r2',{COLUMN=> ['cf1:id','cf1:name','cf2:address']}

 

get 't_student','r1',{COLUMN=> ['cf1:id','cf1:name']}

get 't_student','r1',{COLUMN=> 'cf1:name'}

get 't_student','r1','cf1:id','cf1:name'

get 't_student','r1','cf1:name'

get 't_student','r1','cf1:id','cf1:name','cf2:age'

get 't_student','r2','cf1:id','cf1:name','cf2:address'

 

disable 't_student'

drop 't_student'

 

posted on 2019-02-18 16:58 绿Z 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/greenZ/p/10396544.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值