`
hotdog
  • 浏览: 281993 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Hive和HBase整合

阅读更多

系统信息

CentOS release 5.3 (Final)

Linux version 2.6.18-128.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)) #1 SMP Wed Jan 21 10:41:14 EST 2009

 

Hadoop等版本信息

hadoop-0.20.2-cdh3u1

hbase-0.90.3-cdh3u1

hive-0.7.1-cdh3u1

 

Hive安装见http://running.iteye.com/blog/892312

 

在$HIVE_HOME/conf目录中增加文件hive-site.xml,内容如下:

 

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
    <property>
        <name>hive.aux.jars.path</name>
        <value>file:///data/hive/lib/hive-hbase-handler-0.7.1-cdh3u1.jar,file:///data/hive/lib/hbase-0.90.3-cdh3u1.j
ar,file:///data/hive/lib/zookeeper-3.3.1-cdh3u1.jar</value>
    </property>

    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>hadoop1,hadoop2,hadoop3</value>
    </property>

</configuration>


参考http://www.javabloger.com/article/apache-hadoop-hive-hbase-integration.html 进行测试

 

运行一个在Hive中建表语句,并且将数据导入

 

建表

CREATE TABLE pokes (foo INT, bar STRING);


数据导入

LOAD DATA LOCAL INPATH '/data/hive/examples/files/kv1.txt' OVERWRITE INTO TABLE pokes;


在Hive与HBase关联的表中 插入一条数据

INSERT OVERWRITE TABLE hbase_table_1 SELECT * FROM pokes WHERE foo=98;


执行hbase shell进入hbase,执行命令查看刚才的hive数据是否与hbase同步

scan 'xyz'


在hbase插入数据

put 'xyz','10001','cf1:val','test'


hive中查询hbase插入的记录

select * from hbase_table_1 WHERE key=10001;
 

相互同步没有问题,整合结束

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics