Kettle笔记 6 Span与Kitchen应用
-
Upload
zhangmengzhi -
Category
Documents
-
view
218 -
download
4
Transcript of Kettle笔记 6 Span与Kitchen应用
Kettle 笔记 6 Span 与 Kitchen 应用作者:张孟志日期:2014-03-19
Kettle 笔记 6 Span 与 Kitchen 应用
Kettle 包括三大块:Spoon——转换/任务(transform/job)设计工具 (GUI
方式);Span——转换(trasform)执行器 (命令行方式);Kitchen——任务
(job)执行器 (命令行方式)。前面的文章中已介绍过 Spoon,这里讲讲 Span 与 Kitchen。Spoon 使用 GUI 方式设计转换/任务,并可以执行。但实际的生产环境
(例如,AIX)可能没有 GUI 操作界面,或者 Spoon 界面不能长时间打开,这
就需要命令行方式的支持了。
Span
Span,命令行方式执行的转换(trasform)执行器。1
1.ktr 的运行:运行 transformation 文件是通过 Pan.bat 来运行的。 打 开 cmd 命 令 行 窗 口 , 转 到 Pan.bat 所 在 的 目 录 , 如 F:\kettle4.4\
distrib,然后执行文件的命令为:Pan.bat /file D:\etltest\DB2DB.ktr。使用数据库类型资源库则执行 Pan.bat /rep:"production repository"
/trans:"DB2DB" /dir:/ /user:admin /pass:admin /level:Basic。2.bat 文件运行:如果觉得通过打开命令行输入麻烦,我们可以把它写在
一个批处理文件中。例如: cd F:\kettle4.4\distribPan.bat /file D:\etltest\EtltestTrans.ktr
把这些内容保存在 panKtr.bat 里,通过双击 panKtr.bat 就可以执行 ktr
文件了。在命令行中,重要的是参数的使用。参数后面可以是=也可以是:也可以是
空格,所以下面三句是一样的效果。Pan.bat /rep="production repository" /trans="DB2DB" /dir=/
/user=admin /pass=admin /level=BasicPan.bat /rep:"production repository" /trans:"DB2DB" /dir:/
/user:admin /pass:admin /level:BasicPan.bat /rep "production repository" /trans "DB2DB" /dir / /user
admin /pass admin /level Basic
2
Kitchen
Kitchen,命令行方式执行的任务(job)执行器 。kitchen.bat(类 UNIX 平台为 kitchen.sh),后面可以是-也可以是/然后再
加 options。Options:/rep : Repository name/user : Repository username/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, 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 <NAME>=<VALUE>. For example -param:FOO=bar/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.
而 options 后面可以是=也可以是:也可以是空格:kitchen.bat /file d:\
或者 -file=D:\ 或者/file:\等等。使用案例:1、windows 下的执行方式;
3
建立一个 cmd4windows.dat 的文件,里面写入cd F:\kettle4.4\distribkitchen.bat /norep -file=D:/kettledata/DB2DB.kjb >> kitchen_%date:~0,10%.logexit
保存文件。解释一下上面的语句cd F:\kettle4.4\distrib 这 句 的 含 义 是 跳 转 到 kettle 的 根 目 录 , 因 为
kitchen.bat 文件在根目录下。kitchen.bat /norep -file=D:/kettledata/DB2DB.kjb >> kitchen_
%date:~0,10%.log。含义是,使用 kitchen.bat 命令来执行 job 文件,job 文
件 的 存 放 路 径 是 D:/kettledata/DB2DB.kjb , 并 且 将 执 行 的 结 果 输 出 到
kitchen_%date:~0,10%.log 文件中。2、类 UNIX 下的书写格式:创建 cmd4unix.sh,内容如下:
cd /home/ kettle4.4/distrib ./kitchen.sh -file=/home/etl/ DB2DB.kjb >> /home/etl/log/kettle.log
然后这个文件在 crontab 中去执行。注意:类 UNIX 执行 shell 过程中,
由于类 UNIX 对权限要求很严格,所以 kitchen.sh 必须有可执行的权限。前面
必须加上./,也就是./kitchen.sh 才能执行,否则会提示找不到此命令。4
5