The data preparation 1.HDFS
2019-03-24 09:21:57.347,869454021315519,8,1
2019-03-24 22:07:15.513,867789020387791,8,1
2019-03-24 21:43:34.81,357008082359524,8,1
2019-03-24 16:05:32.227,860201045831206,8,1
2019-03-24 18:11:18.167,866676040163198,8,1
2019-03-24 22:01:24.877,868897026713230,8,1
2019-03-24 12:34:23.377,863119033590062,8,1
2019-03-24 20:16:32.53,862505041870010,8,1
2019-03-24 09:10:55.18,864765037658468,8,1
2019-03-24 16:18:41.503,869609023903469,8,1
2019-03-24 10:44:52.027,869982033593376,8,1
2019-03-24 20:00:08.007,866798025149107,8,1
2019-03-24 10:25:18.1,863291034398181,2,3
2019-03-24 10:33:48.56,867557030361332,8,1
2019-03-24 16:42:15.057,869841022390535,8,1
2019-03-24 10:08:00.277,867574031105048,8,1
Note: The separator is ','
Create a table on the 2. HBase
create 'ALLUSER','INFO';
3. To create the same table in Phoenix to implement the mapping table with hbase
create table if not exists ALLUSER(
firsttime varchar primary key,
INFO.IMEI varchar,
INFO.COID varchar,
INFO.NCOID varchar
)
note:
- In addition to the primary key table names and field to field names of the table and Phoenix HBase same table, including the case
- Phoneix in the column must begin with the HBase columnFamily
4. Specify the separator through importtsv.separator, otherwise the default delimiter is the tab key
hbase org.apache.hadoop.hbase.mapreduce.ImportTsv \
-Dimporttsv.columns=HBASE_ROW_KEY,INFO:IMEI,INFO:IMEI,INFO:NCOID \
-Dimporttsv.separator=, -Dimporttsv.bulk.output=/warehouse/temp/alluser ALLUSER /user/hive/warehouse/toutiaofeedback.db/newuser/000001_0
5. The resulting HFlie into HBase
hbase org.apache.hadoop.hbase.mapreduce.LoadIncrementalHFiles /warehouse/temp/alluser ALLUSER
6. Review HBase, Phoenix
View HBase
View Phoenix