Kitchen is a program that can execute jobs designed by Spoon in XML or in a database repository. Usually jobs are scheduled in batch mode to be run automatically at regular intervals.
The first step is the installation of Sun Microsystems Java Runtime Environment version 1.5 or higher. You can download a JRE for free athttp://www.java.com/.
After this, you can simply unzip the distribution zip-file in a directory of your choice.
In the Kettle directory where you unzipped the file, you will find a number of files.
Under Unix-like environments (Solaris, Linux, OSX, ...) you will need to make the shell scripts executable. Execute these commands to make all shell scripts in the Kettle directory executable:
cd Kettle chmod +x *.sh
To launch Kitchen on the different platforms these are the scripts that are provided:
Kitchen can be run on any platform that has a version of the Java Runtime Environment version 1.5 or higher.
These are the command line options that you can use.
IMPORTANT NOTES:
On Windows system, the use of the minus ("-") in the options causes problems as well as the equal sign ("="). Because of this, from version 2.2.2 on, you can also use this format or any combination of /,- and :,=
Fields in italic represent the values that the options use.
It's important that if spaces are present in the option values, you use quotes or double quotes to keep them together. Take a look at the examples below for more info.
/option:value
Below are the valid options.
-version
This option displays the version of the Kettle core library (kettle.jar).
The build version number and build date are shown as well.
--file=filename
This option runs the job defined in the XML file. (.kjb : Kettle Job)
-log=Logging Filename
Specifies the log file. The default is the standard output.
-level=Logging Level
The level option sets the log level for the job that's being run.
These are the possible values:
-rep=Repository name
Connect to the repository with name "Repository name".
You also need to specify the options -user, -pass, -dir and -job.
You can also specify this option in the form of environment variable KETTLE_REPOSITORY.
-user=Username
This is the username with which you want to connect to the repository.
You can also specify this option in the form of environment variable KETTLE_USER.
-pass=Password
The password to use to connect to the repository
You can also specify this option in the form of environment variable KETTLE_PASSWORD.
-job=Job Name
Use this option to select the job to run from the repository. Please also select the directory with the "-dir" option.
-listdir=Y
Print a listing of all the sub-directories in the repository directory specified with the option "-dir".
-dir=directory
Specifies the directory in the repository to use. Repository directories are specified like this:
From version 2.2.2 on, a / (slash) is used to separate directories on all platforms.
-listjobs=Y
Show a list of all the jobs in the repository directory specified with the option "-dir".
-listrep=Y
Print a listing of all the defined repositories.
-norep=Y
If you have set environment variables KETTLE_REPOSITORY, KETTLE_USER, KETTLE_PASSWORD, you can prevent Kitchen from logging into the repository. For example if you want to launch a job from an XML file.
Please make sure that you are positioned in the Kettle directory before running the samples below. If you put these scripts into a batch file or shell script, simply do a change directory to the installation directory:
If Kettle was installed on windows on the D:\ drive
D: cd \Kettle
If Kettle was installed in the /product directory on a Unix system:
cd /product/Kettle/
This example runs a job from file on a windows platform:
kitchen.bat /file:D:\Jobs\updateWarehouse.kjb /level:Basic
This example runs a job from file on a Linux box:
kitchen.sh -file=/PRD/updateWarehouse.kjb -level=Minimal
This example runs a job from the repository on a windows platform:
(Enter on a single line without returns...)
kitchen.bat /rep:"Production Repository" /job:"Update dimensions" /dir:/Dimensions /user:matt /pass:somepassword123 /level:Basic
例:
kitchen.bat /rep:"ywykettle" /user:admin /pass:admin /job "job_ywy" /dir:/执行job
If you don't want the output of the file to appear on the screen but rather be put into a log file, you can use redirection.
This example adds the Kitchen output to an ever-growing log file:
kitchen.sh -file="/PRD/updateWarehouse.kjb" --level=Minimal >> /LOG/trans.log
This example writes the Kitchen output to a file that gets overwritten every time:
kitchen.bat /file:C:\PRD\runAll.kjb /level:Basic > C:\LOG\trans.log
Kitchen returns an error code based on how the execution went:
The best way to go at it is to test the command first at the dos prompt.
Then you can use the windows scheduler to launch this command.
Windows versions since Windows 2000 have a GUI for doing this accessible through the control panel. However it's also possible to use the command line to do this:
at 23:30 /every:Monday,Wednesday,Friday "D:\updateWarehouse.bat
To see a list of the scheduled commands simply type:
at
First create a shell script that runs all the jobs you need. Then you can schedule this script to run.
On Unix like systems the easiest way to schedule a command is by using the "cron table". You can do this by entering the following command:
crontab -e
Then you can enter the time at which the command needs to be run as well as the command on a single line in the text file that is presented.
The first options are:
You can specify more then 1 number for each of these values by separating 2 number with a hyphen -. This means an inclusive number range. If you separate the number by commas (,), it means distinct values. If you use * instead of a number, it means: every possible hour, minute, day, month or weekday.
So, if you want to update the dimensions every hour, at 15 and 45 minutes past the hour during the weekdays, you might enter these lines in a crontab:
# # Launches the update of the dimensions in the warehouse # 15,45 * * * 1-5 /PROD/update_dimensions.sh
Kettle定时功能。
<wbr><wbr><wbr>在Job下的start模块,有一个定时功能,可以每日,每周等方式进行定时,对于周期性的ETL,很有帮助。</wbr></wbr></wbr>
<wbr><wbr><wbr>a.使用资源库(repository)登录时,默认的用户名和密码是admin/admin。</wbr></wbr></wbr>
<wbr><wbr><wbr>b.当job是存放在资源库(一般资源库都使用数据库)中时,使用Kitchen.bat执行job时,需使用如下的命令行:<span style="color:#0080C0"><br></span><span style="color:#0080C0">Kitchen.bat /rep kettle /user admin/pass admin /job job名</span></wbr></wbr></wbr>
<wbr><wbr><wbr>c.当job没有存放在资源库而存放在文件系统时,使用Kitchen.bat执行job时,需使用如下的命令行:<span style="color:#0080C0"><br> Kitchen.bat /norep /file user-transfer-job.kjb</span></wbr></wbr></wbr>
<wbr><wbr><wbr>d.可以使用命令行执行job后,就可以使用windows或linux的任务调度来定时执行任务了</wbr></wbr></wbr>
<wbr><wbr><wbr>e.如果出现异常语句,</wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><wbr><wbr>Unexpected error during transformation metadata load<br><wbr><wbr><wbr><wbr><wbr><wbr>No repository defined!</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr>请按上面的操作排除。</wbr></wbr></wbr>