talend 将hbase中数据导入到mysql中

首先,解决talend连接hbase的问题:

公司使用的机器是HDP2.2的机器,上面配置好Hbase服务,在集群的/etc/hbase/conf/hbase-site.xml下,有如下配置:

<property>
      <name>zookeeper.znode.parent</name>
      <value>/hbase-unsecure</value>
    </property>

这个配置是决定, Hbase master在zookeeper中,存储数据的根节点,如果不特别设置,默认位置是:/hbase (这个坑了我好久呀。。。,经过漫长的研究,终于顿悟,着实不易呀)。

在设置hbase databae时,配置如下:

Image

Image

测试zk的联通性:

[zookeeper@hdp1 ~]$ zookeeper-client -server 172.28.3.61:2181

[zk: 172.28.3.61:2181(CONNECTED) 15] ls /
[hiveserver2, controller_epoch, controller, brokers, zookeeper, hbase-unsecure, hadoop-ha, rmstore, admin, consumers, config]
[zk: 172.28.3.61:2181(CONNECTED) 16] ls /hbase-unsecure
[replication, meta-region-server, rs, splitWAL, backup-masters, table-lock, region-in-transition, online-snapshot, master, running, recovering-regions, draining, namespace, hbaseid, table]

最后的状态是连接成功:

image

连接成功后,retrive schema:

image

在hbase中,表格信息如下:

hbase(main):047:0> scan 'zhangchao'
ROW                           COLUMN+CELL
 example                      column=cc2:name, timestamp=1436838509057, value=justin
 example2                     column=cc1:age, timestamp=1436838869051, value=38
 example3                     column=cc1:sex, timestamp=1436839082133, value=male
 example4                     column=cc1:age, timestamp=1436854903976, value=334
4 row(s) in 0.0270 seconds

hbase(main):048:0> describe 'zhangchao'
DESCRIPTION                                                               ENABLED
 'zhangchao', {NAME => 'cc1', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_M true
 EMORY => 'false', KEEP_DELETED_CELLS => 'false', DATA_BLOCK_ENCODING =>
 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BL
 OCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}, {NA
 ME => 'cc2', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false'
 , KEEP_DELETED_CELLS => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => '
 FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'tru
 e', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
1 row(s) in 0.0770 seconds

mysql中表的结构如下:

image

建立Talend模型,将hbase中的数据导入到mysql中:

image

image

image

执行后,mysql中的表中有了hbase的信息:

image

这样hbase到mysql的数据通道就算打通,问题的关键其实是,如何设计mysql里的行数据,让其转换为hbase中的类数据,因为hbase是列式存储,按照表->行->列簇:列->值的形式来存储。

 

 

 

 

posted @ 2015-07-14 15:48  justinzhang  阅读(4625)  评论(1编辑  收藏  举报