ln -s $HBASE_HOME/lib/hbase-common-1.2.0-cdh5.14.0.jar $HIVE_HOME/lib/hbase-common-1.2.0-cdh5.14.0.jar
ln -s $HBASE_HOME/lib/hbase-server-1.2.0-cdh5.14.0.jar $HIVE_HOME/lib/hbase-server-1.2.0-cdh5.14.0.jar
ln -s $HBASE_HOME/lib/hbase-client-1.2.0-cdh5.14.0.jar $HIVE_HOME/lib/hbase-client-1.2.0-cdh5.14.0.jar
ln -s $HBASE_HOME/lib/hbase-protocol-1.2.0-cdh5.14.0.jar $HIVE_HOME/lib/hbase-protocol-1.2.0-cdh5.14.0.jar
ln -s $HBASE_HOME/lib/hbase-it-1.2.0-cdh5.14.0.jar $HIVE_HOME/lib/hbase-it-1.2.0-cdh5.14.0.jar
ln -s $HBASE_HOME/lib/htrace-core-3.2.0-incubating.jar $HIVE_HOME/lib/htrace-core-3.2.0-incubating.jar
ln -s $HBASE_HOME/lib/hbase-hadoop2-compat-1.2.0-cdh5.14.0.jar $HIVE_HOME/lib/hbase-hadoop2-compat-1.2.0-cdh5.14.0.jar
ln -s $HBASE_HOME/lib/hbase-hadoop-compat-1.2.0-cdh5.14.0.jar $HIVE_HOME/lib/hbase-hadoop-compat-1.2.0-cdh5.14.0.jar
cd /export/servers/hive-1.1.0-cdh5.14.0/conf
<property>
<name>hive.zookeeper.quorumname>
<value>node01,node02,node03value>
<description>
The list of ZooKeeper servers to talk to. This is only needed for read/write locks.
description>
property>
<property>
<name>hive.zookeeper.client.portname>
<value>2181value>
<description>
The port of ZooKeeper servers to talk to. This is only needed for read/write locks.
description>
property>
nohup hiveserver2 1>/dev/null 2>&1 &
beeline -u jdbc:hive2://node01:10000 -n root
use sfl;
show create table movie;
CREATE TABLE hive_hbase_emp_table(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:ename,info:job,info:mgr,info:hiredate,info:sal,info:comm,info:deptno")
TBLPROPERTIES ("hbase.table.name" = "hbase_emp_table");
insert into table hive_hbase_emp_table select * from emp;
在 HBase 中已经存储了某一张表 hbase_emp_table,然后在 Hive 中创建一个外部表来关联 HBase中的 hbase_emp_table 这张表,使之可以借助 Hive 来分析 HBase 这张表中的数据。
hbase(main):005:0> scan 'fruit'
ROW COLUMN+CELL
1001 column=info:color, timestamp=1563939888519, value=Red
1001 column=info:name, timestamp=1563939888519, value=Apple
1002 column=info:color, timestamp=1563939888519, value=Yellow
1002 column=info:name, timestamp=1563939888519, value=Pear
1003 column=info:color, timestamp=1563939888519, value=Yellow
1003 column=info:name, timestamp=1563939888519, value=Pineapple
CREATE EXTERNAL TABLE relevance_hbase_fruit(
id int,
name string,
color string)
STORED BY
'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:name,info:color")
TBLPROPERTIES ("hbase.table.name" = "fruit");
select * from relevance_hbase_fruit;