通常情況下,在工作中在數據抽取過程中,會使用到job進行定時抽取。本文主要介紹kettle在windows下定時執行job。
備注:我用的kettle版本是5.1.0
1、准備編寫kettle.bat腳本
有庫
D: cd D:\kettle\data-integration kitchen.bat -rep JS_JOB -user admin -pass qdhuang -dir /FTP抽取入庫 -job jobname -level=basic>D:\JOB_LOG\JOB.log
沒有庫
D: cd D:\kettle\data-integration kitchen.bat -file="D:\tools\Common\kettle_pdi-ce-8.2.0.0-342\data-integration\job_test1.kjb" -level=basic>D:\JOB.log
2、針對以上我來介紹下
首先cd 是進入到kettle安裝執行文件目錄下
-rep 表示的是你的倉庫名,也就是你的資源庫的名稱,這里我的資源庫名稱就是 JS_JOB
-user 資源庫用戶名 這里就是admin
-pass 資源庫密碼 這里是qdhuang 默認的是admin ,為了安全我們可以更改密碼
-dir 就是你的job在資源庫中存放目錄 支持中文的目錄
-job job的名稱 這里我的job名稱就是jobname
-level 日志的級別 我們普通的寫basic就可以了,就是最基本的
最后面就是日志了,針對job跑起來的相關信息都會保存在job.log中
3、針對相關的更多參數如下:
/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.
4、windows下建立執行任務
本次操作的是在windowsserver2008下
然后一步一步創建,下一步就可以了
下一步(選擇你的.bat執行文件)
下一步(選擇job的執行頻率)
輸入本服務器的密碼:必須輸入才可以執行job
至此就算完成了操作