kettle&kettle-schedule的部署
概述
Kettle是一款国外开源的ETL工具,纯java编写,可以在Window、Linux、Unix上运行,数据抽取高效稳定。Kettle 中文名称叫水壶,该项目的主程序员MATT 希望把各种数据放到一个壶里,然后以一种指定的格式流出。Kettle这个ETL工具集,它允许你管理来自不同数据库的数据,通过提供一个图形化的用户环境来描述你想做什么,而不是你想怎么做。Kettle中有两种脚本文件,transformation和job,transformation完成针对数据的基础转换,job则完成整个工作流的控制。
准备工作
官方文档
https://community.hitachivantara.com/s/article/data-integration-kettle
开源网址
https://github.com/pentaho/pentaho-kettle
下载地址
https://sourceforge.net/projects/pentaho/files/Data%20Integration/
安装部署
centos下部署kettle
依赖环境
- jdk1.8
安装步骤
- 因为Kettle不需要编译和安装,直接把包传到服务器然后解压缩就可以了。
[root@test local]# unzip pdi-ce-9.1.0.0-324.zip
- 给脚本赋予可执行权限
[root@test local]# chmod +x ./data-integration/*.sh
- 安装依赖
[root@test local]# yum install webkitgtk
[ - 测试安装是否成功
在kettle的data-integration目录中执行kitchen.sh文件,若出现帮助信息,证明安装成功
./kitchen.sh
./kitchen.sh
Options:
-rep = Repository name
-user = Repository username
-trustuser = !Kitchen.ComdLine.RepUsername!
-pass = Repository password
-job = The name of the job to launch
-dir = The directory (dont forget the leading /)
-file = The filename (Job XML) to launch
-level = The logging level (Basic, Detailed, Debug, Rowlevel, Error, Minimal, Nothing)
-logfile = The logging file to write to
-listdir = List the directories in the repository
-listjobs = List the jobs in the specified directory
-listrep = List the available repositories
-norep = Do not log into the repository
-version = show the version, revision and build date
-param = Set a named parameter =. For example -param:FILE=customers.csv
-listparam = List information concerning the defined parameters in the specified job.
-export = Exports all linked resources of the specified job. The argument is the name of a ZIP file.
-custom = Set a custom plugin specific option as a String value in the job using =, for example: -custom:COLOR=Red
-maxloglines = The maximum number of log lines that are kept internally by Kettle. Set to 0 to keep all rows (default)
-maxlogtimeout = The maximum age (in minutes) of a log line while being kept internally by Kettle. Set to 0 to keep all rows indefinitely (default)
- 执行转换:
例子:/opt/kettle/data-integration/pan.sh -file /opt/kettle/ktr/test/tset.ktr
- 执行资源库中的转换:
例子:sh pan.sh -rep=initech_pdi_repo -user=pgibbons -pass=lumburghsux -trans=TPS_reports_2011
- 执行job:
例子:/opt/kettle/data-integration/ kitchen.sh -file /opt/kettle/ktr/test/tset.kjb
windows下部署kettle
依赖环境
- jdk1.8
安装步骤
- 解压pdi-ce-9.1.0.0-324.zip
- 点击data-integration\Spoon.bat,启动kettle
centos下部署kettle-scheduler
kettle-scheduler下载地址
链接: https://pan.baidu.com/s/1CiQjRhssbPblINf3mKzlhw 提取码: 8f2p
依赖环境
- jdk1.8
- tomcat
- mysql
安装步骤
- 在mysql上创建数据库kettle-scheduler,执行kettle-scheduler.sql
- 上传kettle-scheduler.war到centos
- 基于tomcat8创建kettle-scheduler.war的docker镜像
- 启动kettle-scheduler镜像
docker run --privileged=true -v /home/soft/kettle/data-integration/plugins:/usr/local/tomcat8.5/bin/plugins -v /home/soft/kettle/data-integration/system:/usr/local/tomcat8.5/bin/system -v /home/soft/kettle/data-integration/simple-jndi:/usr/local/tomcat8.5/bin/simple-jndi -d -p 8080:8080 kettle-scheduler:latest
5.使用admin/admin登录系统
centos下使用kettle资源库
- 在windows中创建资源库
资源库建好后会生成文件 C:\Users\Administrator.kettle\repositories.xml - 在linux中设置环境变量KETTLE_HOME
修改 /etc/profile 文件,在文件末尾加上如下两行代码
KETTLE_HOME=/home/soft/kettle/data-integration
export KETTLE_HOME - 上传.kettle\repositories.xml文件到linux
- linux中成功执行过kettle任务的话,会生成 ${KETTLE_HOME}/.kettle目录,直接将windows中.kettle\repositories.xml上传至 ${KETTLE_HOME}/.kettle目录。
- linux未执行过kettle任务的话,则需要手动创建 ${KETTLE_HOME}/.kettle目录再上传repositories.xml文件。
注意事项
数据库驱动包
连接mysql5.7需要在data-integration\lib\目录下放置mysql-connector-java-5.1.48.jar,连接oracle等其他数据库也需要放入对应版本的驱动包。
kettle资源库共享
数据资源库使用的数据库以及windows下使用spoon开发的转换和作业使用的数据库都需要当前运行kettle的服务器能够访问