All Projects → thestyleofme → common-datax

thestyleofme / common-datax

Licence: other
基于DataX的通用数据同步微服务,一个Restful接口搞定所有通用数据同步

Programming Languages

java
68154 projects - #9 most used programming language
FreeMarker
481 projects

Projects that are alternatives of or similar to common-datax

dragonshard
Java server framework based on springboot2
Stars: ✭ 15 (-70.59%)
Mutual labels:  mybatis-plus, springboot2, dynamic-datasource
smart-cloud
基于springboot && springcloud的脚手架,支持服务合并部署与拆分部署、接口加解密签名、日志数据 脱敏、接口数据mock、接口文档自动生成、请求幂等校验、接口日志&&sql日志切面打印、分表分库分布式事务、国际化语言等
Stars: ✭ 167 (+227.45%)
Mutual labels:  mybatis, mybatis-plus, dynamic-datasource
springboot-chapter
🚀Spring Boot 2.0基础教程。主流框架整合,实践学习案例。
Stars: ✭ 23 (-54.9%)
Mutual labels:  freemarker, mybatis, mybatis-plus
Addax
Addax is an open source universal ETL tool that supports most of those RDBMS and NoSQLs on the planet, helping you transfer data from any one place to another.
Stars: ✭ 615 (+1105.88%)
Mutual labels:  hive, datax
ETL-Starter-Kit
📁 Extract, Transform, Load (ETL) 👷 refers to a process in database usage and especially in data warehousing. This repository contains a starter kit featuring ETL related work.
Stars: ✭ 21 (-58.82%)
Mutual labels:  hive, azkaban
TitanDataOperationSystem
最好的大数据项目。《Titan数据运营系统》,本项目是一个全栈闭环系统,我们有用作数据可视化的web系统,然后用flume-kafaka-flume进行日志的读取,在hive设计数仓,编写spark代码进行数仓表之间的转化以及ads层表到mysql的迁移,使用azkaban进行定时任务的调度,使用技术:Java/Scala语言,Hadoop、Spark、Hive、Kafka、Flume、Azkaban、SpringBoot,Bootstrap, Echart等;
Stars: ✭ 62 (+21.57%)
Mutual labels:  hive, azkaban
Jeeplatform
一款企业信息化开发基础平台,拟集成OA(办公自动化)、CMS(内容管理系统)等企业系统的通用业务功能 JeePlatform项目是一款以SpringBoot为核心框架,集ORM框架Mybatis,Web层框架SpringMVC和多种开源组件框架而成的一款通用基础平台,代码已经捐赠给开源中国社区
Stars: ✭ 1,285 (+2419.61%)
Mutual labels:  freemarker, mybatis
blog-springboot
My blog with springboot framework
Stars: ✭ 14 (-72.55%)
Mutual labels:  freemarker, mybatis
God Of Bigdata
专注大数据学习面试,大数据成神之路开启。Flink/Spark/Hadoop/Hbase/Hive...
Stars: ✭ 6,008 (+11680.39%)
Mutual labels:  hive, azkaban
huanhuan-blog
一个java版本freemarker的小博客项目
Stars: ✭ 19 (-62.75%)
Mutual labels:  freemarker, mybatis
DataX-src
DataX 是异构数据广泛使用的离线数据同步工具/平台,实现包括 MySQL、Oracle、SqlServer、Postgre、HDFS、Hive、ADS、HBase、OTS、ODPS 等各种异构数据源之间高效的数据同步功能。
Stars: ✭ 21 (-58.82%)
Mutual labels:  hive, datax
Easyadmin
简易的java后台管理框架,基于SpringBoot+FreeMark+ace admin+mysql
Stars: ✭ 169 (+231.37%)
Mutual labels:  freemarker, mybatis
Spring Boot Examples
个人学习 SpringBoot2.x 写的一些示例程序,目前正在持续更新中.....
Stars: ✭ 159 (+211.76%)
Mutual labels:  freemarker, mybatis
litemall-dw
基于开源Litemall电商项目的大数据项目,包含前端埋点(openresty+lua)、后端埋点;数据仓库(五层)、实时计算和用户画像。大数据平台采用CDH6.3.2(已使用vagrant+ansible脚本化),同时也包含了Azkaban的workflow。
Stars: ✭ 36 (-29.41%)
Mutual labels:  hive, azkaban
Lovinghome Real Estate Platform
⚡️基于springboot+MyBatis+FreeMarker+redis+nginx+Echarts+druid等技术的JavaWeb项目------恋家房产平台(采用B/S架构,项目包含前后台,分为前台展示系统及后台管理系统。前台系统包含首页门户、登录注册、房产推荐、房产详情、热门房产、房产及小区搜索、经纪人列表及经纪机构创建、创建房产、房产百科、地图找房、用户个人中心、房产评论、房产打分等模块。 后台管理系统包含房产信息管理、用户管理、管理员管理、小区信息管理、博客管理、评论管理、经纪人管理、系统统计与多种图表展示、数据报表导入导出等模块。系统介绍及详细功能点、技术点见项目内文档描述)
Stars: ✭ 140 (+174.51%)
Mutual labels:  freemarker, mybatis
Bigdata Notes
大数据入门指南 ⭐
Stars: ✭ 10,991 (+21450.98%)
Mutual labels:  hive, azkaban
MiniDao
An powerful enhanced toolkit of SpringJdbc for simplify development
Stars: ✭ 200 (+292.16%)
Mutual labels:  mybatis, mybatis-plus
zealsay backend
Spring Boot 快速开发脚手架,以博客论坛为示例展示,后台主要使用Spring Boot,Spring Security,Mybatis-plus,redis token,前端使用Nuxt,Vue,Vuex,Vue-Router,Vuetify。
Stars: ✭ 58 (+13.73%)
Mutual labels:  mybatis, mybatis-plus
springboot-learning-demo
springboot学习示例
Stars: ✭ 17 (-66.67%)
Mutual labels:  freemarker, mybatis
V5cmsjava
Spring+SpringMVC+Spring Data JPA+FreeMarker+Bootstarp(master分支),mybatis分支ORM使用的是MyBatis。
Stars: ✭ 29 (-43.14%)
Mutual labels:  freemarker, mybatis

DEPRECATED!!!不在维护!!!

已优化重构并迁移至datax-admin

datax-admin传送门


common-datax

基于阿里DataX开发一个通用导数的微服务,可以开发前台页面,根据reader和writer自动进行数据同步

本项目只限于同步数据源量很少的时候使用,若是数据源很多的情况,请参考下面的设计思路


由于阿里DataX有一些缺点:

  • 不够自动化
  • 需要手写json
  • 需要手动运行job

搬砖的时间很宝贵,所以:

  • 提供通用数据抽取restful接口
  • HDFS自动创库创表创分区
  • 利用freemarker模板自动创建json文件
  • 自动python执行job
  • 集成Azkaban进行调度管理

例如:mysql到hive

选择mysql需要同步的表、字段等信息,输入导入到hive的库表分区等信息,不需提前在hive进行创库创表创分区,自动根据要导的mysql表以及字段类型进行创建hive库表分区,然后利用freemarker去生成json文件,使用Azkaban进行调度执行,自动创建项目、上传zip、执行流一系列操作,可在Azkaban页面进行查看。当然也提供了可直接远程python执行。

上述设计使用策略实现,只有几个数据源之间相互同步还好,如hive/mysql/oracle三个,策略模式还是不错的,但若是数据源很多的时候,策略模式不是很方便,写的类也成幂次方增加,为了优化开发易维护,只有放弃策略模式,用以下方式,代码我就不推了,有点懒。

设计思路(跟策略模式对比即目前的项目) 后续有时间我推一下新版的设计实现:

  • 摒弃freemarker,DTO直接使用Map映射,Map里传reader、writer、setting的信息
  • 定义WriterService/ReaderService接口,该接口方法处理reader/writer部分的json信息
  • 一个reader/一个writer对应一个类进行处理(使用反射),专门生成reader/writer部分的json,最后加上setting部分生成成一个完整DataX的Job类

伪代码

DataxSyncDTO
/**
* 同步信息,包含以下三个key
* @see BaseReader 子类
* @see BaseWriter 子类
* @see Job.Setting 
*/
private Map<String, Object> sync;

ReaderService/WriterService
如可以实现MysqlReaderService/MysqlWriterService
public interface ReaderService<T extends BaseReader> {
     /**
     * 解析reader
     *
     * @param tenantId     租户id
     * @param datasourceId 数据源ID
     * @param reader       json
     * @return json
     */
    String parseReader(Long tenantId, Long datasourceId, String reader);
}

根据名称使用反射找到具体的实现类,序列化出具体的reader/writer部分json

最后组合成datax的json

最终的datax json映射类
public class Job {
    private Setting setting;
    private List<Content> content;
    public static class Setting {
        private Speed speed;
        private ErrorLimit errorLimit;
    }
    public static class Speed {
        private String record; 
        private String channel;
        private String speedByte;
    }
    public static class ErrorLimit {
        private String record;
        private String percentage;
    }
    public static class Content {
        private Reader reader;
        private Writer writer;
    }
    public static class Reader {
        private String name;
        private Object parameter;
    }
    public static class Writer {
        private String name;
        private Object parameter;
    }
}

done:

  • oracle、mysql、hive两两互相同步
  • 本地csv文件导入到hive,支持分区
  • 使用Azkaban去执行python脚本进行抽数
  • 一个restful接口,可以实现所有的同步

todo:

  • 创表记录导数的历史
  • json文件下载
  • Azkaban定时调度等
  • 数据源,mysql、hive的数据源维护,下次要导数时,不用传那么多服务器信息
  • groovy脚本

说明

修改配置文件application-template.yml

  1. 数据源修改,根据自己项目情况进行调整

不要修改数据源名称,只需修改为自己的username、password、url即可

  1. datax的信息修改
# 这里只要是路径,后面都加上/
datax:
  home: ${DATAX_HOME:/usr/local/DataX/target/datax/datax/}
  host: ${DATAX_HOST:datax01}
  port: 22
  # 要操作hdfs,用户要有权限
  username: ${DATAX_USERNAME:hadoop}
  password: ${DATAX_PASSWORD:hadoop}
  uploadDicPath: ${DATAX_JSON_FILE_HOME:/home/hadoop/datax/}
  1. azkaban的url, 也可以不用azkaban,本项目默认使用azkaban进行调度
azkaban:
  host: ${AZKABAN_HOST:http://192.168.43.221:8081}
  username: ${AZKABAN_USERNAME:azkaban}
  password: ${AZKABAN_PASSWORD:azkaban}

指定启动配置

可以重命名application-template.yml为application-dev.yml,application.yml指定生效的配置文件

spring:
  profiles:
    active: ${SPRING_PROFILES_ACTIVE:dev}

swagger地址

http://localhost:10024/swagger-ui.html


使用示例

这里的mysql2Hive表明是mysql同步到hive,可以更换为mysql2Mysql、hive2Hive、oracle2Hive等,驼峰命名。

1. mysql2hive example

这里是mysql数据导入到hive,支持分区

POST http://localhost:10024//v1/datax-syncs/execute

Body示例

{
	"syncName": "mysql2hive_test_0625_where",
	"syncDescription": "mysql2hive_test_0625_where",
	"sourceDatasourceType": "mysql",
	"sourceDatasourceId": "1",
	"writeDatasourceType": "hadoop_hive_2",
	"writeDatasourceId": "1",
	"jsonFileName": "mysql2hive_test_0625_where.json",
	"mysql2Hive": {
		"setting": {
			"speed": {
				"channel": 3
			},
			"errorLimit": {
				"record": 0,
				"percentage": 0.02
			}
		},
		"reader": {
			"splitPk": "",
			"username": "root",
            "password": "root",
			"column": [
				"id",
				"username"
			],
			"connection": [{
				"table": [
					"userinfo"
				],
				"jdbcUrl": [
					"jdbc:mysql://hadoop04:3306/common_datax?useUnicode=true&characterEncoding=utf-8&useSSL=false"
				]
			}],
			"where": "2 > 1"
		},
		"writer": {
            "defaultFS": "hdfs://hadoop04:9000",
            "fileType": "text",
            "path": "/user/hive/warehouse/test.db/userinfo",
            "fileName": "userinfo",
            "column": [
                {
                "name": "id",
                "type": "BIGINT"
                },
                {
                "name": "username",
                "type": "STRING"
                }
            ],
            "writeMode": "append",
            "fieldDelimiter": "\t",
            "compress": "",
            "hadoopConfig": {
            },
            "haveKerberos": false,
            "kerberosKeytabFilePath": "",
            "kerberosPrincipal": ""
		}
	}
}

path可以更换为分区的hdfs路径,不需提前创建分区,自动创建,例如:

"path": "/user/hive/warehouse/test.db/userinfo_dts/dt1=A1/dt2=B2"

这里会在hive里自动创建userinfo_dts分区表,有两个分区字段,然后会将数据导入到这里的dt1=A1,dt2=B2分区下

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].