如何在不使用 Sqoop 的情况下自动将 Hive 外部表与 MySQL 表同步? [英] How to automatically sync a Hive external table with a MySQL table without using Sqoop?

查看:40
本文介绍了如何在不使用 Sqoop 的情况下自动将 Hive 外部表与 MySQL 表同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的本​​地机器 (Linux) 中已经有一个 MySQL 表,而且我有一个与 MySQL 表具有相同架构的 Hive 外部表.

I'm already having a MySQL table in my local machine (Linux) itself, and I have a Hive external table with the same schema as the MySQL table.

我想在插入或更新新记录时同步我的 hive 外部表.批量更新对我来说每小时都可以.在不使用 sqoop 的情况下实现相同目标的最佳方法是什么?

I want to sync my hive external table whenever a new record is inserted or updated. Batch update is ok with me to say hourly. What is the best possible approach to achieve the same without using sqoop?

谢谢,顶

推荐答案

没有 scoop,您可以创建表 STORED BY JdbcStorageHandler.项目仓库:https://github.com/qubole/Hive-JDBC-Storage-Handler 它将像往常一样工作,但查询将在 MySQL 上运行.谓词下推将起作用.

Without scoop, you can create table STORED BY JdbcStorageHandler. Project repository: https://github.com/qubole/Hive-JDBC-Storage-Handler It will work as usual hive table, but query will run on MySQL. Predicate pushdown will work.

DROP TABLE HiveTable;
CREATE EXTERNAL TABLE HiveTable(
  id INT,
  id_double DOUBLE,
  names STRING,
  test INT
)
STORED BY 'org.apache.hadoop.hive.jdbc.storagehandler.JdbcStorageHandler'
TBLPROPERTIES (
  "mapred.jdbc.driver.class"="com.mysql.jdbc.Driver",
  "mapred.jdbc.url"="jdbc:mysql://localhost:3306/rstore",
  "mapred.jdbc.username"="root",
  "mapred.jdbc.input.table.name"="JDBCTable",
  "mapred.jdbc.output.table.name"="JDBCTable",
  "mapred.jdbc.password"="",
  "mapred.jdbc.hive.lazy.split"= "false"
);

这篇关于如何在不使用 Sqoop 的情况下自动将 Hive 外部表与 MySQL 表同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆