UvGsu3AFuXc2AAAAAASUVORK5CYII=

Hive ile Hbase database nasil entegre ederim. Hive uzerinden Hbase databasedeki tablomu nasil baglarim

 

set up necessary path and jar configuration

login root user

su –

hbase shell

hbase(main):001:0> list
TABLE

users

 

hbase(main):002:0> describe ‘users’
DESCRIPTION                                          ENABLED
‘users’, {NAME => ‘a’, DATA_BLOCK_ENCODING => ‘NONE true
‘, BLOOMFILTER => ‘ROW’, REPLICATION_SCOPE => ‘0’,
VERSIONS => ‘1’, COMPRESSION => ‘NONE’, MIN_VERSION
S => ‘0’, TTL => ‘2147483647’, KEEP_DELETED_CELLS =
> ‘false’, BLOCKSIZE => ‘65536’, IN_MEMORY => ‘fals
e’, BLOCKCACHE => ‘true’}
1 row(s) in 0.4510 seconds

hbase(main):003:0> get ‘users’,’1′
COLUMN                CELL
a:address            timestamp=1462368843466, value=3084 Cody Ridge Road
a:city               timestamp=1462368843466, value=Loco
a:email              timestamp=1462368843466, value=LarryESchwarz@teleworm.us
a:name               timestamp=1462368843466, value=Larry E Schwarz
a:phone              timestamp=1462368843466, value=580-537-8691
a:state              timestamp=1462368843466, value=OK
a:zipcode            timestamp=1462368843466, value=73442
7 row(s) in 0.0670 seconds

sudo cp /usr/lib/hbase/lib/hbase*.jar /usr/lib/hive/lib

if needed you can set zookeeper conf.

set hbase.zookeeper.com=127.0.0.1;
set hbase.master=127.0.0.1:60000;

connect hive

create external table users(key int,address string,city string,email string,name string,phone string,state string, zipcode string) stored by ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler’ with serdeproperties (‘hbase.columns.mapping’ = ‘:key,a:address,a:city,a:email,a:name,a:phone,a:state,a:zipcode’);

 

hive> describe users
> ;
OK
key                     int                     from deserializer
address                 string                  from deserializer
city                    string                  from deserializer
email                   string                  from deserializer
name                    string                  from deserializer
phone                   string                  from deserializer
state                   string                  from deserializer
zipcode                 string                  from deserializer
Time taken: 3.19 seconds, Fetched: 8 row(s)

hive> select * from users;
OK
1    3084 Cody Ridge Road    Loco    LarryESchwarz@teleworm.us    Larry E Schwarz    580-537-8691    OK    73442
10    3917 Rardin Drive    Santa Clara    TomSDuckett@gustr.com    Tom S Duckett    650-642-6293    CA    95050
11    3406 Ashmor Drive    Kettle River    TheresaRWilliams@dayrep.com    Theresa R Williams    218-273-3304    MN    55757
12    2586 Brighton Circle Road    Wahkon    MildredTBrewer@superrito.com    Mildred T Brewer    320-495-4127    MN    56386
13    4621 Warner Street    Miami    AmandaJWright@cuvox.de    Amanda J Wright305-972-9928    FL    33176
14    4655 Emeral Dreams Drive    Rockford    PamelaRSpinelli@teleworm.us    Pamela R Spinelli    815-226-7633    IL    61108
15    1481 Coolidge Street    Corvallis    GloriaCBewley@einrot.com    Gloria C Bewley    406-961-9478    MT    59828
16    1192 Woodlawn Drive    Sheboygan Falls    GenaDMarshall@dayrep.com    Gena D Marshall    414-596-9264    WI    53085
17    4509 Lang Avenue    Salt Lake City    JamesMWilliams@armyspy.com    James M Williams    435-818-2733    UT    84116
18    2425 Horner Street    Cuyahoga Falls    ChristopherASchneider@fleckens.hu    Christopher A Schneider    330-905-1625    OH    44221
19    90 Willison Street    Golden Valley    SamathaDMcDaniel@dayrep.com    Samatha D McDaniel    763-293-9310    MN    55427
20    3132 Sugarfoot Lane    Indianapolis    KennethLDean@cuvox.de    Kenneth L Dean    765-466-9472    IN    46225
4    4093 Adonais Way    Atlanta    MaryODuprey@jourrapide.com    Mary O Duprey    678-398-6820    GA    30308