kettle作业通常连接资源库进行使用,所有linux后台部署命令需要使用连接资源库:
执行远程资源库中的job命令
./kitchen.sh -rep=资源库名称 -user=资源库用户名 -pass=资源库密码 -dir=资源库目录名称 -job=作业名称 -level=日志级别
资源库名称配置方法:
在解压的kettle包下新建或者找到repositories.xml文件,再其文件中配置如下:
可配置多个资源库.
<?xml version="1.0" encoding="UTF-8"?>
<repositories>
<connection>
<name>kettle_db1</name>
<server>xx.xx.xx.xx</server>
<type>ORACLE</type>
<access>Native</access>
<database>DBsid</database>
<port>1521</port>
<username>user_name</username>
<password>Encrypted 2be98afc86ad7c18fae0dba7cdbc3fd89</password>
<servername/>
<data_tablespace/>
<index_tablespace/>
<attributes>
<attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
<attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
<attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
<attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
<attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
<attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
<attribute><code>STRICT_NUMBER_38_INTERPRETATION</code><attribute>N</attribute></attribute>
<attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
<attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
<attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
</attributes>
</connection>
<connection>
<name>kettle_db2</name>
<server>xx.xx.xx.xx</server>
<type>ORACLE</type>
<access>Native</access>
<database>DBSID</database>
<port>1521</port>
<username>user_name</username>
<password>Encrypted 2be98afc86aa7f2e4cb18aa7d8fc0fc8e</password>
<servername/>
<data_tablespace/>
<index_tablespace/>
<attributes>
<attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
<attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
<attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
<attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
<attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>Y</attribute></attribute>
<attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
<attribute><code>STRICT_NUMBER_38_INTERPRETATION</code><attribute>N</attribute></attribute>
<attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
<attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
<attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
</attributes>
</connection>
<repository> <id>KettleDatabaseRepository</id>
<name>rep_name1</name>
<description>对应命令调用的-rep参数名称</description>
<is_default>true</is_default>
<connection>kettle_db1</connection>
</repository> <repository> <id>KettleDatabaseRepository</id>
<name>rep_name2</name>
<description>Database repository</description>
<is_default>true</is_default>
<connection>kettle_db2</connection>
</repository> </repositories>
shell脚本使用kitchen.sh命令调用资源库执行作业任务:
创建p_load_kettle.sh脚本
##p_load_kettle.sh
##sh p_load_kettle.sh /ETL/Job/j_tab_hv 20180101000000 20180102000000
#!/bin/bash
#################################################################################
#DESCRIPTION : load kettle common shell
#################################################################################
#################################################################################
#get input parameter
#################################################################################
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ];then
exit 1
else
job_dir=$1
start_timekey=$2
end_timekey=$3
fi
#################################################################################
#MAIN BLOCK
#################################################################################
dir=${job_dir%/*}
job_name=${job_dir##*/}
table_name=${job_name:2}
echo $dir
echo $job_name
echo $table_name
#start error rerun 3 times
for((i=0;i<3;i++))
do
sh /home/cdhap/data-integration/kitchen.sh -rep rep_name1 -user admin -pass admin -dir $dir -job $job_name -param:job_name="$job_name" -param:table_name="$table_name" -param:start_timekey="$start_timekey" -param:end_timekey="$end_timekey" -level=Error
returncode=$?
if [ $returncode -eq 0 -o $i -eq 2 ];then
echo "returncode=$returncode"
echo "exit $returncode"
exit $returncode
fi
echo "first execute end!!!"
sleep 5
done
#end
linux使用脚本
[cdhap@etlap ~]$ sh ~/p_load_kettle.sh /job路径/jobName 开始时间 结束时间

7681

被折叠的 条评论
为什么被折叠?



