1,执行命令:hbase shell,会进入到你的 hbase shell 客户端
由于开启ranger控制权限操作,在执行hbase shell 之前要切换有访问及读写权限的用户
2,执行命令:create,创建表
创建 user 表,包含 info、data 两个列簇
hbase(main):018:0> create 'user_info',{NAME=>'base_info',VERSIONS=>3 },{NAME=>'extra_info',VERSIONS=>1 }
3,执行命令:put,插入数据
向 user 表中插入信息,row key 为 user0001,列簇 base_info 中添加 name 列标示符,值为 zhangsan1
hbase(main):004:0> put 'user_info', 'user0001', 'base_info:name', 'zhangsan1'
可以多添加几条数据:
put 'user_info', 'zhangsan_20150701_0001', 'base_info:name', 'zhangsan1' put 'user_info', 'zhangsan_20150701_0002', 'base_info:name', 'zhangsan2' put 'user_info', 'zhangsan_20150701_0003', 'base_info:name', 'zhangsan3' put 'user_info', 'zhangsan_20150701_0004', 'base_info:name', 'zhangsan4' put 'user_info', 'zhangsan_20150701_0005', 'base_info:name', 'zhangsan5' put 'user_info', 'zhangsan_20150701_0006', 'base_info:name', 'zhangsan6' put 'user_info', 'zhangsan_20150701_0007', 'base_info:name', 'zhangsan7' put 'user_info', 'zhangsan_20150701_0008', 'base_info:name', 'zhangsan8'
put 'user_info', 'zhangsan_20150701_0001', 'base_info:age', '21' put 'user_info', 'zhangsan_20150701_0002', 'base_info:age', '22' put 'user_info', 'zhangsan_20150701_0003', 'base_info:age', '23' put 'user_info', 'zhangsan_20150701_0004', 'base_info:age', '24' put 'user_info', 'zhangsan_20150701_0005', 'base_info:age', '25' put 'user_info', 'zhangsan_20150701_0006', 'base_info:age', '26' put 'user_info', 'zhangsan_20150701_0007', 'base_info:age', '27' put 'user_info', 'zhangsan_20150701_0008', 'base_info:age', '28'
put 'user_info', 'zhangsan_20150701_0001', 'extra_info:Hobbies', 'music' put 'user_info', 'zhangsan_20150701_0002', 'extra_info:Hobbies', 'sport' put 'user_info', 'zhangsan_20150701_0003', 'extra_info:Hobbies', 'music' put 'user_info', 'zhangsan_20150701_0004', 'extra_info:Hobbies', 'sport' put 'user_info', 'zhangsan_20150701_0005', 'extra_info:Hobbies', 'music' put 'user_info', 'zhangsan_20150701_0006', 'extra_info:Hobbies', 'sport' put 'user_info', 'zhangsan_20150701_0007', 'extra_info:Hobbies', 'music'
put 'user_info', 'baiyc_20150716_0001', 'base_info:name', 'baiyc1' put 'user_info', 'baiyc_20150716_0002', 'base_info:name', 'baiyc2' put 'user_info', 'baiyc_20150716_0003', 'base_info:name', 'baiyc3' put 'user_info', 'baiyc_20150716_0004', 'base_info:name', 'baiyc4' put 'user_info', 'baiyc_20150716_0005', 'base_info:name', 'baiyc5' put 'user_info', 'baiyc_20150716_0006', 'base_info:name', 'baiyc6' put 'user_info', 'baiyc_20150716_0007', 'base_info:name', 'baiyc7' put 'user_info', 'baiyc_20150716_0008', 'base_info:name', 'baiyc8'
put 'user_info', 'baiyc_20150716_0001', 'base_info:age', '21' put 'user_info', 'baiyc_20150716_0002', 'base_info:age', '22' put 'user_info', 'baiyc_20150716_0003', 'base_info:age', '23' put 'user_info', 'baiyc_20150716_0004', 'base_info:age', '24' put 'user_info', 'baiyc_20150716_0005', 'base_info:age', '25' put 'user_info', 'baiyc_20150716_0006', 'base_info:age', '26' put 'user_info', 'baiyc_20150716_0007', 'base_info:age', '27' put 'user_info', 'baiyc_20150716_0008', 'base_info:age', '28'
put 'user_info', 'baiyc_20150716_0001', 'extra_info:Hobbies', 'music' put 'user_info', 'baiyc_20150716_0002', 'extra_info:Hobbies', 'sport' put 'user_info', 'baiyc_20150716_0003', 'extra_info:Hobbies', 'music' put 'user_info', 'baiyc_20150716_0004', 'extra_info:Hobbies', 'sport' put 'user_info', 'baiyc_20150716_0005', 'extra_info:Hobbies', 'music' put 'user_info', 'baiyc_20150716_0006', 'extra_info:Hobbies', 'sport' put 'user_info', 'baiyc_20150716_0007', 'extra_info:Hobbies', 'music' put 'user_info', 'baiyc_20150716_0008', 'extra_info:Hobbies', 'sport'
4,查询hbase数据,通过ranger实现数据脱敏