Hbase中表与Phoenix表建立关联关系

  1. Hbase建表
hbase(main):046:0> create 'LXW','CF'
0 row(s) in 1.2120 seconds

=> Hbase::Table - LXW
hbase(main):047:0> put 'LXW','row1','CF:NAME','lxw'
0 row(s) in 0.0120 seconds

hbase(main):048:0> put 'LXW','row1','CF:AGE','18'
0 row(s) in 0.0080 seconds

hbase(main):049:0> put 'LXW','row1','CF:ADDRESS','BeijingYiZhuang'
0 row(s) in 0.0070 seconds

hbase(main):050:0> 
  1. Phoenix 建视图
0: jdbc:phoenix:localhost:2181> create view  lxw(id varchar(200) not null primary key,cf.name varchar(50),cf.age varchar(20) ,cf.address varchar(200));
No rows affected (5.869 seconds)
0: jdbc:phoenix:localhost:2181> select * from lxw;
+-------+-------+------+------------------+
|  ID   | NAME  | AGE  |     ADDRESS      |
+-------+-------+------+------------------+
| row1  | lxw   | 18   | BeijingYiZhuang  |
+-------+-------+------+------------------+
1 row selected (0.228 seconds)
0: jdbc:phoenix:localhost:2181> 

如上所示,建的视图可以显示hbase中put的数据

查询带条件sql:

select “columnName” from “TableName” where “columnName”=‘20190905092545836u5G58qD’ limit 20 ;

直接在命令行通过sqoop用Phoenix driver 查hbase数据:

sqoop eval --driver org.apache.phoenix.jdbc.PhoenixDriver --connect jdbc:phoenix:192.168.35.27,192.168.35.32,192.168.35.33:2181 --query "select * from \"ods_app_deviceInfo\" where DAYSTR='20190921'"

你可能感兴趣的:(Hbase中表与Phoenix表建立关联关系)