DataX(MySQL同步数据到Doris)
1.场景
这里演示介绍的使用 Doris 的 Datax 扩展 DorisWriter实现从Mysql数据定时抽取数据导入到Doris数仓表里
2.编译 DorisWriter
这个的扩展的编译可以不在 doris 的 docker 编译环境下进行,本文是在 windows 下的 WLS 下进行编译的
首先从github上拉取源码
git clone https://github.com/apache/incubator-doris.git
进入到incubator-doris/extension/DataX/ 执行编译
首先执行:
sh init_env.sh
这个脚本主要用于构建 DataX 开发环境,他主要进行了以下操作:
- 将 DataX 代码库 clone 到本地。
- 将 doriswriter/ 目录软链到 DataX/doriswriter 目录。
- 在 DataX/pom.xml 文件中添加 <module>doriswriter</module> 模块。
- 将 DataX/core/pom.xml 文件中的 httpclient 版本从 4.5 改为 4.5.13 httpclient v4.5 在处理 307 转发时有bug。
- 这个脚本执行后,开发者就可以进入 DataX/ 目录开始开发或编译了。因为做了软链,所以任何对 DataX/doriswriter 目录中文件的修改,都会反映到 doriswriter/ 目录中,方便开发者提交代码
2.1 开始编译
这里我为了加快编译速度去掉了很多无用的插件:这里直接在Datax目录下的pom.xml里注释掉就行
hbase11xreaderhbase094xreadertsdbreaderoceanbasev10readerodpswriterhdfswriteradswriterocswriteroscarwriteroceanbasev10writer
然后进入到incubator-doris/extension/DataX/ 目录下的 Datax 目录,执行编译
这里我是执行的将 Datax 编译成 tar 包,和官方的编译命令不太一样。
mvn -U clean package assembly:assembly -Dmaven.test.skip=true


编译完成以后,tar 包在 Datax/target 目录下,你可以将这tar包拷贝到你需要的地方,这里我是直接在 datax 执行测试,这里因为的 python 版本是 3.x版本,需要将 bin 目录下的三个文件换成 python 3能之别的版本,这个你可以去下面的地址下载:
https://github.com/WeiYe-Jing...
将下载的三个文件替换 bin 目录下的文件以后,整个编译,安装就完成了
如果你编译不成功也可以从我的百度网盘上下载编译好的包,注意我上边编译去掉的那些插件
链接: https://pan.baidu.com/s/1ObQ4Md0A_0ut4O6-_gPSQg
提取码: 424s
3.数据接入
这个时候我们就可以开始使用 Datax 的doriswriter扩展开始从 Mysql(或者其他数据源)直接将数据抽取出来导入到 Doris 表中了。
3.1 Mysql 数据库准备
下面是我数据库的建表脚本(mysql 8):
CREATE TABLE `order_analysis` (`date` varchar(19) DEFAULT NULL,`user_src` varchar(9) DEFAULT NULL,`order_src` varchar(11) DEFAULT NULL,`order_location` varchar(2) DEFAULT NULL,`new_order` int DEFAULT NULL,`payed_order` int DEFAULT NULL,`pending_order` int DEFAULT NULL,`cancel_order` int DEFAULT NULL,`reject_order` int DEFAULT NULL,`good_order` int DEFAULT NULL,`report_order` int DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
示例数据:
INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-12 00:00:00', '广告二维码', 'Android APP', '上海', 15253, 13210, 684, 1247, 1000, 10824, 862);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-14 00:00:00', '微信朋友圈H5页面', 'iOS APP', '广州', 17134, 11270, 549, 204, 224, 10234, 773);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-17 00:00:00', '地推二维码扫描', 'iOS APP', '北京', 16061, 9418, 1220, 1247, 458, 13877, 749);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-17 00:00:00', '微信朋友圈H5页面', '微信公众号', '武汉', 12749, 11127, 1773, 6, 5, 9874, 678);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-18 00:00:00', '地推二维码扫描', 'iOS APP', '上海', 13086, 15882, 1727, 1764, 1429, 12501, 625);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-18 00:00:00', '微信朋友圈H5页面', 'iOS APP', '武汉', 15129, 15598, 1204, 1295, 1831, 11500, 320);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-19 00:00:00', '地推二维码扫描', 'Android APP', '杭州', 20687, 18526, 1398, 550, 213, 12911, 185);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-19 00:00:00', '应用商店', '微信公众号', '武汉', 12388, 11422, 702, 106, 158, 5820, 474);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-20 00:00:00', '微信朋友圈H5页面', '微信公众号', '上海', 14298, 11682, 1880, 582, 154, 7348, 354);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-21 00:00:00', '地推二维码扫描', 'Android APP', '深圳', 22079, 14333, 5565, 1742, 439, 8246, 211);INSERT INTO `sql12298540`.`order_analysis` (`date`, `user_src`, `order_src`, `order_location`, `new_order`, `payed_order`, `pending_order`, `cancel_order`, `reject_order`, `good_order`, `report_order`) VALUES ('2015-10-22 00:00:00', 'UC浏览器引流', 'iOS APP', '上海', 28968, 18151, 7212, 2373, 1232, 10739, 578);
3.2 doris数据库准备
下面是我上面数据表在doris对应的建表脚本
CREATE TABLE `order_analysis` (`date` datetime DEFAULT NULL,`user_src` varchar(30) DEFAULT NULL,`order_src` varchar(50) DEFAULT NULL,`order_location` varchar(10) DEFAULT NULL,`new_order` int DEFAULT NULL,`payed_order` int DEFAULT NULL,`pending_order` int DEFAULT NULL,`cancel_order` int DEFAULT NULL,`reject_order` int DEFAULT NULL,`good_order` int DEFAULT NULL,`report_order` int DEFAULT NULL) ENGINE=OLAPDUPLICATE KEY(`date`,user_src)COMMENT "OLAP"DISTRIBUTED BY HASH(`user_src`) BUCKETS 1PROPERTIES ("replication_num" = "3","in_memory" = "false","storage_format" = "V2");
3.3 Datax Job JSON文件
创建并编辑datax job任务json文件,并保存到指定目录
{"job": {"setting": {"speed": {"channel": 1},"errorLimit": {"record": 0,"percentage": 0}},"content": [{"reader": {"name": "mysqlreader","parameter": {"username": "root","password": "zh","column": ["date","user_src","order_src","order_location","new_order","payed_order"," pending_order"," cancel_order"," reject_order"," good_order"," report_order" ],"connection": [ { "table": [ "order_analysis" ], "jdbcUrl": [ "jdbc:mysql://localhost:3306/demo" ] } ] }},"writer": {"name": "doriswriter","parameter": {"feLoadUrl": ["fe:8030"],"beLoadUrl": ["be1:8040","be1:8040","be1:8040","be1:8040","be1:8040","be1:8040"],"jdbcUrl": "jdbc:mysql://fe:9030/","database": "test_2","table": "order_analysis","column": ["date","user_src","order_src","order_location","new_order","payed_order"," pending_order"," cancel_order"," reject_order"," good_order"," report_order"],"username": "root","password": "","postSql": [],"preSql": [],"loadProps": {},"maxBatchRows" : 10000,"maxBatchByteSize" : 104857600,"labelPrefix": "datax_doris_writer_demo_","lineDelimiter": "\n"}}}]}}
这块 Mysql reader 使用方式参照:
https://github.com/alibaba/DataX/blob/master/mysqlreader/doc/mysqlreader.md
doriswriter的使用及参数说明:
https://github.com/apache/incubator-doris/blob/master/extension/DataX/doriswriter/doc/doriswriter.md
或者
{
"job": {
"setting": {
"speed": {
"channel": 1
},
"errorLimit": {
"record": 0,
"percentage": 0
}
},
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"username": "root",
"password": "My",
"column": ["id","md5","eid","industry_code","start_date","end_date","is_valid","source","create_time ","update_time","row_update_time","local_row_update_time"],
"connection": [ { "table": [ "t_last_industry_all" ], "jdbcUrl": [ "jdbc:mysql://IP:3306/log" ] } ] }
},
"writer": {
"name": "doriswriter",
"parameter": {
"feLoadUrl": ["IP:8030"],
"beLoadUrl": ["IP:8040"],
"jdbcUrl": "jdbc:mysql://IP:9030/",
"database": "mysqltodoris",
"table": "t_last",
"column": ["id","md5","eid","industry_code","start_date","end_date","is_valid","source","create_time ","update_time","row_update_time","local_row_update_time"],
"username": "root",
"password": "123456",
"postSql": [],
"preSql": [],
"loadProps": {
},
"maxBatchRows" : 300000,
"maxBatchByteSize" : 20971520
}
}
}
]
}
}
4.执行Datax数据导入任务
python bin/datax.py doris.json
然后就可以看到执行结果:

再去 Doris 数据库中查看你的表,数据就已经导入进去了,任务执行结束
相关文章:
DataX(MySQL同步数据到Doris)
1.场景 这里演示介绍的使用 Doris 的 Datax 扩展 DorisWriter实现从Mysql数据定时抽取数据导入到Doris数仓表里 2.编译 DorisWriter 这个的扩展的编译可以不在 doris 的 docker 编译环境下进行,本文是在 windows 下的 WLS 下进行编译的 首先从github上拉取源码 …...
sql server服务无法启动怎么办?如何正常启动?
sql server软件是一款关系型数据库管理系统。具有使用方便可伸缩性好与相关软件集成程度高等优点。并且有些应用软件使用过程中是需要sql server数据库的后台支持的,我们在数据编程操作时经常会使用这款编程软件,在编程时系统有时会提示sql server服务无…...
SpringMVC实现文件上传和下载
目录 前言 一. SpringMVC文件上传 1. 配置多功能视图解析器 2. 前端代码中,将表单标记为多功能表单 3. 后端利用MultipartFile 接口,接收前端传递到后台的文件 4. 文件上传示例 1. 相关依赖: 2. 逆向生成对应的类 3. 后端代码…...
Your build is currently configured to use Java 20.0.2 and Gradle 8.0
jdk 版本不适配 下载jdk17 https://www.oracle.com/java/technologies/downloads/#jdk17 参考 JDK17的下载安装与配置(详细教程)_keyila798的博客-CSDN博客...
栈 之 如何实现一个栈
前言 栈最鲜明的特点就是后进先出,一碟盘子就是类似这样的结构,最晚放上去的,可以最先拿出来。本文将介绍的是如何自己实现一个栈结构。 栈的操作 栈是一种先进后出(Last-In-First-Out, LIFO)的数据结构,…...
uni-app:自带的消息提示被遮挡的解决办法(自定义消息提示框)
效果: 代码: 1、在最外层或者根组件的模板中添加一个容器元素,用于显示提示消息。例如: <div class"toast-container" v-if"toastMessage"><div class"toast-content">{{ toastMessa…...
PHP设备检验系统Dreamweaver开发mysql数据库web结构php编程计算机网页代码
一、源码特点 PHP设备检验系统是一套完善的web设计系统,对理解php编程开发语言有帮助,系统具有完整的源代码和数据库,系统主要采用B/S模式开发。 下载地址 https://download.csdn.net/download/qq_41221322/88306259 php设备检验系统1 …...
Windows 可以使用以下快捷键打开终端(命令提示符)
Windows 可以使用以下快捷键打开终端(命令提示符) 使用快捷键 Win R 打开 “运行” 对话框,然后输入 “cmd” 并按下 Enter 键。这将打开默认的命令提示符窗口。 使用快捷键 Ctrl Shift Esc 打开任务管理器,然后在 “文件” …...
Netty编程面试题
1.Netty 是什么? Netty是 一个异步事件驱动的网络应用程序框架,用于快速开发可维护的高性能协议服务器和客户端。Netty是基于nio的,它封装了jdk的nio,让我们使用起来更加方法灵活。 2.Netty 的特点是什么? 高并发&a…...
math_review
topics mathmatics supreme and optimumNorm and Linear producttopology of R*Continuious Function supreme and optimum Def 1: 非空有界集合必有上确界 common norm (1) x ∈ \in ∈ Rn, ||x||2 x 1 2 x 2 2 . . . x n 2 \sqrt {x_1^2x_2^2...x_n^2} x12x22.…...
肖sir__设计测试用例方法之场景法04_(黑盒测试)
设计测试用例方法之场景法 1、场景法主要是针对测试场景类型的,顾也称场景流程分析法。 2、流程分析是将软件系统的某个流程看成路径,用路径分析的方法来设计测试用例。根据流程的顺序依次进行组合,使得流程的各个分支能走到。 举例说明&…...
plt函数显示图片 在图片上画边界框 边界框坐标转换
一.读取图片并显示图片 %matplotlib inline import torch from d2l import torch as d2l读取图片 image_path ../data/images/cat_dog_new.jpg # 创建画板 figure d2l.set_figsize() image d2l.plt.imread(image_path) d2l.plt.imshow(image);二.给出一个(x左上角,y左上角,…...
运行期获得文件名和行号
探索动态日志模块的实现 最初的目标是创建一个通用的日志模块, 它具有基本的日志输出功能并支持重定向. 这样, 如果需要更换日志模块, 可以轻松实现. 最初的构想是通过函数重定向, 即使用 dlsym 来重定向所有函数以实现打印功能. 然而, 这种方法引发了一个问题, 即无法正确获…...
数组操作UNIAPP
字符串转数组 let string "12345,56789" string.split(,) // [12345,56789] 数组转字符串 let array ["123","456"] array.join(",") // "123,456" 数组元素删除 let array [123,456] // 删除起始下标为1࿰…...
MySQL——无法打开MySQL8.0软件安装包或者安装过程中失败,如何解决?
在运行MySQL8.0软件安装包之前,用户需要确保系统中已经安装了.Net Framework相关软件,如果缺少此软件,将不能正常地安装MySQL8.0软件。 解决方案:到这个地址 https://www.microsoft.com/en-us/download/details.aspx?id42642…...
DB2存储过程如何编写和执行
db2执行文件参数: -t 表示语句使用默认的语句终结符——分号; -v 表示使用冗长模式,这样 DB2 会显示每一条正在执行命令的信息; -f 表示其后就是脚本文件; -z表示其后的信息记录文件用于记录屏幕的输出&am…...
SpringBoot + FFmpeg实现一个简单的M3U8切片转码系统
简介 在本文中,我们将使用SpringBoot和FFmpeg来实现一个简单的M3U8切片转码系统。M3U8是一种常用的视频流媒体播放列表格式,而FFmpeg则是一个强大的音视频处理工具。 技术栈 SpringBoot:一个基于Spring框架的快速开发平台。FFmpeg…...
SpringCloud(35):Nacos 服务发现快速入门
本小节,我们将演示如何使用Spring Cloud Alibaba Nacos Discovery为Spring cloud 应用程序与 Nacos 的无缝集成。 通过一些原生的spring cloud注解,我们可以快速来实现Spring cloud微服务的服务发现机制,并使用Nacos Server作为服务发现中心,统一管理所有微服务。 1 Spring…...
OSPF实验:配置与检测全网互通
文章目录 一、实验背景与目的二、实验拓扑三、实验需求四、实验解法1. 配置 IP 地址2. 按照图示分区域配置 OSPF ,实现全网互通3. 检查是否全网互通 摘要: 本篇文章介绍了一个 OSPF(Open Shortest Path First)实验,旨在…...
常见的五种设计模式
https://www.runoob.com/design-pattern/factory-pattern.html 单例模式 **意图:**保证一个类仅有一个实例,并提供一个访问它的全局访问点。 **主要解决:**一个全局使用的类频繁地创建与销毁。 **何时使用:**当您想控制实例数目…...
ToyKind-World:基于Python的ECS架构多智能体模拟框架构建指南
1. 项目概述与核心价值最近在GitHub上看到一个挺有意思的项目,叫“ToyKind-World”。光看这个名字,你可能会觉得有点抽象,是玩具世界?还是某种模拟器?点进去一看,发现它其实是一个用Python构建的、高度可配…...
硬件调试利器:全面掌握AMD Ryzen处理器系统性能优化实战技巧
硬件调试利器:全面掌握AMD Ryzen处理器系统性能优化实战技巧 【免费下载链接】SMUDebugTool A dedicated tool to help write/read various parameters of Ryzen-based systems, such as manual overclock, SMU, PCI, CPUID, MSR and Power Table. 项目地址: http…...
终极指南:PersistentWindows如何彻底解决Windows多显示器窗口管理难题
终极指南:PersistentWindows如何彻底解决Windows多显示器窗口管理难题 【免费下载链接】PersistentWindows fork of http://www.ninjacrab.com/persistent-windows/ with windows 10 update 项目地址: https://gitcode.com/gh_mirrors/pe/PersistentWindows …...
KMS_VL_ALL_AIO智能激活脚本:5分钟搞定Windows和Office永久激活的终极方案
KMS_VL_ALL_AIO智能激活脚本:5分钟搞定Windows和Office永久激活的终极方案 【免费下载链接】KMS_VL_ALL_AIO Smart Activation Script 项目地址: https://gitcode.com/gh_mirrors/km/KMS_VL_ALL_AIO 还在为Windows系统激活和Office办公软件授权而烦恼吗&…...
【模块化设计-14】深入解析 RT-Thread syswatch 系统监控模块:保障系统稳定的核心卫士
在嵌入式系统开发中,系统的稳定性是重中之重。RT-Thread 提供的 syswatch(系统监控)模块,专为解决线程异常阻塞、保障系统持续运行设计。本文将从模块设计理念、核心功能、配置项、工作流程到实际测试,全方位解析 sysw…...
绝对不要让两根线在同一个交换机上连成一个圈。 为什么 形成一个环就会网络风暴?
为了让你彻底理解“为什么环路会导致风暴”,我们把网络连接看作一个“数字信息的传递游戏”。 1. 关键前提:交换机不懂“记忆” 交换机(特别是普通的傻瓜交换机)在转发广播消息时,它不具备判断“这条消息我刚才是不是发过”的能力。它只认一个逻辑: “只要是从端口A进来…...
用STM32F103的USART1和PC串口助手玩“聊天室”:一个完整的数据收发项目实战
STM32F103串口聊天室:从零构建双向交互式终端 项目背景与核心价值 在嵌入式开发领域,串口通信如同"Hello World"般基础却又至关重要。传统教学往往止步于数据收发演示,而本项目将打破常规——用STM32F103的USART1构建一个具有完整交…...
3PEAK思瑞浦 TPA1811-S5TR SOT23-5 精密运放
特性 供电电压:4伏至30伏 低功耗:在25C时为55A(典型值) 低偏置电压:8V在25C(最大值) 零漂:0.01V/C 轨到轨输出 增益带宽积:500kHz 斜率:0.3V/us...
别再手动找数据了!用SPSS的‘添加变量’功能,5分钟搞定跨表数据匹配
SPSS数据合并实战:用‘添加变量’功能高效匹配跨表数据 在数据分析的日常工作中,我们常常遇到这样的场景:市场部门提供了一份客户基本信息表,销售团队则提交了季度消费记录,两份数据都包含客户ID字段但其他信息分散在不…...
如何用Mermaid CLI彻底改变技术文档工作流
如何用Mermaid CLI彻底改变技术文档工作流 【免费下载链接】mermaid-cli Command line tool for the Mermaid library 项目地址: https://gitcode.com/gh_mirrors/me/mermaid-cli 在技术文档编写过程中,图表创建往往是效率瓶颈。传统绘图工具需要手动拖拽、反…...
