Skip to content

Latest commit

 

History

History
202 lines (165 loc) · 8.36 KB

README_zh.md

File metadata and controls

202 lines (165 loc) · 8.36 KB

Addax Logo

Addax 是一个支持主流数据库的通用数据采集工具

使用文档 详细描述了如何安装部署和每个采集插件的使用方法

release version Maven Package

该项目原始代码来自阿里开源的 DataX ,但经过了大幅修改,详细情况可参考与DataX的主要区别

支持的数据库一览表

Addax 支持超过 20 种关系型和非关系型数据库,通过简单的配置,还可以快速增加更多的数据源支持。

supported databases

快速开始

使用 Docker 镜像

docker pull wgzhao/addax:latest
docker run -ti --rm --name addax wgzhao/addax:latest /opt/addax/bin/addax.sh /opt/addax/job/job.json

如果你只需要基本的插件,可以使用带有 -lite 结尾的镜像,它体积更小。

docker pull wgzhao/addax:4.0.12-lite
docker run -ti --rm --name addax wgzhao/addax:4.0.12-lite /opt/addax/bin/addax.sh /opt/addax/job/job.json

使用一键安装脚本

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/wgzhao/Addax/master/install.sh)"

上述脚本会将 Addax 安装到预设的目录( 对于 macOS Intel 而言,目录为 /usr/local, Apple Silicon 以及 Linux 系统则为 /opt/addax)

编译及打包

git clone https://github.com/wgzhao/addax.git addax
cd addax
mvn clean package -pl '!:addax-docs'
mvn package assembly:single

编译打包成功后,会在项目目录的target/addax 目录下创建一个 addax-<version>的 文件夹,其中 <version> 表示版本。

开始第一个任务

job 子目录包含了大量的任务样本,其中 job.json 可以作为冒烟测试,执行如下

bin/addax.sh job/job.json

上述命令的输出大致如下:

点击展开
$bin/addax.sh job/job.json

 ___      _     _
 / _ \    | |   | |
/ /_\ \ __| | __| | __ ___  __
|  _  |/ _` |/ _` |/ _` \ \/ /
| | | | (_| | (_| | (_| |>  <
\_| |_/\__,_|\__,_|\__,_/_/\_\

:: Addax version ::    (v4.0.13-SNAPSHOT)

2023-05-14 11:43:38.040 [        main] INFO  VMInfo               - VMInfo# operatingSystem class => sun.management.OperatingSystemImpl
2023-05-14 11:43:38.062 [        main] INFO  Engine               -
{
	"setting":{
		"speed":{
			"byte":-1,
			"channel":1,
			"record":-1
		}
	},
	"content":{
		"reader":{
			"name":"streamreader",
			"parameter":{
				"sliceRecordCount":10,
				"column":[
					{
						"value":"addax",
						"type":"string"
					},
					{
						"value":19890604,
						"type":"long"
					},
					{
						"value":"1989-06-04 11:22:33 123456",
						"type":"date",
						"dateFormat":"yyyy-MM-dd HH:mm:ss SSSSSS"
					},
					{
						"value":true,
						"type":"bool"
					},
					{
						"value":"test",
						"type":"bytes"
					}
				]
			}
		},
		"writer":{
			"name":"streamwriter",
			"parameter":{
				"print":true,
				"encoding":"UTF-8"
			}
		}
	}
}

2023-05-14 11:43:38.092 [        main] INFO  JobContainer         - The jobContainer begins to process the job.
2023-05-14 11:43:38.107 [       job-0] INFO  JobContainer         - The Reader.Job [streamreader] perform prepare work .
2023-05-14 11:43:38.107 [       job-0] INFO  JobContainer         - The Writer.Job [streamwriter] perform prepare work .
2023-05-14 11:43:38.108 [       job-0] INFO  JobContainer         - Job set Channel-Number to 1 channel(s).
2023-05-14 11:43:38.108 [       job-0] INFO  JobContainer         - The Reader.Job [streamreader] is divided into [1] task(s).
2023-05-14 11:43:38.108 [       job-0] INFO  JobContainer         - The Writer.Job [streamwriter] is divided into [1] task(s).
2023-05-14 11:43:38.130 [       job-0] INFO  JobContainer         - The Scheduler launches [1] taskGroup(s).
2023-05-14 11:43:38.138 [ taskGroup-0] INFO  TaskGroupContainer   - The taskGroupId=[0] started [1] channels for [1] tasks.
2023-05-14 11:43:38.141 [ taskGroup-0] INFO  Channel              - The Channel set byte_speed_limit to -1, No bps activated.
2023-05-14 11:43:38.141 [ taskGroup-0] INFO  Channel              - The Channel set record_speed_limit to -1, No tps activated.
addax  19890604	1989-06-04 11:24:36	true	test
addax  19890604	1989-06-04 11:24:36	true	test
addax  19890604	1989-06-04 11:24:36	true	test
addax  19890604	1989-06-04 11:24:36	true	test
addax  19890604	1989-06-04 11:24:36	true	test
addax  19890604	1989-06-04 11:24:36	true	test
addax  19890604	1989-06-04 11:24:36	true	test
addax  19890604	1989-06-04 11:24:36	true	test
addax  19890604	1989-06-04 11:24:36	true	test
addax  19890604	1989-06-04 11:24:36	true	test
2023-05-14 11:43:41.157 [       job-0] INFO  AbstractScheduler    - The scheduler has completed all tasks.
2023-05-14 11:43:41.158 [       job-0] INFO  JobContainer         - The Writer.Job [streamwriter] perform post work.
2023-05-14 11:43:41.159 [       job-0] INFO  JobContainer         - The Reader.Job [streamreader] perform post work.
2023-05-14 11:43:41.162 [       job-0] INFO  StandAloneJobContainerCommunicator - Total 10 records, 260 bytes | Speed 86B/s, 3 records/s | Error 0 records, 0 bytes |  All Task WaitWriterTime 0.000s |  All Task WaitReaderTime 0.000s | Percentage 100.00%
2023-05-14 11:43:41.596 [       job-0] INFO  JobContainer         -
Job start  at             : 2023-05-14 11:43:38
Job end    at             : 2023-05-14 11:43:41
Job took secs             :                  3ss
Average   bps             :               86B/s
Average   rps             :              3rec/s
Number of rec             :                  10
Failed record             :                   0

这里 以及文档中心 提供了大量作业配置样例

运行要求

  • JDK 1.8+
  • Python 2.7+ / Python 3.7+ (Windows)

文档

代码风格

建议使用 IntelliJ 作为开发 IDE。项目的代码风格模板可以在codestyle资源库中找到,还有我们的一般编程和Java指南。除了这些之外,你还应该遵守以下几点。

  • 在文档源文件中按字母顺序排列章节(包括目录文件和其他常规文档文件)。一般来说,如果周围的代码中已经存在这样的排序,就按字母顺序排列方法/变量/部分。
  • 在适当的时候,使用Java 8的流API。然而,请注意,流的实现并不是很好,所以避免在内循环或其他对性能敏感的部分使用它。
  • 在抛出异常时对错误进行分类。例如,AddaxException 使用错误代码和错误消息作为参数,AddaxException(REQUIRE_VALUE, "lack of required item")。这种分类可以让你生成报告,这样你就可以监控各种故障。
  • 确保所有文件都有适当的许可证头;你可以通过运行mvn license:format生成许可证。
  • 考虑使用字符串格式化(使用JavaFormatter类的printf风格):format("Session property %s is invalid: %s", name, value)(注意,format()应该总是静态导入)。有时,如果你只需要附加一些东西,可以考虑使用+运算符。
  • 除了琐碎的表达式,避免使用三元操作符。
  • 如果有涵盖你的情况的断言,就使用Airlift的Assertions类,而不是手工写断言。
  • 在编写Git提交信息时,请遵循这些[指南](https://chris.beams.io/posts/git-commit/)。

版本兼容性说明

  • 从 4.0.0 版本开始,启用新的项目名称 Addax, 因此它和以前的版本均不兼容
  • 从 3.2.1 版本开始,包类名已经更改,因此不再兼容 3.1.x 版本

代码授权许可

该软件在遵守 Apache license 下可自由免费使用

特别感谢

特别感谢 JetBrains 对本项目提供开发工具赞助