Linux下用命令来执行kettle文件资源库的文件ktr与kjb的方法

转载地址: https://blog.csdn.net/zuolovefu/article/details/78083445

1. 准备工作

一个简单的job,一个简单的trans。

trans:读取download目录下的所有文件名,输出为文件。【界面情况下测试成功】 

这里写图片描述

成功生成目标文件: 
这里写图片描述

job:创建文件。【界面模式测试执行成功】 
这里写图片描述

执行结果: 
这里写图片描述

把界面执行测试结果文件删除,以免影响观察。

2. linux环境以命令行方式执行job和trans

Pan是用于执行trans的PDI命令行工具。
    Kitchen是用于执行作业的PDI命令行工具。
  • 1
  • 2

a. Pan的命令行选项和语法 
语法:

pan.sh -option=value arg1 arg2
  • 1

命令行参数:

SwitchPurpose
repEnterprise or database repository name, if you are using one
userRepository username
passRepository password
transThe name of the transformation (as it appears in the repository) to launch
dirThe repository directory that contains the transformation, including the leading slash
fileIf you are calling a local KTR file, this is the filename, including the path if it is not in the local directory
levelThe logging level (Basic, Detailed, Debug, Rowlevel, Error, Nothing)
logfileA local filename to write log output to
listdirLists the directories in the specified repository
listtransLists the transformations in the specified repository directory
listrepLists the available repositories
exprepExports all repository objects to one XML file
norepPrevents Pan from logging into a repository. If you have set the KETTLE_REPOSITORY, KETTLE_USER, and KETTLE_PASSWORD environment variables, then this option will enable you to prevent Pan from logging into the specified repository, assuming you would like to execute a local KTR file instead.
safemodeRuns in safe mode, which enables extra checking
versionShows the version, revision, and build date
paramSet a named parameter in a name=value format. For example: -param:FOO=bar
listparamList information about the defined named parameters in the specified transformation.
maxloglinesThe maximum number of log lines that are kept internally by PDI. Set to 0 to keep all rows (default)
maxlogtimeoutThe maximum age (in minutes) of a log line while being kept internally by PDI. Set to 0 to keep all rows indefinitely (default)

示例:

sh pan.sh -rep=initech_pdi_repo -user=pgibbons -pass=lumburghsux -trans=TPS_reports_2011
  • 1

本地trans调用示例:

./pan.sh -file=/home/hadoop/workplace/kettle/trans/test_cml.ktr -norep
  • 1

b.Kitchen的命令行参数及语法:

语法与Pan一样,参数有点不同。

Switchurpose
repEnterprise or database repository name, if you are using one
userRepository username
pass Repositorypassword
jobThe name of the job (as it appears in the repository) to launch
dirThe repository directory that contains the job, including the leading slash
fileIf you are calling a local KJB file, this is the filename, including the path if it is not in the local directory
levelThe logging level (Basic, Detailed, Debug, Rowlevel, Error, Nothing)
logfileA local filename to write log output to
listdirLists the sub-directories within the specified repository directory
listjobLists the jobs in the specified repository directory
listrepLists the available repositories
exportExports all linked resources of the specified job. The argument is the name of a ZIP file.
norepPrevents Kitchen from logging into a repository. If you have set the KETTLE_REPOSITORY, KETTLE_USER, and KETTLE_PASSWORD environment variables, then this option will enable you to prevent Kitchen from logging into the specified repository, assuming you would like to execute a local KTR file instead.
versionShows the version, revision, and build date
paramSet a named parameter in a name=value format. For example: -param:FOO=bar
listparamList information about the defined named parameters in the specified job.
maxloglinesThe maximum number of log lines that are kept internally by PDI. Set to 0 to keep all rows (default)
maxlogtimeoutThe maximum age (in minutes) of a log line while being kept internally by PDI. Set to 0 to keep all rows indefinitely (default)

执行本地job的命令行语句:

/home/kettle/data-integration/kitchen.sh -file=/home/kettle/transition/move.kjb -log=log.log
  • 1

形式:

$kitchen路径 -file=$job路径 log=$log路径
  • 1

调用pan结果: 

这里写图片描述

调用kitchen结果: 
这里写图片描述

3.个人常用命令选项

由于我当前的工作环境都是执行本地的job和trans文件,所以常用的命令选项有:

命令描述
-filejob或trans文件路径
-norep标明不是资源库里的文件
-param参数设置
-logfilelog输出文件名
-levellog级别 (Basic, Detailed, Debug, Rowlevel, Error, Nothing)
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Kettle文件资源库是一种用于存储ETL元数据信息的资源库类型。在Kettle中,你可以选择使用文件资源库来保存转换和作业,以便更方便地进行管理和共享。在Kettle的不同版本中,创建文件资源库的步骤可能会有所不同。 在Kettle 7.1版本中,你可以通过打开默认的Pentaho资源库,然后点击"Other Repositories"来创建文件资源库文件资源库相对于数据库资源库来说,操作性更好,但权限控制可能稍差。因此,你可以根据实际需求选择使用文件资源库或数据库资源库。\[1\] 在Kettle 6.1版本中,你可以选择"工具" -> "资源库" -> "连接资源库"来创建文件资源库。填写资源库路径和名称等信息,并点击确定按钮完成新建资源库操作。之后,转换和作业保存时会默认保存到文件资源库的根目录下,方便管理。\[2\] 在Kettle 8.2版本中,你可以点击右上角的"Connect"按钮,然后选择"Other Repositories"来创建文件资源库。填写相关的资源库配置信息,并点击"Finish"按钮完成新建操作。在这个版本中,你同样可以选择文件资源库或数据库资源库来存储转换和作业。\[2\] 如果你想将之前保存在本地文件系统中的转换和作业上传到SQL Server数据库资源库,你可以选择"文件" -> "从XML文件导入"选项,将之前保存好的XML转换或作业导入,然后选择"Save"按钮将XML上传到SQL Server的数据库资源库中。这样,你就可以在数据库资源库中管理和使用这些转换和作业了。\[3\] #### 引用[.reference_title] - *1* [kettle资源库](https://blog.csdn.net/weixin_42011858/article/details/111083988)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Kettle学习--资源库](https://blog.csdn.net/linjinhuo/article/details/88699867)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Kettle(三):创建资源库](https://blog.csdn.net/MengCXJ/article/details/123095338)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值