linux下kettle網頁版執行job方式(作業採用檔案資源庫存放)
目標:通過carte服務,使用網頁版執行job(作業)
前提:
1、kettle部署在Linux機器上
2、job使用檔案資源庫方式存放,資源庫名字為DZHY,存放位置為:/home/tools/kettle/job/DZHY
步驟
1、配置檔案資源庫
首先,將kettle的作業檔案從本地放到遠端伺服器上,如存放位置為伺服器地址:/home/tools/kettle/job/DZHY
然後,在/root/.kettle/repositories.xml中配置檔案資源庫,配置方式如下:
<name>DZHY</name> <description>File repository</description> <is_default>false</is_default> <base_directory>/home/tools/kettle/job/</base_directory> <read_only>N</read_only> <hides_hidden_files>N</hides_hidden_files>
注意:<base_directory>路徑可以直接作業存放的上層資料夾路徑,後續網頁執行時需要將此部分忽略掉;
2、配置資料共享檔案
在/root/.kettle/shared.xml中配置需要連線的資料庫,示例如下:
<connection> <name>ora11g</name> <server>172.16.5.195</server> <type>ORACLE</type> <access>Native</access> <database>orcl</database> <port>1521</port> <username>GSJLS</username> <password>Encrypted 2be98afc86aa7f2e4cb79ce10ffbb80f6</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>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>N</attribute></attribute> <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute> <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute> </attributes> </connection>
3、linux下通過shell啟動carte服務
通過shell遠端啟動carte服務時,最好通過後臺命令啟動,不然關閉shell時,啟動命令也會停止;
命令如: nohup ./carte.sh a.xml &
其中a.xml內容如下:
<slave_config> <max_log_lines>5</max_log_lines> <max_log_timeout_minutes>1</max_log_timeout_minutes> <object_timeout_minutes>1</object_timeout_minutes> <slaveserver> <name>master1</name> <hostname>172.17.2.89</hostname> <port>8081</port> </slaveserver> </slave_config>
由於carte服務為Java程序,可以通過jps命令檢視程序資訊;
檢視carte服務是否啟動成功:通過瀏覽器輸入http://172.17.2.89:8081/檢視是否啟動成功
4、通過網頁執行job作業
在本地瀏覽器中輸入,即可執行成功
http://172.17.2.89:8081/kettle/executeJob/?rep=DZHY20170620&job=/DZHY/job/YWToHC/DZHY_HC&level=INFO
此時在檢視http://172.17.2.89:8081/kettle/status/,發現作業正在執行,並且沒有報錯。
注意1:啟動時執行的job路徑不能和repositories.xml中配置的base_directory有重合的地方
注意2:檔案資源庫連線方式時,一定按照如上格式進行執行,目前官方提供的carte服務的job介面文件沒有這種方式。